public ActionResult Create(NominationViewModel ViewModel)
        {
            Nomination nomination = ViewModel.nomination;
            if (ModelState.IsValid)
            {
                db.Nominations.Add(nomination);

                foreach (Application application in ViewModel.applications)
                {
                    var original = db.Applications.Find(application.id);
                    if (application.shortlisted != original.shortlisted)
                    {
                        original.modified = DateTime.Now;
                        original.modified_by = User.Identity.Name;
                        original.shortlisted = application.shortlisted;
                        db.Entry(original).State = EntityState.Modified;
                    }
                }

                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.status_id = new SelectList(db.NominationStatus, "id", "name", nomination.status_id);
            ViewBag.program_id = new SelectList(db.Programs, "id", "name", nomination.program_id);
            return View(ViewModel);
        }
        public ActionResult Create(int id = 0)
        {
            NominationViewModel ViewModel = new NominationViewModel();
            ViewModel.nomination = new Nomination();
            ViewModel.applications = new List<Application>();

            Program program = db.Programs.Where(p => p.id == id && p.require_nomination).FirstOrDefault();
            if (program == null)
            {
                return HttpNotFound("Program not found");
            }
            List<Application> applications = db.Applications.Where(a => a.program_id == program.id).ToList();
            if (applications == null)
            {
                return HttpNotFound("Application not found");
            }

            //fix me: user profile relationship
            List<SelectListItem> nominators = new List<SelectListItem>();
            nominators.Add(new SelectListItem{
                Value = "7",
                Text = "nominator"
            });

            int openedStatusId = db.NominationStatus.Where(x => x.name == "Opened").FirstOrDefault().id;
            ViewBag.statusList = new SelectList(db.NominationStatus, "id", "name");
            ViewBag.nominatorList = new SelectList(nominators, "Value", "Text");
            ViewModel.nomination.program_id = program.id;
            ViewModel.nomination.Program = program;
            ViewModel.applications = applications;
            ViewModel.nomination.nominator_id = 7;
            ViewModel.nomination.status_id = openedStatusId;
            ViewModel.nomination.start_date = DateTime.Now.Date;
            ViewModel.nomination.end_date = DateTime.Now.Date;
            return View(ViewModel);
        }
        public ActionResult Nominate(int id = 0)
        {
            NominationViewModel ViewModel = new NominationViewModel();
            Nomination nomination = db.Nominations.Find(id);
            if (nomination == null)
            {
                return HttpNotFound("Nomination not found");
            }
            List<Application> applications = nomination.Program.Applications.Where(a => a.shortlisted).ToList();

            ViewModel.nomination = nomination;
            ViewModel.applications = applications;
            return View(ViewModel);
        }
        public ActionResult Nominate(NominationViewModel ViewModel)
        {
            int nominatedStatusId = db.NominationStatus.Where(s => s.name == "Nominated").FirstOrDefault().id;
            Nomination nomination = ViewModel.nomination;
            nomination.status_id = nominatedStatusId;
            db.Entry(nomination).State = EntityState.Modified;

            foreach (Application application in ViewModel.applications)
            {
                var original = db.Applications.Find(application.id);
                if (application.nominated != original.nominated)
                {
                    original.modified = DateTime.Now;
                    original.modified_by = User.Identity.Name;
                    original.nominated = application.nominated;
                    db.Entry(original).State = EntityState.Modified;
                }
            }

            db.SaveChanges();
            return RedirectToAction("Nominate", new { id = ViewModel.nomination.id });
        }
        public ActionResult Edit(NominationViewModel ViewModel)
        {
            Nomination nomination = ViewModel.nomination;
            if (ModelState.IsValid)
            {
                db.Entry(nomination).State = EntityState.Modified;
                db.SaveChanges();

                foreach (Application application in ViewModel.applications)
                {
                    var original = db.Applications.Find(application.id);
                    if (application.shortlisted != original.shortlisted)
                    {
                        original.modified = DateTime.Now;
                        original.modified_by = User.Identity.Name;
                        original.shortlisted = application.shortlisted;
                        db.Entry(original).State = EntityState.Modified;
                    }
                }

                db.SaveChanges();
                return RedirectToAction("Index");
            }

            //fix me: user profile relationship
            List<SelectListItem> nominators = new List<SelectListItem>();
            nominators.Add(new SelectListItem
            {
                Value = "7",
                Text = "nominator"
            });
            ViewBag.statusList = new SelectList(db.NominationStatus, "id", "name");
            ViewBag.nominatorList = new SelectList(nominators, "Value", "Text");
            return View(ViewModel);
        }