Пример #1
0
        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));
        }
Пример #2
0
 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));
     }
 }