public ActionResult Create(Leave leave) { if (ModelState.IsValid) { db.Leaves.AddObject(leave); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "Name", leave.EmployeeId); return View(leave); }
/// <summary> /// Deprecated Method for adding a new object to the Leaves EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToLeaves(Leave leave) { base.AddObject("Leaves", leave); }
/// <summary> /// Create a new Leave object. /// </summary> /// <param name="employeeId">Initial value of the EmployeeId property.</param> /// <param name="casualLeaves">Initial value of the CasualLeaves property.</param> /// <param name="sickLeaves">Initial value of the SickLeaves property.</param> /// <param name="maternalLeaves">Initial value of the MaternalLeaves property.</param> /// <param name="optionalHolidays">Initial value of the OptionalHolidays property.</param> public static Leave CreateLeave(global::System.Int32 employeeId, global::System.Int32 casualLeaves, global::System.Int32 sickLeaves, global::System.Int32 maternalLeaves, global::System.Int32 optionalHolidays) { Leave leave = new Leave(); leave.EmployeeId = employeeId; leave.CasualLeaves = casualLeaves; leave.SickLeaves = sickLeaves; leave.MaternalLeaves = maternalLeaves; leave.OptionalHolidays = optionalHolidays; return leave; }
public ActionResult Edit(Leave leave) { if (ModelState.IsValid) { db.Leaves.Attach(leave); db.ObjectStateManager.ChangeObjectState(leave, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "Name", leave.EmployeeId); return View(leave); }