public ActionResult Create(Employee employee) { try { Employee empTable = new Employee(); empTable.FIO = employee.FIO; empTable.OrganizationId = employee.OrganizationId; db.Employee.Add(empTable); db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult DeleteStudent(int idSt, int idGr, Employee employee) { Employee emp = (from e in db.Employee where e.Id == idSt select e).FirstOrDefault<Employee>(); StudyGroup sg = emp.StudyGroup.Where( g => g.Id == idGr).FirstOrDefault<StudyGroup>(); emp.StudyGroup.Remove(sg); db.SaveChanges(); return RedirectToAction("StudyGroup"); }
public ActionResult DeleteEmployee(int id,Employee employee) { Employee emp = db.Employee.First(i => i.Id == id); db.Employee.Remove(emp); db.SaveChanges(); return RedirectToAction("Index"); }