public Task <DiscountDTO> AddAsync(DiscountDTO discountDTO) { CheckValidProductSKU(discountDTO); var discount = discountDTO.ToModel(); discount.Id = Guid.NewGuid(); Discounts.AddOrUpdate(discount); return(Task.FromResult <DiscountDTO>(DiscountDTO.FromModel(discount))); }
public Task <DiscountDTO> UpdateAsync(DiscountDTO discountDTO) { var existingDiscount = Discounts.Get(discountDTO.Id); if (existingDiscount == null) { throw new Exception(string.Format(ERROR_DISCOUNT_NOT_FOUND, discountDTO.Id)); } CheckValidProductSKU(discountDTO); Discounts.AddOrUpdate(discountDTO.ToModel()); return(Task.FromResult <DiscountDTO>(discountDTO)); }