public async Task CreateOrUpdateProductCategory(ProductCategoryInput input) { if (input.Id != 0) { await UpdateProductCategory(input); } else { await CreateProductCategory(input); } }
public async Task CreateProductCategory(ProductCategoryInput input) { var category = input.MapTo <ProductCategory>(); var val = _productCategoryRepository .GetAll().Where(p => p.Code == input.Code || p.Name == input.Name).FirstOrDefault(); if (val == null) { await _productCategoryRepository.InsertAsync(category); } else { throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Code '" + input.Code + "' orName '" + input.Name + "'..."); } }