Esempio n. 1
0
        public ActionResult New(int id)
        {
            var proposal = _context.Proposals.SingleOrDefault(m => m.Id == id);

            if (proposal == null)
            {
                return(HttpNotFound());
            }
            ProgrammeRationale pr = null;

            if (proposal.ProgrammeRationaleId != null)
            {
                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)
            {
                return(HttpNotFound());
            }
            var viewModel = new DemandFormViewModel
            {
                Proposal = proposal,
            };

            return(View("Form", viewModel));
        }
Esempio n. 2
0
        public ActionResult New(int id)
        {
            var proposal = _context.Proposals.SingleOrDefault(m => m.Id == id);

            if (proposal == null)
            {
                return(HttpNotFound());
            }
            ProgrammeRationale pr = null;

            if (proposal.ProgrammeRationaleId != null)
            {
                pr = _context.ProgrammeRationales.SingleOrDefault(m => m.Id == proposal.ProgrammeRationaleId);
            }
            if (pr.TentativePsId != null)
            {
                return(HttpNotFound());
            }

            var allUnits = _context.Database.SqlQuery <Ref_Unit>("Select * from Ref_Unit where DepartmentId In(Select distinct DepartmentId From dbo.Department_General WHERE GeneralId = " + proposal.GeneralId + ")").ToList();
            //var departmentIds = _context.Database.SqlQuery<int>("Select distinct DepartmentId From dbo.Department_General WHERE GeneralId = " + proposal.GeneralId).ToList();
            var viewModel = new TentativePsFormViewModel
            {
                Proposal    = proposal,
                AllUnits    = allUnits,
                TentativePs = new TentativeP(),
            };

            return(View("Form", viewModel));
        }
        public ActionResult New(int id)
        {
            var proposal = _context.Proposals.SingleOrDefault(m => m.Id == id);

            if (proposal == null)
            {
                return(HttpNotFound());
            }
            if (!proposal.IsEditable(User.Identity.GetUserId()))
            {
                return(HttpNotFound());
            }
            ProgrammeRationale pr = null;

            if (proposal.ProgrammeRationaleId != null)
            {
                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)
            {
                return(HttpNotFound());
            }
            proposal.IsInEdit    = true;
            proposal.UserEditing = User.Identity.GetUserId();
            _context.SaveChanges();
            var viewModel = new ProgrammeStudyFormViewModel
            {
                Proposal       = proposal,
                ProgrammeStudy = new ProgrammeOfStudy()
            };

            return(View("Form", viewModel));
        }
Esempio n. 4
0
        public ActionResult Save(RationaleFormViewModel vm)
        {
            var rationale = vm.Rationale;
            var proposal  = _context.Proposals.SingleOrDefault(m => m.Id == vm.Proposal.Id);

            if (proposal == null)
            {
                return(HttpNotFound());
            }
            if (!proposal.IsEditable(User.Identity.GetUserId()))
            {
                return(HttpNotFound());
            }
            if (proposal.Submitted)
            {
                return(Content("Proposal already submitted"));
            }
            if (!ModelState.IsValid)
            {
                return(View("Form", rationale));
            }

            if (rationale.Id == 0)
            {
                Thread t = new Thread();
                _context.Threads.Add(t);
                rationale.Thread = t;
                _context.Rationales.Add(rationale);
                ProgrammeRationale pr = new ProgrammeRationale();
                pr.RationaleId = rationale.Id;
                _context.ProgrammeRationales.Add(pr);
                proposal.ProgrammeRationaleId = pr.Id;
                proposal.ProgrammeRationale   = pr;
            }
            else
            {
                var rationaleInDb = _context.Rationales.SingleOrDefault(m => m.Id == rationale.Id);
                rationaleInDb.Justification = rationale.Justification;
                rationaleInDb.Fit           = rationale.Fit;
                rationaleInDb.Differences   = rationale.Differences;
            }

            _context.SaveChanges();
            var jump = Request["jump"];

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

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

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

            case "2":
            {
                //Save and exit
                return(RedirectToAction("CloseEdit", "Proposal", 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"));
            }
            }
        }