public ActionResult Update(UpdateEmployeeModel updateemployeemodel, FormCollection form, string submit) { switch (submit) { case "Sil": { var emp = db.T_Employee.Find(updateemployeemodel._Employee.employee_id); if (emp == null) { return(HttpNotFound()); } db.T_Employee.Remove(emp); break; } default: { var hash = new HashIt(); if (updateemployeemodel._Employee.employee_id == 0) { updateemployeemodel._Employee.department_id = int.Parse(form["DropDownListDepartmants"].ToString()); updateemployeemodel._Employee.employee_authority_id = int.Parse(form["DropDownListAuthorities"].ToString()); updateemployeemodel._Employee.employee_password = hash.Hashit(updateemployeemodel._Employee.employee_password); } else { if (updateemployeemodel._Employee.employee_password == null) { updateemployeemodel._Employee.employee_password = db.T_Employee.Find(updateemployeemodel._Employee.employee_id).employee_password; } else { updateemployeemodel._Employee.employee_password = hash.Hashit(updateemployeemodel._Employee.employee_password); } db.T_Employee.Find(updateemployeemodel._Employee.employee_id).department_id = form["DropDownListDepartmants"].ToString() == "" ? db.T_Employee.Find(updateemployeemodel._Employee.employee_id).department_id : int.Parse(form["DropDownListDepartmants"]); db.T_Employee.Find(updateemployeemodel._Employee.employee_id).employee_authority_id = form["DropDownListAuthorities"].ToString() == "" ? db.T_Employee.Find(updateemployeemodel._Employee.employee_id).employee_authority_id : int.Parse(form["DropDownListAuthorities"]); } db.T_Employee.AddOrUpdate(updateemployeemodel._Employee); break; } } db.SaveChanges(); return(RedirectToAction("Index", "Employees")); }
public ActionResult Index(T_Employee employee) { var hash = new HashIt(); var result = hash.Hashit(employee.employee_password); user = db.T_Employee.FirstOrDefault(x => x.employee_username.Equals(employee.employee_username) && x.employee_password.Equals(result)); if (user == null) { ViewBag.Mesaj = "Geçersiz kullanıcı adı veya parola"; return(View()); } else { FormsAuthentication.SetAuthCookie(user.employee_username, false); return(RedirectToAction("Index", "Calendar")); } }