Ejemplo n.º 1
0
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                progDec           = new ProgDec();
                progDec.ProgramId = programs[ddlPrograms.SelectedIndex].Id;
                progDec.StudentId = students[ddlStudents.SelectedIndex].Id;

                int results = ProgDecManager.Insert(progDec);
                Response.Write("Inserted " + results + " rows.");

                progDecs.Add(progDec);

                Rebind();

                if (results > 0)
                {
                    ddlChangeDate.SelectedValue = progDec.Id.ToString();
                }
                ddlChangeDate_SelectedIndexChanged(sender, e);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Ejemplo n.º 2
0
        public void UpdateTest()
        {
            ProgDec progDec = ProgDecManager.LoadById(6);

            progDec.ProgramId = 13;
            Assert.IsTrue(ProgDecManager.Update(progDec) > 0);
        }
 public ActionResult AddToCart(int id)
 {
     GetShoppingCart();
     BL.Models.ProgDec progDec = ProgDecManager.LoadById(id);
     ShoppingCartManager.Add(cart, progDec);
     Session["cart"] = cart;
     return(RedirectToAction("Index", "ProgDec"));
 }
Ejemplo n.º 4
0
        public void InsertTest()
        {
            ProgDec progDec = new ProgDec {
                ProgramId = 12, StudentId = 4
            };

            Assert.AreNotEqual(0, ProgDecManager.Insert(progDec));
        }
Ejemplo n.º 5
0
 public ActionResult Create(ProgDecProgramsStudents pps)
 {
     try
     {
         ProgDecManager.Insert(pps.ProgDec);
         pps.AdvisorIds.ToList().ForEach(a => ProgDecAdvisorManager.Add(pps.ProgDec.Id, a));
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 6
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());
     }
 }
Ejemplo n.º 7
0
        // GET: ProgDec/Edit/5
        public ActionResult Edit(int id)
        {
            ProgDecProgramsStudents pps = new ProgDecProgramsStudents();

            pps.ProgDec  = ProgDecManager.LoadById(id);
            pps.Programs = ProgramManager.Load();
            pps.Students = StudentManager.Load();

            pps.Advisors = AdvisorManager.Load(); //load them all

            pps.ProgDec.Advisors = ProgDecManager.LoadAdvisors(id);
            pps.AdvisorIds       = pps.ProgDec.Advisors.Select(a => a.Id); //Select the ids

            //Put Existing Advisors into Session
            Session["advisorids"] = pps.AdvisorIds;

            return(View(pps));
        }
Ejemplo n.º 8
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                progDec = progDecs[ddlChangeDate.SelectedIndex];

                int results = ProgDecManager.Update(progDec);
                Response.Write("Updated " + results + " rows.");

                progDecs.Remove(progDec);

                Rebind();
                ddlChangeDate_SelectedIndexChanged(sender, e);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                students = StudentManager.Load();
                progDecs = ProgDecManager.Load();
                programs = ProgramManager.Load();
                Rebind();

                Session["students"] = students;
                Session["progdecs"] = progDecs;
                Session["programs"] = programs;

                ddlChangeDate_SelectedIndexChanged(sender, e);
            }
            else
            {
                students = (List <Student>)Session["students"];
                progDecs = (List <ProgDec>)Session["progdecs"];
                programs = (List <Program>)Session["programs"];
            }
        }
Ejemplo n.º 10
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());
            }
        }
Ejemplo n.º 11
0
 // POST: api/ProgDec
 public void Post([FromBody] ProgramDec.BL.Models.ProgDec progDec)
 {
     ProgDecManager.Insert(progDec);
 }
Ejemplo n.º 12
0
 // GET: api/ProgDec/5
 public ProgramDec.BL.Models.ProgDec Get(int id)
 {
     ProgramDec.BL.Models.ProgDec progDec = ProgDecManager.LoadById(id);
     return(progDec);
 }
Ejemplo n.º 13
0
        // GET: api/ProgDec
        public IEnumerable <ProgramDec.BL.Models.ProgDec> Get()
        {
            List <ProgramDec.BL.Models.ProgDec> progDecs = ProgDecManager.Load();

            return(progDecs);
        }
Ejemplo n.º 14
0
 public void DeleteTest()
 {
     Assert.IsTrue(ProgDecManager.Delete(6) > 0);
 }
Ejemplo n.º 15
0
        // GET: ProgDec/Delete/5
        public ActionResult Delete(int id)
        {
            BL.Models.ProgDec progdec = ProgDecManager.LoadById(id);

            return(View(progdec));
        }
Ejemplo n.º 16
0
        // GET: ProgDec
        public ActionResult Index()
        {
            var progdecs = ProgDecManager.Load();

            return(View(progdecs));
        }
Ejemplo n.º 17
0
 // PUT: api/ProgDec/5
 public void Put(int id, [FromBody] ProgramDec.BL.Models.ProgDec progDec)
 {
     ProgDecManager.Update(progDec);
 }
Ejemplo n.º 18
0
        // GET: ProgDec/Details/5
        public ActionResult Details(int id)
        {
            var progdec = ProgDecManager.LoadById(id);

            return(View(progdec));
        }
Ejemplo n.º 19
0
        public ActionResult Load(int id)
        {
            var progdecs = ProgDecManager.Load(id);

            return(View("Index", progdecs));
        }
Ejemplo n.º 20
0
 // DELETE: api/ProgDec/5
 public void Delete(int id)
 {
     ProgDecManager.Delete(id);
 }
Ejemplo n.º 21
0
        public void LoadTest()
        {
            List <ProgDec> progDecs = ProgDecManager.Load();

            Assert.AreEqual(5, progDecs.Count);
        }