Browse Source
* ardalis/cart-updates Updating how items are added to cart and displayed in cart. * Cleaning up UImain
committed by
GitHub
16 changed files with 258 additions and 22 deletions
@ -0,0 +1,8 @@ |
|||||
|
namespace ApplicationCore.Interfaces |
||||
|
{ |
||||
|
|
||||
|
public interface IUriComposer |
||||
|
{ |
||||
|
string ComposePicUri(string uriTemplate); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
using ApplicationCore.Interfaces; |
||||
|
using Microsoft.eShopWeb; |
||||
|
|
||||
|
namespace ApplicationCore.Services |
||||
|
{ |
||||
|
public class UriComposer : IUriComposer |
||||
|
{ |
||||
|
private readonly CatalogSettings _catalogSettings; |
||||
|
|
||||
|
public UriComposer(CatalogSettings catalogSettings) |
||||
|
{ |
||||
|
_catalogSettings = catalogSettings; |
||||
|
} |
||||
|
public string ComposePicUri(string uriTemplate) |
||||
|
{ |
||||
|
return uriTemplate.Replace("http://catalogbaseurltobereplaced", _catalogSettings.CatalogBaseUrl); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using Microsoft.eShopWeb.ApplicationCore.Entities; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.ViewModels |
||||
|
{ |
||||
|
|
||||
|
public class BasketItemViewModel |
||||
|
{ |
||||
|
public string Id { get; set; } |
||||
|
public string ProductId { get; set; } |
||||
|
public string ProductName { get; set; } |
||||
|
public decimal UnitPrice { get; set; } |
||||
|
public decimal OldUnitPrice { get; set; } |
||||
|
public int Quantity { get; set; } |
||||
|
public string PictureUrl { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.ViewModels |
||||
|
{ |
||||
|
|
||||
|
public class BasketViewModel |
||||
|
{ |
||||
|
public List<BasketItemViewModel> Items { get; set; } = new List<BasketItemViewModel>(); |
||||
|
public string BuyerId { get; set; } |
||||
|
|
||||
|
public decimal Total() |
||||
|
{ |
||||
|
return Math.Round(Items.Sum(x => x.UnitPrice * x.Quantity), 2); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue