예제 #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))
                {
                    Proposals = await _context.Proposal
                                .Where(p => p.DateDeleted == null)
                                .Where(s => s.Receiver == username)
                                .Where(p => p.ProposalStatus != "Completed" && p.ProposalStatus != "Failed" && p.ProposalStatus != "Rejected")
                                .Include(p => p.Project)
                                .OrderBy(p => p.ProposalStatus)
                                .ToListAsync();

                    ProposalCount = Proposals.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()
        {
            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))
                {
                    Proposals = await _context.Proposal
                                .Where(s => s.DateDeleted == null)
                                .Where(s => s.Sender == username)
                                .Include(p => p.Project)
                                .OrderBy(p => p.ProposalStatus)
                                .ToListAsync();

                    ProposalCount = Proposals.Count();

                    ActiveProposals   = new List <Proposal>();
                    RejectedProposals = new List <Proposal>();

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

                    foreach (var proposal in Proposals)
                    {
                        if (proposal.ProposalStatus != "Rejected" && proposal.ProposalStatus != "Failed")
                        {
                            ActiveProposalCount += 1;
                            ActiveProposals.Add(proposal);
                        }
                        else
                        {
                            RejectedProposals.Add(proposal);
                        }
                    }

                    Requisition = await _context.Requisition.Where(r => r.DateDeleted == null).Where(r => r.RequisitionStatus != "Rejected").FirstOrDefaultAsync(r => r.Sender == username);

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