public ActionResult Create(Employee employee) { if (ModelState.IsValid) { db.Employees.AddObject(employee); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.EmployeeId = new SelectList(db.Leaves, "EmployeeId", "EmployeeId", employee.EmployeeId); ViewBag.ManagerId = new SelectList(db.Employees, "EmployeeId", "Name", employee.ManagerId); return View(employee); }
public ActionResult Login(Employee u) { // this action is for handle post (login) if (ModelState.IsValid) // this is check validity { using (AMSEntities dc = new AMSEntities()) { var v = dc.Employees.Where(a => a.Username.Equals(u.Username) && a.Password.Equals(u.Password)).FirstOrDefault(); if (v != null) { Session["LogedUserId"] = v.EmployeeId; Session["LogedUserType"] = v.Designation.ToString(); Session["LogedUsername"] = v.Username.ToString(); Session["LogedUserFullName"] = v.Name.ToString(); return RedirectToAction("AfterLogin"); } } } return View(u); }
/// <summary> /// Create a new Employee object. /// </summary> /// <param name="employeeId">Initial value of the EmployeeId property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="username">Initial value of the Username property.</param> /// <param name="password">Initial value of the Password property.</param> public static Employee CreateEmployee(global::System.Int32 employeeId, global::System.String name, global::System.String username, global::System.String password) { Employee employee = new Employee(); employee.EmployeeId = employeeId; employee.Name = name; employee.Username = username; employee.Password = password; return employee; }
/// <summary> /// Deprecated Method for adding a new object to the Employees EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToEmployees(Employee employee) { base.AddObject("Employees", employee); }
public ActionResult Edit(Employee employee) { if (ModelState.IsValid) { db.Employees.Attach(employee); db.ObjectStateManager.ChangeObjectState(employee, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.EmployeeId = new SelectList(db.Leaves, "EmployeeId", "EmployeeId", employee.EmployeeId); ViewBag.ManagerId = new SelectList(db.Employees, "EmployeeId", "Name", employee.ManagerId); return View(employee); }