public virtual void Delete(TEntity entityToDelete) { if (context.Entry(entityToDelete).State == EntityState.Detached) { dbSet.Attach(entityToDelete); } dbSet.Remove(entityToDelete); }
public ActionResult Edit([Bind(Include = "Id,FileNumber,FilePath,Comment,CreatedDate,IsActive")] FileRefrence fileRefrence) { if (ModelState.IsValid) { db.Entry(fileRefrence).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(fileRefrence)); }
public ActionResult Create(Employee employee) { if (ModelState.IsValid) { db.Employees.Add(employee); db.SaveChanges(); employee.ReferenceNumber = "EMP" + employee.EmployeeId; db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employee)); }
public ActionResult Edit([Bind(Include = "TableId,SenarioID,ColumnDefination,ColumnOrder,IsDeleted")] AttTableDefination attTableDefination) { if (ModelState.IsValid) { db.Entry(attTableDefination).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SenarioID = new SelectList(db.Senarios, "Id", "SenarioName", attTableDefination.SenarioID); return(View(attTableDefination)); }
public ActionResult Edit([Bind(Include = "Id,Name,Batch_Id")] Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Batch_Id = new SelectList(db.Batches, "Id", "Name", student.Batch_Id); return(View(student)); }
public ActionResult Edit([Bind(Include = "MachId,MachineName,SenarioID,IsDeleted")] AttMachine attMachine) { if (ModelState.IsValid) { db.Entry(attMachine).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SenarioID = new SelectList(db.Senarios, "Id", "SenarioName", attMachine.SenarioID); return(View(attMachine)); }
public ActionResult Edit([Bind(Include = "Id,Date,TimeIN,TimeOut,TimeFunction,FunctionID,EmployeeID,MachineTableID,Comment")] AttendanceLog attendanceLog) { if (ModelState.IsValid) { db.Entry(attendanceLog).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MachineTableID = new SelectList(db.AttMachineTableRefrences, "Id", "Id", attendanceLog.MachineTableID); ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeId", "ReferenceNumber", attendanceLog.EmployeeID); return(View(attendanceLog)); }
public ActionResult Edit([Bind(Include = "Id,MachineID,TableID")] AttMachineTableRefrence attMachineTableRefrence) { if (ModelState.IsValid) { db.Entry(attMachineTableRefrence).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MachineID = new SelectList(db.AttMachines, "MachId", "MachineName", attMachineTableRefrence.MachineID); ViewBag.TableID = new SelectList(db.AttTableDefinations, "TableId", "ColumnDefination", attMachineTableRefrence.TableID); return(View(attMachineTableRefrence)); }
public void Delete <E>(E e) where E : class { try { DbSet <E> dbSet = context.Set <E>(); if (context.Entry(e).State == EntityState.Detached) { dbSet.Attach(e); } dbSet.Remove(e); } catch (Exception) { throw; } }