public ActionResult PasswordChange(string NewPassword, string Password, string ConfirmPassword) { try { if (NewPassword.Length < 6 || Password.Length < 6 || ConfirmPassword.Length < 6) { ModelState.AddModelError(string.Empty, "パスワードの長さが最低6桁をに入力ください。"); TempData["ViewData"] = ViewData; return(RedirectToAction("PasswordChange")); } if (!Password.Equals(ConfirmPassword)) { ModelState.AddModelError(string.Empty, "パスワードと確認パスワードが同じではないです。"); TempData["ViewData"] = ViewData; return(RedirectToAction("PasswordChange")); } PasswordService passwordService = new PasswordService(); EmployeeLoginOutput employee = (EmployeeLoginOutput)Session["employee"]; string employeeId = employee.Id; passwordService.ChangePassword(employeeId, Password, NewPassword); TempData["SuccessMessage"] = "パスワード変更ができました"; TempData["ViewData"] = ViewData; } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); TempData["ViewData"] = ViewData; return(RedirectToAction("PasswordChange")); } return(RedirectToAction("PasswordChange")); }
public ActionResult GetEmployeeSalaryMonth(string SalaryMonth) { try { if (null == SalaryMonth || "".Equals(SalaryMonth)) { ModelState.AddModelError(string.Empty, "年月を入力ください"); TempData["ViewData"] = ViewData; return(RedirectToAction("Index")); } TempData["SalaryMonth"] = SalaryMonth; EmployeeLoginOutput sessionEmployee = (EmployeeLoginOutput)Session["employee"]; string employeeId = sessionEmployee.Id; SalaryService salaryService = new SalaryService(); EmployeeSearchSalaryOutput employeeSearchSalaryOutput = salaryService.getSalaryDetailEmployee(employeeId, SalaryMonth); if (employeeSearchSalaryOutput == null) { ModelState.AddModelError(string.Empty, "当月、給料明細書まだアップロードされません"); TempData["ViewData"] = ViewData; return(RedirectToAction("Index")); } TempData["SalaryDetailFilePath"] = employeeSearchSalaryOutput.SalaryDetailFilePath; } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); TempData["ViewData"] = ViewData; return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
public EmployeeLoginOutput Login(EmployeeLoginInput employeeLoginInput) { EmployeeLoginOutput employeeLoginOutput = new EmployeeLoginOutput(); try { string passWord = HelperCommon.hashPassword(employeeLoginInput.PassWord); using (sys_employeeEntities db = new sys_employeeEntities()) { var query = (from e in db.employee join c in db.customer on e.customerId equals c.customerId into ecGroup from ec in ecGroup.DefaultIfEmpty() where e.userName.Equals(employeeLoginInput.UserName) && e.passWord.Equals(passWord) select new { e.employeeId, e.name, e.kataName, e.mailAddress, e.telephoneNumber, e.entryDate, customerName = ec.name, e.address, e.accountBankInfo, e.personalNumber, e.dateOfBirth, e.authorityId, e.avatarFilePath }).FirstOrDefault(); if (query == null) { throw new Exception("ユーザネームまたパスワードが違います"); } employeeLoginOutput.Id = query.employeeId; employeeLoginOutput.Name = query.name; employeeLoginOutput.KataName = query.kataName; employeeLoginOutput.Email = query.mailAddress; employeeLoginOutput.TelephoneNumber = query.telephoneNumber; employeeLoginOutput.EntryDate = query.entryDate; employeeLoginOutput.CustomerName = query.customerName; employeeLoginOutput.Address = query.address; employeeLoginOutput.AccountBankInfo = query.accountBankInfo; employeeLoginOutput.PersonalNunber = query.personalNumber; employeeLoginOutput.DateOfBirth = query.dateOfBirth.GetValueOrDefault().ToString("yyyy/MM/dd"); employeeLoginOutput.AuthorityId = query.authorityId; employeeLoginOutput.AvatarFilePath = query.avatarFilePath; } } catch (Exception e) { throw e; } return(employeeLoginOutput); }
public ActionResult DecideRoute() { EmployeeLoginOutput employeeLoginOutput = (EmployeeLoginOutput)Session["employee"]; string authorityId = employeeLoginOutput.AuthorityId; if (authorityId.Equals(ConstantCommon.ADMIN)) { return(RedirectToAction("Index", "Employee")); } else { return(RedirectToAction("Index", "Info")); } }
public void InitAppController(ActionExecutingContext filterContext) { if (filterContext.HttpContext.Session["employee"] == null) { filterContext.Result = RedirectToAction("Index", "Login"); } else { EmployeeLoginOutput employee = (EmployeeLoginOutput)filterContext.HttpContext.Session["employee"]; if (!employee.AuthorityId.Equals(ConstantCommon.ADMIN)) { filterContext.Result = RedirectToAction("Index", "Login"); } } }
public ActionResult Login(EmployeeLoginInput employeeLoginInput) { try { if (ModelState.IsValid) { LoginService loginService = new LoginService(); EmployeeLoginOutput employeeLoginOutput = loginService.Login(employeeLoginInput); Session["employee"] = employeeLoginOutput; return(RedirectToAction("ViewEmployeeInfo")); } } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); TempData["ViewData"] = ViewData; TempData["employee"] = employeeLoginInput; return(RedirectToAction("Index")); } TempData["ViewData"] = ViewData; TempData["employee"] = employeeLoginInput; return(RedirectToAction("Index")); }