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)); } }
public async Task UpdateCustomerCategoryAsync(CustomerCategoryDto item) { ValidateCustomerCategory(item); await _customerCategoryEntityService.UpdateAsync(_mapper.Map <CustomerCategory>(item)); }
// CUSTOMERCATEGORY public async Task <int> CreateCustomerCategoryAsync(CustomerCategoryDto item) { ValidateCustomerCategory(item); return(await _customerCategoryEntityService.CreateAsync(_mapper.Map <CustomerCategory>(item))); }