Example #1
0
        public IActionResult OnPostEdit(EditColleagueDiscount command)
        {
            var result = new OperationResult();

            if (ModelState.IsValid)
            {
                result = _colleagueDiscountApplication.Edit(command);
            }

            return(new JsonResult(result));
        }
        public OperationResult Edit(EditColleagueDiscount command)
        {
            var result   = new OperationResult();
            var discount = _colleagueDiscountRepository.Get(command.Id);

            if (discount == null)
            {
                return(result.Failed(QueryValidationMessage.NotFound));
            }
            if (_colleagueDiscountRepository.Exists(cd => cd.ProductId == command.ProductId && cd.Id != command.Id))
            {
                return(result.Failed(QueryValidationMessage.DuplicateRecord));
            }

            discount.Edit(command.ProductId, command.DiscountRate);
            _colleagueDiscountRepository.SaveChanges();
            return(result.Succeeded());
        }
Example #3
0
        public OperationResult Edit(EditColleagueDiscount command)
        {
            var operation         = new OperationResult();
            var colleagueDiscount = _colleagueDiscountRepository.Get(command.Id);

            if (colleagueDiscount == null)
            {
                return(operation.Failed(ApplicationMessages.RecordNotFound));
            }
            if (_colleagueDiscountRepository.Exsists(x => x.ProductId == command.ProductId && x.DiscountRate == command.DiscountRate && x.Id != command.Id))
            {
                return(operation.Failed(ApplicationMessages.DuplicatedRecord));
            }

            colleagueDiscount.Edit(command.ProductId, command.DiscountRate);
            _colleagueDiscountRepository.SaveChanges();

            return(operation.Succeded());
        }
Example #4
0
        public JsonResult OnPostEdit(EditColleagueDiscount command)
        {
            var result = _colleagueDiscountApplication.Edit(command);

            return(new JsonResult(result));
        }