public ActionResult GetAllUsers(int?page)
        {
            OperationResult <IList <IUserDto> > resultAllUsers = _userFacade.GetAllUsers();
            List <UserModel> result = new List <UserModel>();

            if (resultAllUsers.IsValid())
            {
                foreach (var item in resultAllUsers.Data)
                {
                    UserModel userData = new UserModel();
                    DTOConverter.FillViewModelFromDTO(userData, item);
                    result.Add(userData);
                }
            }
            else
            {
                IList <EmployeePortalValidationFailure> resultFail = resultAllUsers.ValidationResult.Errors;
                foreach (var item in resultFail)
                {
                }
            }
            int pageSize   = 5;
            int pageNumber = (page ?? 1);

            return(View(result.OrderBy(item => item.Name).ToPagedList(pageNumber, pageSize)));
        }
Exemple #2
0
        public ActionResult EditEmployee(string employeeEmail)
        {
            ActionResult retVal               = null;
            IUserFacade  userFacade           = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserManagerFacade);
            OperationResult <IUserDTO> result = userFacade.GetUserByEmailId(employeeEmail);

            if (result.IsValid())
            {
                User user = new User();
                DTOConverter.FillViewModelFromDTO(user, result.Data);

                user.Employee = new Employee();
                DTOConverter.FillViewModelFromDTO(user.Employee, result.Data.EmployeeDTO);

                user.Employee.Departments = FillDepartmentsFromDepartmentList(user.Employee.DepartmentId);
                ViewBag.Create            = false;
                retVal = PartialView("~/Views/User/_CreateEmployee.cshtml", user);
            }
            else if (result.HasFailed())
            {
                retVal = RedirectToAction("SearchEmployee", "User");
            }
            else
            {
                retVal = View("~/Views/Shared/Error.cshtml");
            }
            return(retVal);
        }
        public ActionResult SearchUser(string searchName, string searchContact, string searchEmail)
        {
            List <UserModel> result = new List <UserModel>();

            if (searchContact == "" && searchName == "" && searchEmail == "")
            {
            }
            else
            {
                searchName    = (searchName == "") ? null : searchName;
                searchContact = (searchContact == "") ? null : searchContact;
                searchEmail   = (searchEmail == "") ? null : searchEmail;
            }
            OperationResult <IList <IUserDto> > resultAllUsers = _userFacade.SearchUser(searchName, searchContact, searchEmail);

            if (resultAllUsers.IsValid())
            {
                foreach (var item in resultAllUsers.Data)
                {
                    UserModel userData = new UserModel();
                    DTOConverter.FillViewModelFromDTO(userData, item);
                    result.Add(userData);
                }
            }
            int pageSize   = 5;
            int pageNumber = 1;

            return(View("GetAllUsers", result.ToPagedList(pageNumber, pageSize)));
        }
 private void FillSurveysFromDto(List <SurveyViewModel> surveys, IEnumerable <ISurveyDTO> surveysResult)
 {
     foreach (var surveyDTO in surveysResult)
     {
         var surveyViewModel = new SurveyViewModel();
         DTOConverter.FillViewModelFromDTO(surveyViewModel, surveyDTO);
         surveys.Add(surveyViewModel);
     }
 }
Exemple #5
0
        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);
        }
        public ActionResult GetFilteredUsers(string userName, string userContact, string userEmail)
        {
            List <UserRegistrationModel> filteredList = new List <UserRegistrationModel>();
            IUserFacade userFacade = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserFacade);
            OperationResult <IList <IUserDTO> > result = userFacade.GetFilteredUsers(userName, userContact, userEmail);

            if (result.IsValid())
            {
                foreach (var user in result.Data)
                {
                    UserRegistrationModel model = new UserRegistrationModel();
                    DTOConverter.FillViewModelFromDTO(model, user);
                    filteredList.Add(model);
                }
            }
            return(View("UserList", filteredList));
        }
Exemple #7
0
        public ViewResult SearchUser(string nameSearch, string contactSearch, string emailSearch)
        {
            if (nameSearch.Length == 0 && contactSearch.Length == 0 && emailSearch.Length == 0)
            {
                //return PartialView("GetAllUser");
                return(this.GetAllUser());
            }
            else
            {
                if (nameSearch.Length == 0)
                {
                    nameSearch = null;
                }

                if (contactSearch.Length == 0)
                {
                    contactSearch = null;
                }

                if (emailSearch.Length == 0)
                {
                    emailSearch = null;
                }

                IUserFacade userFacade = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserFacade);
                OperationResult <IList <IUserDTO> > resultAllCustomers = userFacade.SearchCustomer(nameSearch, emailSearch, contactSearch);
                List <UserModel> result = new List <UserModel>();
                if (resultAllCustomers.IsValid())
                {
                    foreach (var item in resultAllCustomers.Data)
                    {
                        UserModel userData = new UserModel();
                        DTOConverter.FillViewModelFromDTO(userData, item);
                        result.Add(userData);
                    }
                }
                else
                {
                    IList <EmployeePortalValidationFailure> resultFail = resultAllCustomers.ValidationResult.Errors;
                    foreach (var item in resultFail)
                    {
                    }
                }
                return(View("GetAllUser", result));
            }
        }
Exemple #8
0
        public ActionResult SearchUser(string nameSearch, string contactSearch, string emailSearch)
        {
            if (nameSearch.Length == 0 && contactSearch.Length == 0 && emailSearch.Length == 0)
            {
                //return this.GetAllUsers();
            }
            else
            {
                if (nameSearch != null && nameSearch.Length == 0)
                {
                    nameSearch = null;
                }

                if (contactSearch != null && contactSearch.Length == 0)
                {
                    contactSearch = null;
                }

                if (emailSearch != null && emailSearch.Length == 0)
                {
                    emailSearch = null;
                }
            }
            IUserFacade userFacade = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserFacade);
            OperationResult <IList <IUserDTO> > resultAllCustomers = userFacade.SearchUser(nameSearch, contactSearch, emailSearch);
            List <UserViewModels> result = new List <UserViewModels>();

            if (resultAllCustomers.IsValid())
            {
                foreach (var item in resultAllCustomers.Data)
                {
                    UserViewModels userData = new UserViewModels();
                    DTOConverter.FillViewModelFromDTO(userData, item);
                    result.Add(userData);
                }
            }
            //return View("GetAllUsers", result);
            int pageSize   = 5;
            int pageNumber = 1;

            return(View("GetAllUsers", result.ToPagedList(pageNumber, pageSize)));
        }
        public ActionResult UserList(int?page)
        {
            List <UserRegistrationModel> list          = new List <UserRegistrationModel>();
            IUserFacade userFacade                     = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserFacade);
            OperationResult <IList <IUserDTO> > result = userFacade.GetAllUsers();

            if (result.IsValid())
            {
                foreach (var user in result.Data)
                {
                    UserRegistrationModel model = new UserRegistrationModel();
                    DTOConverter.FillViewModelFromDTO(model, user);
                    list.Add(model);
                }
            }
            int pageNumber = (page ?? 1);
            int pageSize   = 5;

            return(View(list.OrderBy(item => item.Customer_Name).ToPagedList(pageNumber, pageSize)));
        }
Exemple #10
0
        public ActionResult GetAllUsers(int?page)
        {
            IUserFacade noticeFacade = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserFacade);
            OperationResult <IList <IUserDTO> > resultActive = noticeFacade.GetAllUser();
            IList <UserViewModels> allUser = new List <UserViewModels>();

            if (resultActive.IsValid())
            {
                foreach (IUserDTO item in resultActive.Data)
                {
                    UserViewModels user = new UserViewModels();
                    DTOConverter.FillViewModelFromDTO(user, item);
                    allUser.Add(user);
                }
            }

            int pageSize  = 5;
            int pageIndex = page ?? 1;

            return(View("GetAllUsers", allUser.ToPagedList(pageIndex, pageSize)));
            //return View("GetAllUsers", allUser);
        }
        public IHttpActionResult GetSurveyById(int id)
        {
            try
            {
                var surveyBdc       = (ISurveyBDC)BDCFactory.Instance.Create(BDCType.Survey);
                var surveyViewModel = new SurveyViewModel();

                var result = surveyBdc.GetSurveyById(id);
                if (result != null && result.IsValid())
                {
                    DTOConverter.FillViewModelFromDTO(surveyViewModel, result.Data);
                    return(Ok(surveyViewModel));
                }
                else
                {
                    return(Error(HttpStatusCode.NotFound, "survey", "No Survey with specified id is found"));
                }
            }
            catch (Exception ex)
            {
                //todo log the message
                return(Error(HttpStatusCode.InternalServerError, "survey", "An internal error has occurred."));
            }
        }
Exemple #12
0
        public ViewResult GetAllUser()//int? page
        {
            IUserFacade usersFacade = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserFacade);
            OperationResult <IList <IUserDTO> > result = usersFacade.GetAllUser();
            List <UserModel> list = new List <UserModel>();

            //List<UserModel> list1 = new List<UserModel>();
            if (result.IsValid())
            {
                foreach (var item in result.Data)
                {
                    UserModel user = new UserModel();
                    DTOConverter.FillViewModelFromDTO(user, item);
                    list.Add(user);
                }
            }
            else
            {
            }
            //int pagesize = 3;
            //int pagenumber = (page ?? 1);
            //return View(list.topagedlist(pagenumber, pagesize));
            return(View(list));
        }