public async Task CreateOrUpdateProductAttribute(CreateProductAttributeInput input) { if (input.Id != 0) { await UpdateProductAttribute(input); } else { await CreateProductAttribute(input); } }
public async Task CreateProductAttribute(CreateProductAttributeInput input) { var attribute = input.MapTo <ProductAttribute>(); var val = _productAttributeRepository .GetAll().Where(p => p.AttributeCode == input.AttributeCode || p.AttributeName == input.AttributeName).FirstOrDefault(); if (val == null) { await _productAttributeRepository.InsertAsync(attribute); } else { throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in AttributeCode '" + input.AttributeCode + "' or AttributeName '" + input.AttributeName + "'..."); } }