public async Task <IActionResult> AddAsync([FromRoute] int customerNumber, [FromBody] CustomerAddress newAddress) { _customerContext.CustomerAddress.Add(newAddress); await _customerContext.SaveChangesAsync(); return(Ok(newAddress)); }
public async Task <IActionResult> AddAsync([FromBody] RetailCustomer newCustomer) { _customerContext.RetailCustomer.Add(newCustomer); await _customerContext.SaveChangesAsync(); return(Ok(newCustomer)); }
public async Task <IActionResult> AddAsync([FromBody] CorporateCustomer newCustomer) { string validationResult = newCustomer.ValidateAndPrepeareForInsert(); if (!string.IsNullOrEmpty(validationResult)) { Error a = new Error(); a.Title = "Invalid fields"; a.Message = validationResult; return(BadRequest(a)); } _customerContext.CorporateCustomer.Add(newCustomer); await _customerContext.SaveChangesAsync(); return(Ok(newCustomer)); }