/// <summary> /// Generic Delete method for the entities /// </summary> /// <param name="entityToDelete"></param> public virtual void Delete(TEntity entityToDelete) { if (Context.Entry(entityToDelete).State == EntityState.Detached) { DbSet.Attach(entityToDelete); } DbSet.Remove(entityToDelete); }
public IHttpActionResult PutLibrary(int id, Library library) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != library.ID) { return(BadRequest()); } db.Entry(library).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LibraryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutEmployee(int id, Employee employee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employee.EmployeeId) { return(BadRequest()); } db.Entry(employee).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit(userinfo userinfo) { if (ModelState.IsValid) { db.Entry(userinfo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userinfo)); }