Beispiel #1
0
 private void AddEnclosingJobs(ViewJobsViewModel model)
 {
     foreach (JobViewModel job in model.Jobs)
     {
         job.AddEnclosingJobs(this.enclosingJobService.GetEnclosingJobsByJobId(Int32.Parse(job.Id)));
     }
 }
Beispiel #2
0
        private void SetRole(ApplicationUser currentuser, ViewJobsViewModel model)
        {
            if (!currentuser.Roles.Any())
            {
                return;
            }

            var currentUserRoleNames =
                currentuser.Roles
                .Select(identityUserRole => identityUserRole.Role.Name)
                .ToList();

            model.CanShowActionMenu = true;

            if (currentUserRoleNames.Contains(Role.ExportSearchResults))
            {
                model.CanExportResults = true;
            }

            if (currentUserRoleNames.Contains(Role.AuthoriseJobs))
            {
                model.CanAuthoriseJobs = true;
            }

            if (currentUserRoleNames.Contains(Role.StatusChange))
            {
                model.CanChangeStatus = true;
            }
        }
Beispiel #3
0
        public ActionResult SearchJobs(String searchCriteria)
        {
            this.TempData["SearchField"] = searchCriteria;
            this.SetEnvironmentSession();
            var   currentuser = this.userService.GetApplicationUser(HttpContext.User.Identity.Name);
            Int32 page        = 1;

            var model = new ViewJobsViewModel();

            model.SearchValue = searchCriteria;

            this.SetRole(currentuser, model);

            PagedResult <JobEntity> jobs;

            var environment = (String)this.HttpContext.Session[SessionObject.Environment];

            if (searchCriteria.Length < 1)
            {
                jobs = this.jobService.GetJobs(page, PageSize, currentuser.Id, environment);
            }
            else
            {
                jobs = this.jobService.GetJobs(page, PageSize, searchCriteria, currentuser.Id, environment);
            }

            model.AddJobs(jobs);

            //Adds enclosing jobs per each job
            AddEnclosingJobs(model);

            return(this.PartialView("_JobsList", model));
        }
Beispiel #4
0
        public ActionResult ViewJobs(Int32 page = 1, Boolean isAjaxCall = false)
        {
            this.SetEnvironmentSession();
            var currentuser = this.userService.GetApplicationUser(HttpContext.User.Identity.Name);

            var model = new ViewJobsViewModel();

            this.SetRole(currentuser, model);

            PagedResult <JobEntity> jobs;

            var environment = (String)this.HttpContext.Session[SessionObject.Environment];

            jobs = this.jobService.GetJobs(page, PageSize, currentuser.Id, environment);

            model.AddJobs(jobs);

            //Adds enclosing jobs per each job
            AddEnclosingJobs(model);

            return(this.View(model));
        }
Beispiel #5
0
        public ActionResult Authorise(Int32[] jobIds)
        {
            var jobIdList   = jobIds.ToList();
            var currentuser = this.userService.GetApplicationUser(HttpContext.User.Identity.Name);

            this.authoriseJobEngine.AuthoriseJob(jobIdList, JobStatusTypes.Complete, currentuser.Id, String.Empty);


            var environment = (String)this.HttpContext.Session[SessionObject.Environment];

            var jobs  = this.jobService.GetJobs(1, PageSize, currentuser.Id, environment);
            var model = new ViewJobsViewModel();

            this.SetRole(currentuser, model);

            model.AddJobs(jobs);

            //Adds enclosing jobs per each job
            AddEnclosingJobs(model);

            return(this.PartialView("_JobsList", model));
        }