public async Task CreateOrUpdateProductGroup(CreateProductGroupInput input) { if (input.Id != 0) { await UpdateProductGroup(input); } else { await CreateProductGroup(input); } }
public async Task CreateProductGroup(CreateProductGroupInput input) { using (_unitOfWorkManager.Current.SetTenantId(_session.TenantId)) { input.TenantId = (int)_session.TenantId; var productgroup = input.MapTo <ProductGroup>(); var val = _productGroupRepository .GetAll().Where(p => p.ProductGroupName == input.ProductGroupName || p.ProductGroupCode == input.ProductGroupCode).FirstOrDefault(); if (val == null) { await _productGroupRepository.InsertAsync(productgroup); } else { throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in ProductGroupName '" + input.ProductGroupName + "' or ProductGroupCode '" + input.ProductGroupCode + "'..."); } } }