public IActionResult Edit(int id) { if (!_permissionService.Authorize(EmployeePermissionProvider.ManageDepartments)) { return(AccessDeniedView()); } var department = _employeeService.GetDepartmentById(id); var model = department.ToModel(); return(View($"{Route}{nameof(Edit)}.cshtml", model)); }
public IActionResult Info(string id) { var model = new EmployeeInfoModel { IsAdmin = _permissionService.Authorize(EmployeePermissionProvider.ManageEmployees) }; var e = GetEmployeeByIdOrEmailPrefix(id); if (e == null) { return(RedirectToAction(nameof(Index), new { area = "" })); } if (model.IsAdmin) { DisplayEditLink(Url.Action(nameof(Edit), ControllerName, new { id = e.Id.ToString(), area = "Admin" })); } model.Employee = e.ToModel(); model.Employee.PhotoUrl = (e.PictureId > 0) ? _pictureService.GetPictureUrl(e.PictureId, 200) : null; var department = _employeeService.GetDepartmentById(e.DepartmentId); if (department != null) { model.Employee.DepartmentPublished = department.Published; model.Employee.DepartmentName = department.Name; } return(View($"{Route}{nameof(Info)}.cshtml", model)); }