public ActionResult Create(ProgDecProgramsStudents pps)
        {
            try
            {
                pps.ProgDec.Insert();
                int id = pps.ProgDec.Id;
                pps.AdvisorIds.ToList().ForEach(a => ProgDecAdvisor.Add(id, a));

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View(pps));
            }
        }
        public ActionResult Edit(int id, ProgDecProgramsStudents pps)
        {
            try
            {
                // Deal with the advisors
                IEnumerable <int> oldadvisorsid = new List <int>();
                if (Session["advisorids"] != null)
                {
                    oldadvisorsid = (IEnumerable <int>)Session["advisorids"];
                }

                IEnumerable <int> newadvisorids = new List <int>();
                if (pps.AdvisorIds != null)
                {
                    newadvisorids = pps.AdvisorIds;
                }

                // Identify the deletes
                IEnumerable <int> deletes = oldadvisorsid.Except(newadvisorids);

                // Identify the adds
                IEnumerable <int> adds = newadvisorids.Except(oldadvisorsid);

                // Do the deletes
                deletes.ToList().ForEach(d => ProgDecAdvisor.Delete(id, d));

                // Do the adds
                adds.ToList().ForEach(a => ProgDecAdvisor.Add(id, a));


                pps.ProgDec.Update();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View(pps));
            }
        }