示例#1
0
        public async Task <IActionResult> OnGetAsync()
        {
            var username = HttpContext.Session.GetString("_username");
            var usertype = HttpContext.Session.GetString("_usertype");
            var access   = new Access(username, "Supervisor");

            if (access.IsLogin())
            {
                if (access.IsAuthorize(usertype))
                {
                    Requisitions = await _context.Requisition
                                   .Where(i => i.DateDeleted == null)
                                   .Where(i => i.RequisitionStatus == "New")
                                   .Where(s => s.Receiver == username)
                                   .Include(p => p.Project)
                                   .OrderBy(p => p.RequisitionStatus)
                                   .ToListAsync();

                    RequisitionCount = Requisitions.Count();

                    return(Page());
                }
                else
                {
                    ErrorMessage = "Access Denied";
                    return(RedirectToPage($"/{usertype}/Index"));
                }
            }
            else
            {
                ErrorMessage = "Login Required";
                return(RedirectToPage("/Account/Login"));
            }
        }
示例#2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            var username = HttpContext.Session.GetString("_username");
            var usertype = HttpContext.Session.GetString("_usertype");
            var access   = new Access(username, "Student");

            if (access.IsLogin())
            {
                if (access.IsAuthorize(usertype))
                {
                    if (id == null)
                    {
                        return(NotFound());
                    }

                    Project = await _context.Project.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(m => m.ProjectId == id);

                    if (Project == null)
                    {
                        return(NotFound());
                    }

                    ProjectSpecialization = await _context.ProjectSpecialization.FirstOrDefaultAsync(ps => ps.ProjectId == Project.ProjectId);

                    Specialization = await _context.Specialization.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(s => s.SpecializationId == ProjectSpecialization.SpecializationId);

                    Supervisor = await _context.Supervisor.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(s => s.AssignedId == Project.SupervisorId);

                    CoSupervisor = await _context.Supervisor.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(s => s.AssignedId == Project.CoSupervisorId);

                    Requisitions = await _context.Requisition.Where(s => s.DateDeleted == null).Where(i => i.Sender == username).ToListAsync();

                    if (Requisitions.Count() == 0)
                    {
                        CanRequisition = true;
                    }
                    else
                    {
                        CanRequisition = true;

                        foreach (var Requisition in Requisitions)
                        {
                            if (Requisition.RequisitionStatus != "Rejected")
                            {
                                CanRequisition = false;
                                break;
                            }
                        }
                    }

                    var proposal = await _context.Proposal.Where(p => p.DateDeleted == null).Where(p => p.ProposalStatus == "New").FirstOrDefaultAsync(p => p.Sender == username);

                    if (proposal != null)
                    {
                        CanRequisition = false;
                    }

                    var student = await _context.Student.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(s => s.AssignedId == username);

                    if (student.ProjectId != null)
                    {
                        CanRequisition = false;
                    }

                    return(Page());
                }
                else
                {
                    ErrorMessage = "Access Denied";
                    return(RedirectToPage($"/{usertype}/Index"));
                }
            }
            else
            {
                ErrorMessage = "Login Required";
                return(RedirectToPage("/Account/Login"));
            }
        }