Ejemplo n.º 1
0
        public ActionResult Save(StatementServFormViewModel vm)
        {
            var proposal = vm.Proposal;

            proposal = _context.Proposals.SingleOrDefault(m => m.Id == proposal.Id);
            if (proposal == null || !proposal.Submitted)
            {
                return(HttpNotFound());
            }
            var statement = vm.Statement;

            if (statement.Selection == true)
            {
                //if a is chosen, set reservations to a default string
                statement.Reservations = "_";
            }
            if (!ModelState.IsValid)
            {
                return(View("Form", statement));
            }

            var statementInDb = _context.StatementServs.SingleOrDefault(m => m.Id == statement.Id);

            statementInDb.Reservations = statement.Reservations;
            statementInDb.SignedBy     = "DeanXYZ";
            statementInDb.SignedDate   = DateTime.Now;
            statementInDb.Selection    = statement.Selection;

            _context.SaveChanges();
            return(RedirectToAction("Approval", "Proposal", new { id = proposal.Id }));
        }
Ejemplo n.º 2
0
        public ActionResult Details(int id)
        {
            var stmServ = _context.StatementServs.SingleOrDefault(m => m.Id == id);

            if (stmServ == null)
            {
                return(HttpNotFound());
            }

            //get proposal
            var ers      = _context.Approval_Statement.SingleOrDefault(m => m.StatementId == stmServ.Id);
            var proposal = _context.Proposals.SingleOrDefault(m => m.ApprovalId == ers.ApprovalId);

            if (proposal == null || !proposal.Submitted)
            {
                return(HttpNotFound());
            }
            if (stmServ.SignedBy == null)
            {
                //return Form
                //stmServ.Reservations = null;
                var viewModel = new StatementServFormViewModel
                {
                    Proposal  = proposal,
                    Statement = stmServ
                };
                return(View("Form", viewModel));
            }
            else
            {
                if (stmServ.Selection == true)
                {
                    //return accept view
                    var viewModel = new StatementServFormViewModel
                    {
                        Proposal  = proposal,
                        Statement = stmServ
                    };
                    return(View("Accepted", viewModel));
                }
                else
                {
                    //return reject view
                    var viewModel = new StatementServFormViewModel
                    {
                        Proposal  = proposal,
                        Statement = stmServ
                    };
                    return(View("Rejected", viewModel));
                }
            }
        }
Ejemplo n.º 3
0
        public ActionResult Details(int id)
        {
            var stmServ = _context.StatementServs.SingleOrDefault(m => m.Id == id);

            if (stmServ == null)
            {
                return(HttpNotFound());
            }

            //get proposal
            var ers      = _context.Approval_Statement.SingleOrDefault(m => m.StatementId == stmServ.Id);
            var proposal = _context.Proposals.SingleOrDefault(m => m.ApprovalId == ers.ApprovalId);

            if (proposal == null || !proposal.Submitted)
            {
                return(HttpNotFound());
            }
            if (stmServ.SignedBy == null)
            {
                if (User.IsInRole(RoleName.HoD))
                {
                    var dept = _context.Ref_Department.SingleOrDefault(m => m.Id == stmServ.DepartmentId);
                    if (dept.HoD == User.Identity.GetUserId())
                    {
                        //return Form if user is hod of servicing dept
                        //stmServ.Reservations = null;
                        var viewModel = new StatementServFormViewModel
                        {
                            Proposal  = proposal,
                            Statement = stmServ
                        };
                        return(View("Form", viewModel));
                    }
                    else
                    {
                        return(View("NoDecision", proposal.Id));
                    }
                }
                else
                {
                    return(View("NoDecision", proposal.Id));
                }
            }
            else
            {
                ApplicationDbContext adb = new ApplicationDbContext();
                var signedBy             = adb.Users.SingleOrDefault(m => m.Id == stmServ.SignedBy);
                if (stmServ.Selection == true)
                {
                    //return accept view
                    var viewModel = new StatementServFormViewModel
                    {
                        Proposal  = proposal,
                        Statement = stmServ,
                        SignedBy  = signedBy.Email
                    };
                    return(View("Accepted", viewModel));
                }
                else
                {
                    //return reject view
                    var viewModel = new StatementServFormViewModel
                    {
                        Proposal  = proposal,
                        Statement = stmServ,
                        SignedBy  = signedBy.Email
                    };
                    return(View("Rejected", viewModel));
                }
            }
        }