public OperationResult Define(DefineColleagueDiscount command)
        {
            var operation = new OperationResult();

            if (_colleagueDiscountRepository.Exists(x => x.Id == command.ProductId && x.DiscountRate == command.DiscountRate))
            {
                return(operation.Failed(ApplicationMessages.DuplicatedRecord));
            }
            var colleagueDiscount = new ColleagueDiscount(command.ProductId, command.DiscountRate);

            _colleagueDiscountRepository.Create(colleagueDiscount);
            _colleagueDiscountRepository.SaveChanges();
            return(operation.Succeeded());
        }
        public OperationResult Define(DefineColleagueDiscount command)
        {
            var result = new OperationResult();

            if (_colleagueDiscountRepository.Exists(cd => cd.ProductId == command.ProductId))
            {
                return(result.Failed(QueryValidationMessage.DuplicateRecord));
            }

            var colleagueDiscount = new ColleagueDiscount(command.ProductId, command.DiscountRate);

            _colleagueDiscountRepository.Create(colleagueDiscount);
            _colleagueDiscountRepository.SaveChanges();
            return(result.Succeeded());
        }
Ejemplo n.º 3
0
        public OperationResult Define(ColleagueDiscountDefine define)
        {
            var operation = new OperationResult();

            if (_colleagueDiscountRepository.Exists(d => d.ProductId == define.ProductId &&
                                                    d.DiscountRate == define.DiscountRate))
            {
                return(operation.Fail(ApplicationMessages.DuplicateRecord));
            }

            var colleageDiscount = new ColleagueDiscount(define.ProductId, define.DiscountRate);

            _colleagueDiscountRepository.Create(colleageDiscount);
            _colleagueDiscountRepository.SaveChanges();
            return(operation.Success());
        }