mirror of https://github.com/EasyAbp/EShop.git
27 changed files with 452 additions and 65 deletions
@ -0,0 +1,77 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace EasyAbp.EShop.Plugins.Baskets.BasketItems.Dtos; |
|||
|
|||
[Serializable] |
|||
public class ClientSideBasketItemModel : IBasketItem |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string BasketName { get; set; } |
|||
|
|||
public int Quantity { get; set; } |
|||
|
|||
public Guid StoreId { get; set; } |
|||
|
|||
public Guid ProductId { get; set; } |
|||
|
|||
public string ProductUniqueName { get; set; } |
|||
|
|||
public string ProductDisplayName { get; set; } |
|||
|
|||
public Guid ProductSkuId { get; set; } |
|||
|
|||
public string SkuName { get; set; } |
|||
|
|||
public string SkuDescription { get; set; } |
|||
|
|||
public string MediaResources { get; set; } |
|||
|
|||
public string Currency { get; set; } |
|||
|
|||
public decimal UnitPrice { get; set; } |
|||
|
|||
public decimal TotalPrice { get; set; } |
|||
|
|||
public decimal TotalDiscount { get; set; } |
|||
|
|||
public int Inventory { get; set; } |
|||
|
|||
public bool IsInvalid { get; set; } |
|||
|
|||
public ClientSideBasketItemModel( |
|||
Guid id, |
|||
[NotNull] string basketName, |
|||
Guid storeId, |
|||
Guid productId, |
|||
Guid productSkuId) |
|||
{ |
|||
Id = id; |
|||
BasketName = basketName; |
|||
StoreId = storeId; |
|||
ProductId = productId; |
|||
ProductSkuId = productSkuId; |
|||
} |
|||
|
|||
public void SetIsInvalid(bool isInvalid) |
|||
{ |
|||
IsInvalid = isInvalid; |
|||
} |
|||
|
|||
public void UpdateProductData(int quantity, IProductData productData) |
|||
{ |
|||
Quantity = quantity; |
|||
|
|||
MediaResources = productData.MediaResources; |
|||
ProductUniqueName = productData.ProductUniqueName; |
|||
ProductDisplayName = productData.ProductDisplayName; |
|||
SkuName = productData.SkuName; |
|||
SkuDescription = productData.SkuDescription; |
|||
Currency = productData.Currency; |
|||
UnitPrice = productData.UnitPrice; |
|||
TotalPrice = productData.TotalPrice; |
|||
TotalDiscount = productData.TotalDiscount; |
|||
Inventory = productData.Inventory; |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
namespace EasyAbp.EShop.Plugins.Baskets.BasketItems.Dtos; |
|||
|
|||
public class GenerateClientSideDataInput : ExtensibleObject |
|||
{ |
|||
public List<GenerateClientSideDataItemInput> Items { get; set; } = new(); |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
namespace EasyAbp.EShop.Plugins.Baskets.BasketItems.Dtos |
|||
{ |
|||
[Serializable] |
|||
public class GenerateClientSideDataItemInput : ExtensibleObject |
|||
{ |
|||
/// <summary>
|
|||
/// Reuse Id if set.
|
|||
/// </summary>
|
|||
public Guid? Id { get; set; } |
|||
|
|||
public string BasketName { get; set; } = BasketsConsts.DefaultBasketName; |
|||
|
|||
public Guid ProductId { get; set; } |
|||
|
|||
public Guid ProductSkuId { get; set; } |
|||
|
|||
public int Quantity { get; set; } |
|||
|
|||
public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext) |
|||
{ |
|||
base.Validate(validationContext); |
|||
|
|||
if (Quantity <= 0) |
|||
{ |
|||
yield return new ValidationResult( |
|||
"Quantity should be greater than 0.", |
|||
new[] { "Quantity" } |
|||
); |
|||
} |
|||
|
|||
if (BasketName.IsNullOrWhiteSpace()) |
|||
{ |
|||
yield return new ValidationResult( |
|||
"BasketName should not be empty.", |
|||
new[] { "BasketName" } |
|||
); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace EasyAbp.EShop.Plugins.Baskets.BasketItems; |
|||
|
|||
public interface IBasketItem : IProductData |
|||
{ |
|||
Guid Id { get; } |
|||
|
|||
[NotNull] |
|||
string BasketName { get; } |
|||
|
|||
Guid StoreId { get; } |
|||
|
|||
Guid ProductId { get; } |
|||
|
|||
Guid ProductSkuId { get; } |
|||
|
|||
int Quantity { get; } |
|||
|
|||
bool IsInvalid { get; } |
|||
|
|||
void SetIsInvalid(bool isInvalid); |
|||
|
|||
void UpdateProductData(int quantity, IProductData productData); |
|||
} |
|||
Loading…
Reference in new issue