public async Task <ActionResult <Supplement> > Put(string id, [FromBody] Supplement su) { var suplement = await _supplementService.Get(id); if (suplement == null) { return(NotFound()); } su.Id = suplement.Id; await _supplementService.Update(id, su); return(CreatedAtRoute("Get", new { id = su.Id.ToString() }, su)); }
public HttpResponseMessage UpdateSupplement(SupplementAddRequest model) { try { if (ModelState.IsValid) { SupplementService svc = new SupplementService(); svc.Update(model); SuccessResponse resp = new SuccessResponse(); return(Request.CreateResponse(HttpStatusCode.OK, resp)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }