public IHttpActionResult UpdateCustomer(string token, int userId, Customer customer) { if (!ModelState.IsValid || !ApplicationHelper.IsTokenValid(token, userId)) { return(Content(HttpStatusCode.BadRequest, "BadRequest")); } var customerDb = CustomersLogic.GetCustomer(customer.customerId); if (customerDb == null) { return(Content(HttpStatusCode.NotFound, "NotFound")); } var result = CustomersLogic.UpdateCustomer(customer); if (!result.Success) { ApplicationHelper.Log(result.Message); } return(result.Success ? Content(HttpStatusCode.OK, "OK") : Content(HttpStatusCode.InternalServerError, result.Message)); }
public IHttpActionResult GetCustomer(string token, int userId, int id) { if (!ApplicationHelper.IsTokenValid(token, userId)) { return(Content(HttpStatusCode.BadRequest, "BadRequest")); } var customer = CustomersLogic.GetCustomer(id); if (customer == null) { return(Content(HttpStatusCode.NotFound, "NotFound")); } return(Content(HttpStatusCode.OK, customer)); }