Beispiel #1
0
        private void ValidateCustomerCategory(CustomerCategoryDto item)
        {
            if (item is null)
            {
                throw new ValidationException(StringRes.NullEntityMsg, new ArgumentNullException(nameof(item)));
            }

            if (_customerCategoryEntityService.GetAll().Any(i => i.Name == item.Name))
            {
                throw new ValidationException(StringRes.NameShouldBeUniqueMsg, fieldName: nameof(item.Name));
            }

            if (item.SaleCoefficient > Constants.CoefficientMaximum || item.SaleCoefficient < Constants.CoefficientMinimum)
            {
                throw new ValidationException(StringRes.CoefficientBoundsMsg, fieldName: nameof(item.SaleCoefficient));
            }
        }
Beispiel #2
0
        public async Task UpdateCustomerCategoryAsync(CustomerCategoryDto item)
        {
            ValidateCustomerCategory(item);

            await _customerCategoryEntityService.UpdateAsync(_mapper.Map <CustomerCategory>(item));
        }
Beispiel #3
0
        // CUSTOMERCATEGORY
        public async Task <int> CreateCustomerCategoryAsync(CustomerCategoryDto item)
        {
            ValidateCustomerCategory(item);

            return(await _customerCategoryEntityService.CreateAsync(_mapper.Map <CustomerCategory>(item)));
        }