static void GetAllDepartments() { IDepartmentFacade departmentFacade = (IDepartmentFacade)FacadeFactory.Instance.Create(FacadeType.DepartmentManagerFacade); OperationResult <IList <IDepartmentDTO> > departmentDTOList = departmentFacade.GetAllDepartments(); if (departmentDTOList.IsValid()) { foreach (var department in departmentDTOList.Data) { System.Console.WriteLine(department.DepartmentId + "\t" + department.DepartmentName); } } }
static void GetDepartment() { System.Console.WriteLine("Department Id : "); int departmentId; int.TryParse(System.Console.ReadLine(), out departmentId); IDepartmentFacade departmentFacade = (IDepartmentFacade)FacadeFactory.Instance.Create(FacadeType.DepartmentManagerFacade); OperationResult <IDepartmentDTO> departmentDTO = departmentFacade.GetADepartment(departmentId); if (departmentDTO.IsValid()) { System.Console.WriteLine(departmentDTO.Data.DepartmentId + "\t" + departmentDTO.Data.DepartmentName); } }
public ActionResult SearchEmployee(SearchEmployee searchEmployee) { ActionResult retVal = null; if (ModelState.IsValid) { ISearchEmployeeDTO searchEmployeeDTO = (ISearchEmployeeDTO)DTOFactory.Instance.Create(DTOType.SearchEmployeeDTO); DTOConverter.FillDTOFromViewModel(searchEmployeeDTO, searchEmployee); IUserFacade userFacade = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserManagerFacade); OperationResult <IList <IEmployeeDTO> > result = userFacade.SearchEmployeeByRawQuery(searchEmployeeDTO, (User.IsInRole("NonAdmin"))?true:false); if (result.IsValid()) { IList <Employee> employeeList = new List <Employee>(); Employee employee = null; IDepartmentFacade departmentFacade = (IDepartmentFacade)FacadeFactory.Instance.Create(FacadeType.DepartmentManagerFacade); //OperationResult<IList<IEmployeeDTO>> result = userFacade.SearchEmployeeByRawQuery(searchEmployeeDTO, true); foreach (var employeeDTO in result.Data) { employee = new Employee(); DTOConverter.FillViewModelFromDTO(employee, employeeDTO); OperationResult <IDepartmentDTO> department = departmentFacade.GetADepartment(employeeDTO.DepartmentId); if (department.IsValid()) { employee.Department = new Department(); DTOConverter.FillViewModelFromDTO(employee.Department, department.Data); } employeeList.Add(employee); } retVal = PartialView("~/Views/User/_SearchEmployeeList.cshtml", employeeList); } else if (result.HasFailed()) { } else { retVal = View("~/Views/Shared/Error.cshtml"); } } return(retVal); }
private IEnumerable <SelectListItem> FillDepartmentsFromDepartmentList(int selectedDepartmentId) { IDepartmentFacade departmentFacade = (IDepartmentFacade)FacadeFactory.Instance.Create(FacadeType.DepartmentManagerFacade); OperationResult <IList <IDepartmentDTO> > departmentList = departmentFacade.GetAllDepartments(); IEnumerable <SelectListItem> departments = null; if (departmentList.IsValid()) { departments = new List <SelectListItem>(); departments = departmentList.Data.Select(dept => new SelectListItem { Text = dept.DepartmentName, Value = dept.DepartmentId.ToString(), Selected = (dept.DepartmentId == selectedDepartmentId) ? true : false }); } return(departments); }
public DepartmentController() { this.depFac = new DepartmentFacade(); }