示例#1
0
 public ActionResult <Keep> Patch(int id, [FromBody] KeepPatch keepPatchBody)
 {
     try
     {
         keepPatchBody.Id = id;
         Keep updatedKeep = _service.Patch(keepPatchBody);
         return(Ok(updatedKeep));
     }
     catch (System.Exception error)
     {
         return(BadRequest(error.Message));
     }
 }
示例#2
0
        internal Keep Patch(KeepPatch keepPatch)
        {
            Keep keep = _repo.GetById(keepPatch.Id);

            if (keep == null)
            {
                throw new Exception("Invalid Id / No longer exists");
            }
            keep.Views = keepPatch.Views;
            keep.Keeps = keepPatch.Keeps;
            Keep updatedKeep = _repo.Update(keep);

            return(_repo.GetById(updatedKeep.Id));
        }