public IActionResult UpdateInfo([FromBody] Customer customer, int id) { if (customer == null) { var newCustUtil = new CustomerUtils(); var item = newCustUtil.GetCustomerById(id); if (item == null) { return(NotFound("Customer Was Not Found")); } return(new ObjectResult(item)); } else { var newCustUtil = new CustomerUtils(); customer.CustomerId = id; try { var result = newCustUtil.UpdateCustomer(customer); if (result) { return(NoContent()); } return(BadRequest($"Couldn't Update Customer!")); } catch (Exception e) { return(BadRequest($"Couldn't Update Customer!" + e)); } } }
public IActionResult UpdateInfo([FromBody] Customer customer) { var newCustUtil = new CustomerUtils(); try { var result = newCustUtil.UpdateCustomer(customer); if (result) { //SUCCESS _context.Customers.Add(customer); _context.SaveChanges(); return(CreatedAtRoute("GetCustomer", new { id = customer.CustomerId }, customer)); } return(BadRequest($"Couldn't Update Customer!")); } catch (Exception e) { return(BadRequest($"Couldn't Update Customer!" + e)); } }