예제 #1
0
        public ActionResult DummySave(TentativePsIndexViewModel vm)
        {
            var proposal = _context.Proposals.SingleOrDefault(m => m.Id == vm.Proposal.Id);

            if (proposal == null)
            {
                return(HttpNotFound());
            }
            if (proposal.Submitted)
            {
                return(Content("Proposal already submitted"));
            }
            var jump = Request["jump"];

            switch (jump)
            {
            case "-1":
            {
                // Previous pressed -> return form
                return(RedirectToAction("Edit", "ProgrammeStudy", new { id = proposal.Id }));
            }

            case "1":
            {
                // Next pressed -> return next page
                return(RedirectToAction("Jump", "ExternalReview", new { id = proposal.Id }));
            }

            case "A":
            {
                // A pressed -> go to Section A
                return(RedirectToAction("Edit", "General", new { id = proposal.Id }));
            }

            case "B":
            {
                // B pressed -> go to Section B
                return(RedirectToAction("Jump", "ProgrammeRationale", new { id = proposal.Id }));
            }

            case "C":
            {
                // C pressed -> go to Section C
                return(RedirectToAction("Jump", "ExternalReview", new { id = proposal.Id }));
            }

            case "D":
            {
                // D pressed -> go to Section D
                return(RedirectToAction("Jump", "IncomeExpenditure", new { id = proposal.Id }));
            }

            default:
            {
                return(RedirectToAction("Index", "Proposal"));
            }
            }
        }
예제 #2
0
        // GET: TentativePs
        public ActionResult Index(int id)
        {
            var proposal = _context.Proposals.SingleOrDefault(m => m.Id == id);

            if (proposal == null || proposal.Submitted)
            {
                return(HttpNotFound());
            }
            if (!proposal.IsEditable(User.Identity.GetUserId()))
            {
                return(HttpNotFound());
            }
            var pr = _context.ProgrammeRationales.SingleOrDefault(m => m.Id == proposal.ProgrammeRationaleId);

            if (pr == null)
            {
                //if section B has not been visited yet
                return(RedirectToAction("Jump", "ProgrammeRationale", new { id = proposal.Id }));
            }
            if (pr.DemandId == null)
            {
                //if section demand has not been visited yet
                return(RedirectToAction("Jump", "Demand", new { id = proposal.Id }));
            }
            if (pr.PsId == null)
            {
                //if section ps has not been visited yet
                return(RedirectToAction("Jump", "ProgrammeStudy", new { id = proposal.Id }));
            }
            var tp    = _context.TentativePs.SingleOrDefault(m => m.Id == pr.TentativePsId);
            var years = _context.Years.Where(m => m.TentativePsId == tp.Id).OrderBy(m => m.YearNo).ToList();

            proposal.IsInEdit    = true;
            proposal.UserEditing = User.Identity.GetUserId();
            _context.SaveChanges();
            var viewModel = new TentativePsIndexViewModel
            {
                Proposal = proposal,
                Years    = years
            };

            return(View(viewModel));
        }