public HttpResponseMessage PutChecklistAPI(Checklist checklist)
        {
            if (checklist == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotFound));
            }

            _context.Entry(checklist).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChecklistExists(checklist.Id))
                {
                    return(new HttpResponseMessage(HttpStatusCode.NotFound));
                }
                else
                {
                    throw;
                }
            }

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Example #2
0
 public void Update(T entity)
 {
     if (entity is null)
     {
         throw new ArgumentNullException(nameof(entity));
     }
     _dbset.Attach(entity);
     _checklistContext.Entry(entity).State = EntityState.Modified;
 }
Example #3
0
 public ActionResult Edit([Bind(Include = "ID,Questions")] Pet pet)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pet).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pet));
 }