public IHttpActionResult Patch(CustomerViewModel model) { if (!model.id.HasValue || model.id.Value < 0) { return(BadRequest()); } var svc = new CustomerAppSvcGeneric(); var toUpdate = svc.Get(model.id.Value); if (toUpdate == null) { return(NotFound()); } try { toUpdate.Name = model.customerName; toUpdate.ContactName = model.contactName; var result = svc.Update(toUpdate); return(Ok(result)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IHttpActionResult Get(int id) { if (id < 0) { return(BadRequest()); } var svc = new CustomerAppSvcGeneric(); var customer = svc.Get(id); if (customer == null) { return(NotFound()); } return(Ok(customer)); }
public IHttpActionResult Delete(int id) { if (id < 0) { return(BadRequest()); } var svc = new CustomerAppSvcGeneric(); var customer = svc.Get(id); if (customer == null) { return(NotFound()); } var result = svc.Delete(id); return(result ? StatusCode(HttpStatusCode.NoContent) : StatusCode(HttpStatusCode.InternalServerError)); }