public async Task <IHttpActionResult> PutPerson(int id, Person person) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != person.Id) { return(BadRequest()); } db.Entry(person).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public Url Update(Url url) { _db.Urls.Attach(url); _db.Entry(url).State = EntityState.Modified; _db.SaveChanges(); return(url); }
public async Task <IHttpActionResult> PutInstructor(int id, Instructor instructor) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != instructor.InstructorID) { return(BadRequest()); } db.Entry(instructor).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InstructorExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult EditUrl(UrlModel url) { db.Entry(url).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult UrlTable(ListOfUrls listOfUrls) { urlContext.Entry(listOfUrls).State = EntityState.Modified; urlContext.SaveChanges(); return(View(urlContext.ListOfUrls.ToList())); }