// GET: Employees/Delete/5 public ActionResult Delete(string id) { // idが無い場合、不正なリクエストとして処理 if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } // DBからidで検索して該当するユーザーを取得 ApplicationUser applicationUser = db.Users.Find(id); // ユーザーが取得できなければ、NotFoundエラーページへ if (applicationUser == null) { return(HttpNotFound()); } // ビューモデルにデータを詰め替える EmployeesDeleteViewModel employee = new EmployeesDeleteViewModel { Id = applicationUser.Id, Email = applicationUser.Email, EmployeeName = applicationUser.EmployeeName, CreatedAt = applicationUser.CreatedAt, UpdatedAt = applicationUser.UpdatedAt }; return(View(employee)); }
// GET: Employees/Delete/5 public ActionResult Delete(string id) { // idが無い場合、不正なリクエストとして処理 if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } // DBからidで検索して該当するユーザーを取得 ApplicationUser applicationUser = db.Users.Find(id); // ユーザーが取得できなければ、NotFoundエラーページへ if (applicationUser == null) { return(HttpNotFound()); } // ビューモデルにデータを詰め替える EmployeesDeleteViewModel employee = new EmployeesDeleteViewModel { Id = applicationUser.Id, Email = applicationUser.Email, EmployeeName = applicationUser.EmployeeName, CreatedAt = applicationUser.CreatedAt, UpdatedAt = applicationUser.UpdatedAt }; if (UserManager.IsInRole(applicationUser.Id, "Chief")) { employee.Role = "係長"; } else if (UserManager.IsInRole(applicationUser.Id, "Manager")) { employee.Role = "部長"; } else if (UserManager.IsInRole(applicationUser.Id, "GeneralManager")) { employee.Role = "本部長"; } else if (UserManager.IsInRole(applicationUser.Id, "ManagingDirector")) { employee.Role = "専務"; } else if (UserManager.IsInRole(applicationUser.Id, "President")) { employee.Role = "社長"; } else { employee.Role = "一般"; } return(View(employee)); }