Пример #1
0
        public ActionResult index()
        {
            CommitteeLibRepository committee_rep = new CommitteeLibRepository();

            ViewData["all_committees"] = committee_rep.getAll();
            return(View());
        }
Пример #2
0
        public ActionResult edit(FormCollection collection)
        {
            //Generate new Committee object for form if error
            CommitteeLibRepository committee_rep = new CommitteeLibRepository();
            CommitteeLib           committee     = new CommitteeLib();

            //GET Committee
            try
            {
                committee             = committee_rep.getCommittee(Int32.Parse(collection["committee_id"]));
                TempData["committee"] = committee;
            }
            catch (Exception exception)
            {
                //IF THERE IS A MESS UP, RETURN ERROR TO FRONT
                TempData["flash"] = "Unable to retrieve committee: " + exception.Message;
                return(RedirectToAction("edit", new { controller = "Committees", id = collection["committee_id"] }));
            }


            //UPDATE Committee
            try
            {
                return(committeeFormProcess(committee, committee_rep, collection));
            }
            catch (Exception exception)
            {
                //IF THERE IS A MESS UP, RETURN ERROR TO FRONT
                TempData["flash"] = "Unable to update committee: " + exception.Message;
                return(RedirectToAction("edit", new { controller = "Committees", id = collection["committee_id"] }));
            }
        }
Пример #3
0
        public ActionResult delete(int id)
        {
            CommitteeLibRepository committee_rep = new CommitteeLibRepository();
            CommitteeLib           committee     = new CommitteeLib();

            //GET Committee
            try
            {
                committee = committee_rep.getCommittee(id);
            }
            catch (Exception exception)
            {
                //IF THERE IS A MESS UP, RETURN ERROR TO FRONT
                TempData["flash"] = "Unable to retrieve committee: " + exception.Message;
                return(RedirectToAction("Index"));
            }


            //DELETE Committee
            try
            {
                committee_rep.delete(committee);
                TempData["flash"] = "Deleted committee.";
                return(RedirectToAction("Index"));
            }
            catch (Exception exception)
            {
                TempData["flash"] = "Unable to delete committee: " + exception.Message;
                return(RedirectToAction("Index"));
            }
        }
Пример #4
0
        public ActionResult edit(int id)
        {
            CommitteeLibRepository committee_rep = new CommitteeLibRepository();

            ViewData["committee_id"] = id.ToString();
            ViewData["committee"]    = committee_rep.getCommittee(id);
            ViewData["edit"]         = true;

            return(View());
        }
Пример #5
0
        public ActionResult create()
        {
            //Generate new Committee object
            CommitteeLibRepository committee_rep = new CommitteeLibRepository();
            CommitteeLib           committee     = new CommitteeLib();

            ViewData["edit"]      = false;
            ViewData["committee"] = committee;
            return(View());
        }
Пример #6
0
        //PROCESS EDIT AND CREATE FORMS
        private ActionResult committeeFormProcess(CommitteeLib committee, CommitteeLibRepository committee_rep, FormCollection collection)
        {
            try
            {
                committee.Description = collection["committee_description"];
                committee_rep.save(committee);

                TempData["flash"] = "Committee: " + committee.Description;
                return(RedirectToAction("Index"));
            }
            catch (Exception exception)
            {
                throw new Exception("A data entry problem has occurred.");
            }
        }
Пример #7
0
        public ActionResult create(FormCollection collection)
        {
            //Generate new Committee object
            CommitteeLibRepository committee_rep = new CommitteeLibRepository();
            CommitteeLib           committee     = new CommitteeLib();

            ViewData["edit"]      = false;
            ViewData["committee"] = committee;

            try
            {
                return(committeeFormProcess(committee, committee_rep, collection));
            }
            catch (Exception exception)
            {
                //IF THERE IS A MESS UP, RETURN ERROR TO FRONT
                TempData["flash"] = "Unable to create committee: " + exception.Message;
                return(RedirectToAction("create"));
            }
        }