getPhase() public method

public getPhase ( int id ) : Phase
id int
return Phase
Example #1
0
        public ActionResult delete(int id)
        {
            PhaseRepository phase_rep = new PhaseRepository();
            Phase phase = new Phase();

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

            //DELETE PHASE
            try
            {
               phase_rep.delete(phase);
               TempData["flash"] = "Deleted phase.";
               return RedirectToAction("Index");
            }
            catch (Exception exception)
            {
                TempData["flash"] = "Unable to delete phase: " + exception.Message;
                return RedirectToAction("Index");
            }
        }
Example #2
0
        public ActionResult edit(int id)
        {
            PhaseRepository phase_rep = new PhaseRepository();
            ViewData["phase_id"] = id.ToString();
            ViewData["phase"] = phase_rep.getPhase(id);
            ViewData["edit"] = true;

            return View();
        }
Example #3
0
        public ActionResult edit(FormCollection collection)
        {
            //Generate new phase object for form if error
            PhaseRepository phase_rep = new PhaseRepository();
            Phase phase = new Phase();

            //GET PHASE
            try
            {
                phase = phase_rep.getPhase(Int32.Parse(collection["phase_id"]));
                TempData["phase"] = phase;
            }
            catch (Exception exception)
            {
                //IF THERE IS A MESS UP, RETURN ERROR TO FRONT
                TempData["flash"] = "Unable to retrieve phase: " + exception.Message;
                return RedirectToAction("edit", new {controller = "Phases", id = collection["phase_id"]});
            }

            //UPDATE PHASE
            try
            {
                return phaseFormProcess(phase, phase_rep, collection);
            }
            catch (Exception exception)
            {

              //IF THERE IS A MESS UP, RETURN ERROR TO FRONT
              TempData["flash"] = "Unable to update phase: " + exception.Message;
              return RedirectToAction("edit", new { controller = "Phases", id = collection["phase_id"] });
            }
        }