コード例 #1
0
        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)));
        }
コード例 #2
0
        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));
        }