Browse Source

Merge branch 'gterdem/payment' into enisn/payment-paypal-flow

pull/48/head
enisn 5 years ago
parent
commit
03503f8a38
  1. 32
      apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs
  2. 34
      apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml
  3. 5
      apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetStyleContributor.cs
  4. 23
      apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs
  5. 18
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.css

32
apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs

@ -0,0 +1,32 @@
using System.Collections.Generic;
using Volo.Abp.DependencyInjection;
namespace EShopOnAbp.PublicWeb.Basket;
public class UserAddressProvider : ITransientDependency
{
public List<AddressDto> GetDemoAddresses()
{
return new List<AddressDto>()
{
new()
{
Name = "Home",
Description = "Cecilia Chapman Senior 711-2880 Nulla St. Mankato Mississippi 96522/USA",
IsDefault = true
},
new()
{
Name = "Work",
Description = "Yeşilköy Serbest Bölge Mah. E-Blok Sokak E1 Blok No:2, Bakırköy/İstanbul"
}
};
}
}
public class AddressDto
{
public string Name { get; set; }
public string Description { get; set; }
public bool IsDefault { get; set; } = false;
}

34
apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml

@ -1,19 +1,47 @@
@using EShopOnAbp.Localization
@using EShopOnAbp.PublicWeb.Components.Purchase
@using Microsoft.Extensions.Localization
@model EShopOnAbp.PublicWeb.Components.Payment.PaymentViewModel
@inject IStringLocalizer<EShopOnAbpResource> L
@{
const int defaultColumnSize = 4;
}
<div class="row">
<div class="col-lg-9">
<div class="address-list">
<div class="address-list p-5">
<h3>Select Address</h3>
@for (int i = 0; i < Math.Ceiling(Model.Address.Count / (double) defaultColumnSize); i++)
{
<abp-row>
@for (int j = 0; j < defaultColumnSize; j++)
{
<abp-column size-lg="_3" size-md="_4" size-sm="_6">
@if ((i * defaultColumnSize) + j < Model.Address.Count)
{
var address = Model.Address[(i * defaultColumnSize) + j];
string isSelected = address.IsDefault ? "is-selected" : string.Empty;
<div class="card @isSelected">
<div class="card-body">
<h4 class="card-title">@address.Name</h4>
<p class="card-text">@address.Description</p>
</div>
</div>
}
</abp-column>
}
</abp-row>
}
</div>
<div class="payment-list">
<div class="payment-list p-5">
<h3>Select Payment Method</h3>
</div>
</div>
<div class="col-lg-3">
@await Component.InvokeAsync(typeof(PurchaseWidgetViewComponent),
new {Basket = Model, ButtonDescription = "CompleteOrder"})
new {Basket = Model.Basket, ButtonDescription = "CompleteOrder"})
</div>
</div>

5
apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetStyleContributor.cs

@ -1,7 +1,12 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace EShopOnAbp.PublicWeb.Components.Payment;
public class PaymentWidgetStyleContributor: BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("/components/payment/payment-widget.css");
}
}

23
apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs

@ -1,4 +1,6 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading.Tasks;
using EShopOnAbp.BasketService;
using EShopOnAbp.PublicWeb.Basket;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
@ -12,17 +14,30 @@ namespace EShopOnAbp.PublicWeb.Components.Payment;
StyleTypes = new[] {typeof(PaymentWidgetStyleContributor)},
ScriptTypes = new[] {typeof(PaymentWidgetScriptContributor)}
)]
public class PaymentWidgetViewComponent: AbpViewComponent
public class PaymentWidgetViewComponent : AbpViewComponent
{
private readonly UserBasketProvider _userBasketProvider;
private readonly UserAddressProvider _userAddressProvider;
public PaymentWidgetViewComponent(UserBasketProvider userBasketProvider)
public PaymentWidgetViewComponent(UserBasketProvider userBasketProvider, UserAddressProvider userAddressProvider)
{
_userBasketProvider = userBasketProvider;
_userAddressProvider = userAddressProvider;
}
public async Task<IViewComponentResult> InvokeAsync()
{
return View("~/Components/Payment/Default.cshtml", await _userBasketProvider.GetBasketAsync());
var viewModel = new PaymentViewModel()
{
Basket = await _userBasketProvider.GetBasketAsync(),
Address = _userAddressProvider.GetDemoAddresses()
};
return View("~/Components/Payment/Default.cshtml", viewModel);
}
}
public class PaymentViewModel
{
public BasketDto Basket { get; set; }
public List<AddressDto> Address { get; set; }
}

18
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.css

@ -0,0 +1,18 @@
.card {
/* Add shadows to create the "card" effect */
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
}
/* On mouse-over, add a deeper shadow */
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}
/* Add some padding inside the card container */
.card-body {
padding: 2px 16px;
}
.is-selected{
border: solid #bfbfe3;
}
Loading…
Cancel
Save