Exemplo n.º 1
0
        public async Task <IViewComponentResult> InvokeAsync(StartViewErrandInputData inputData)
        {
            //id = employeeId
            Employee currentEmployee = await repository.GetEmployee(inputData.employeeId);

            ViewBag.Worker = currentEmployee.RoleTitle;
            IQueryable <StartViewErrand> errands;

            ViewBag.FilteredOrSearched = true;
            if (inputData.caseNumberSearched && inputData.caseNumber != null)             //a caseNumber was entered for search
            {
                errands = await repository.GetStartViewEmployeeErrandsCaseNumberSearched(inputData.employeeId, inputData.caseNumber);
            }
            else if (inputData.filterUsed)             //the filter function was used to filter errands
            {
                errands = await GetFilteredErrands(currentEmployee.RoleTitle, inputData);
            }
            else
            {
                ViewBag.FilteredOrSearched = false;                 //No search or filtering was made
                errands = await repository.GetStartViewEmployeeErrands(inputData.employeeId);
            }


            return(View(errands));
        }
Exemplo n.º 2
0
        public ViewResult StartCoordinator()
        {
            ViewBag.Worker = "Coordinator";

            var username = contextAcc.HttpContext.User.Identity.Name;

            StartViewErrandInputData startViewErrandInputData = new StartViewErrandInputData
            {
                employeeId = username
            };

            ViewBag.startViewErrandInputData = startViewErrandInputData;


            return(View(repository));
        }
Exemplo n.º 3
0
        public async Task <ViewResult> StartManager()
        {
            Employee managerEmployee = await GetEmployeeData();

            ViewBag.departmentId = managerEmployee.DepartmentId;

            StartViewErrandInputData startViewErrandInputData = new StartViewErrandInputData
            {
                employeeId = managerEmployee.EmployeeId
            };

            ViewBag.startViewErrandInputData = startViewErrandInputData;


            return(View(repository));
        }
Exemplo n.º 4
0
        public async Task <ViewResult> StartInvestigator()
        {
            Employee currentEmployee = await GetEmployeeData();

            ViewBag.employeeID = currentEmployee.EmployeeId;
            ViewBag.Statuses   = repository.ErrandStatuses;


            StartViewErrandInputData startViewErrandInputData = new StartViewErrandInputData
            {
                employeeId = currentEmployee.EmployeeId
            };

            ViewBag.startViewErrandInputData = startViewErrandInputData;

            return(View());
        }
Exemplo n.º 5
0
        public ViewResult StartCoordinator(string statusId, string departmentId, string casenumber, bool isCasenumber)
        {
            ViewBag.Worker = "Coordinator";

            var username = contextAcc.HttpContext.User.Identity.Name;

            StartViewErrandInputData startViewErrandInputData = new StartViewErrandInputData
            {
                filterUsed         = !isCasenumber,
                caseNumberSearched = isCasenumber,
                employeeId         = username,
                departmentId       = !isCasenumber ? departmentId : null,
                caseNumber         = isCasenumber ? casenumber : null,
                statusId           = !isCasenumber ? statusId : null
            };

            ViewBag.startViewErrandInputData = startViewErrandInputData;


            return(View(repository));
        }
Exemplo n.º 6
0
        public async Task <ViewResult> StartManager(string statusId, string investigatorId, string casenumber, bool isCasenumber)
        {
            Employee managerEmployee = await GetEmployeeData();

            ViewBag.departmentId = managerEmployee.DepartmentId;

            StartViewErrandInputData startViewErrandInputData = new StartViewErrandInputData
            {
                filterUsed         = !isCasenumber,
                caseNumberSearched = isCasenumber,
                employeeId         = managerEmployee.EmployeeId,
                caseNumber         = isCasenumber ? casenumber : null,
                statusId           = !isCasenumber ? statusId : null,
                investigatorId     = !isCasenumber ? investigatorId : null
            };

            ViewBag.startViewErrandInputData = startViewErrandInputData;


            return(View(repository));
        }
Exemplo n.º 7
0
        public async Task <ViewResult> StartInvestigator(ErrandStatus errandStatus, string casenumber, bool isCasenumber)
        {
            Employee currentEmployee = await GetEmployeeData();

            ViewBag.employeeID = currentEmployee.EmployeeId;
            ViewBag.Statuses   = repository.ErrandStatuses;

            StartViewErrandInputData startViewErrandInputData = new StartViewErrandInputData
            {
                filterUsed         = !isCasenumber,
                caseNumberSearched = isCasenumber,
                employeeId         = currentEmployee.EmployeeId,
                departmentId       = null,
                caseNumber         = isCasenumber ? casenumber : null,
                statusId           = !isCasenumber ? errandStatus.StatusId : null,
                investigatorId     = null
            };

            ViewBag.startViewErrandInputData = startViewErrandInputData;

            return(View());
        }
Exemplo n.º 8
0
        private async Task <IQueryable <StartViewErrand> > GetFilteredErrands(string role, StartViewErrandInputData inputData)
        {
            IQueryable <StartViewErrand> filteredListOfErrands;
            string statusID = !inputData.statusId.Equals("Välj alla") ? inputData.statusId : null;             //null matches all
            string departmentID;
            string investigatorID;

            if (inputData.departmentId != null)
            {
                departmentID = !inputData.departmentId.Equals("Välj alla") ? inputData.departmentId : null;                 //null matches all
            }
            else
            {
                departmentID = null;
            }
            if (inputData.investigatorId != null)
            {
                investigatorID = !inputData.investigatorId.Equals("Välj alla") ? inputData.investigatorId : null;                 //null matches all
            }
            else
            {
                investigatorID = null;
            }


            if (role.Equals("Investigator"))
            {
                filteredListOfErrands = await repository.GetStartViewInvestigatorErrandsFiltered(inputData.employeeId, statusID);
            }
            else if (role.Equals("Manager"))
            {
                filteredListOfErrands = await repository.GetStartViewManagerErrandsFiltered((await repository.GetEmployee(inputData.employeeId)).DepartmentId, statusID, investigatorID);
            }
            else if (role.Equals("Coordinator"))
            {
                filteredListOfErrands = await repository.GetStartViewCoordinatorErrandsFiltered(statusID, departmentID);
            }
            else
            {
                throw new Exception("No matching role");
            }
            return(filteredListOfErrands);
        }