예제 #1
0
 public ActionResult Delete(int id, BL.Models.ProgDec progDec)
 {
     try
     {
         // TODO: Add delete logic here
         progDec.Advisors = ProgDecManager.LoadAdvisors(id);
         progDec.Advisors.ForEach(a => ProgDecAdvisorManager.Delete(id, a.Id));
         ProgDecManager.Delete(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
예제 #2
0
        public ActionResult Edit(int id, ProgDecProgramsStudents pps)
        {
            try
            {
                // Deal with the Advisors
                IEnumerable <int> oldadvisorids = new List <int>();
                if (Session["advisorids"] != null)
                {
                    oldadvisorids = (IEnumerable <int>)Session["advisorids"];
                }

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

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

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

                deletes.ToList().ForEach(d => ProgDecAdvisorManager.Delete(id, d));
                adds.ToList().ForEach(a => ProgDecAdvisorManager.Add(id, a));


                // TODO: Add update logic here
                ProgDecManager.Update(pps.ProgDec);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }