public OperationResult Edit(EditCustoemrDiscount command)
        {
            var operation        = new OperationResult();
            var customerDiscount = _customerDiscountRepository.Get(command.Id);

            if (customerDiscount == null)
            {
                return(operation.Failed(ApplicationMessages.RecordNotFound));
            }

            if (_customerDiscountRepository.Exists(x => x.ProductId == command.ProductId &&
                                                   x.DiscountRate == command.DiscountRate && x.Id != command.Id))
            {
                return(operation.Failed(ApplicationMessages.DuplicatedRecord));
            }

            var startDate = command.StartDate.ToGeorgianDateTime();
            var endDate   = command.EndDate.ToGeorgianDateTime();

            customerDiscount.Edit(command.ProductId, command.DiscountRate, startDate, endDate, command.Reason);
            _customerDiscountRepository.SaveChanges();
            return(operation.Succedded());
        }
Exemple #2
0
        public JsonResult OnPostEdit(EditCustoemrDiscount command)
        {
            var result = _customerDiscountApplication.Edit(command);

            return(new JsonResult(result));
        }