public async Task <IHttpActionResult> PutContact(int id, Contact contact) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != contact.ContactId) { return(BadRequest()); } db.Entry(contact).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Post(Notebook notebook) { if (ModelState.IsValid) { db.Entry(notebook).State = EntityState.Modified; db.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "Id,Name,Number")] Contact contact) { if (ModelState.IsValid) { db.Entry(contact).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(contact)); }
public ActionResult Edit(Notebook notebook) { if (ModelState.IsValid) { db.Entry(notebook).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(notebook)); }
public async Task SaveEditedToDB(Note note) { using (this.context = new NotebookContext()) { var editedNote = await context.Notes.FindAsync(note.Id); if (editedNote != null) { editedNote.Name = note.Name; editedNote.File = note.File; context.Entry(editedNote).State = EntityState.Modified; await context.SaveChangesAsync(); } } }
public void Add(TEntity item) { _context.Entry <TEntity>(item).State = System.Data.Entity.EntityState.Added; }
public ActionResult Edit(Contact contact) { db.Entry(contact).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }