47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using DataProviders;
|
|
using DomainResults.Common;
|
|
|
|
using WeatherForecast.Models.Requests;
|
|
using WeatherForecast.Models.Responses;
|
|
|
|
namespace WeatherForecast.Services {
|
|
|
|
public interface IShopCartService {
|
|
(GetShopCartResponseModel?, IDomainResult) GetShopCart(Guid siteId, Guid userId);
|
|
(Guid?, IDomainResult) UpdateShopCart(Guid siteId, Guid userId, Guid shopCartId, PutShopCatalogRequestModel requestData);
|
|
}
|
|
|
|
public class ShopCartService : IShopCartService {
|
|
|
|
ILogger<ShopCartService> _logger;
|
|
IShopCartDataProvider _shopCartDataProvider;
|
|
|
|
public ShopCartService(
|
|
ILogger<ShopCartService> logger,
|
|
IShopCartDataProvider shopCartDataprovider
|
|
) {
|
|
_logger = logger;
|
|
_shopCartDataProvider = shopCartDataprovider;
|
|
}
|
|
|
|
public (GetShopCartResponseModel?, IDomainResult) GetShopCart(Guid siteId, Guid userId) {
|
|
var (items, result) = _shopCartDataProvider.Get(siteId, userId);
|
|
|
|
if (!result.IsSuccess || items == null)
|
|
return (null, result);
|
|
|
|
return IDomainResult.Success(new GetShopCartResponseModel(items));
|
|
}
|
|
|
|
public (Guid?, IDomainResult) UpdateShopCart(Guid siteId, Guid userId, Guid shopCartId, PutShopCatalogRequestModel requestData) {
|
|
var shopCart = requestData.ToDomainObject();
|
|
|
|
shopCart.Id = shopCartId;
|
|
shopCart.SiteId = siteId;
|
|
shopCart.UserId = userId;
|
|
|
|
return IDomainResult.Failed<Guid?>();
|
|
}
|
|
}
|
|
}
|