public ActionResult Create(ProgramModel pm)
 {
     if (Session["LoggedUserName"] == null || Session["IsAdmin"] == "0")
         return RedirectToAction("Login","Bh");
     if (ModelState.IsValid && programFlag == 1)
     {
         BugBusinessLayer.OperationsBusinessLayerControl obc = new OperationsBusinessLayerControl();
         obc.AddProgram(pm);
         return RedirectToAction("Index");
     }
     return View(pm);
 }
        public ActionResult Areas(int id)
        {
            if (Session["LoggedUserName"] == null)
                return RedirectToAction("Login", "Bh");

            BugBusinessLayer.OperationsBusinessLayerControl obc = new OperationsBusinessLayerControl();
            areas = obc.GetAreasByProgramId(id);
            string programName = obc.GetProgramNameByPrgmId(id);
            ViewBag.ForProgram = programName;
            tempProgramId = id;
            tempProgram = programName;
            return View(areas);
        }
        public ActionResult CreateArea(AreaModel am)
        {
            if (Session["LoggedUserName"] == null || Session["IsAdmin"] == "0")
                return RedirectToAction("Login", "Bh");

            if (ModelState.IsValid)
            {
                BugBusinessLayer.OperationsBusinessLayerControl obc = new OperationsBusinessLayerControl();
                am.ProgramId = tempProgramId;
                am.ProgramName = tempProgram;
                obc.AddArea(am);
                return RedirectToAction("Areas", new { id=tempProgramId});
            }
            return null;
        }
        public ActionResult EditArea(AreaModel am)
        {
            if (Session["LoggedUserName"] == null || Session["IsAdmin"] == "0")
                return RedirectToAction("Login", "Bh");

            if (ModelState.IsValid)
            {
                BugBusinessLayer.OperationsBusinessLayerControl obc = new OperationsBusinessLayerControl();
                //FillEmptyFields(bm);
                am.ProgramId = tempProgramId;
                obc.UpdateArea(am);
                return RedirectToAction("Areas", new { id=tempProgramId});
            }
            else
                return View(am);
        }
        public ActionResult Edit(ProgramModel bm)
        {
            if (Session["LoggedUserName"] == null || Session["IsAdmin"] == "0")
                return RedirectToAction("Login", "Bh");

            if (ModelState.IsValid)
            {
                BugBusinessLayer.OperationsBusinessLayerControl obc = new OperationsBusinessLayerControl();
                //FillEmptyFields(bm);
                obc.UpdateProgram(bm);
                Response.Write("<script>alert('Data Updated Successfully')</script>");
                return RedirectToAction("Index");
            }
            else
                return View(bm);
        }
        public ActionResult DeleteArea(int id)
        {
            if (Session["LoggedUserName"] == null || Session["IsAdmin"] == "0")
                return RedirectToAction("Login", "Bh");

            AreaModel am = areas.Single(x => x.Id == id);
            BugBusinessLayer.OperationsBusinessLayerControl obc = new OperationsBusinessLayerControl();
            obc.DeleteArea(am);
            return RedirectToAction("Areas", new { id = tempProgramId });
        }
        public ActionResult Delete(int id)
        {
            if (Session["LoggedUserName"] == null || Session["IsAdmin"] == "0")
                return RedirectToAction("Login", "Bh");

            ProgramModel bm = programs.Single(x => x.Id == id);
            BugBusinessLayer.OperationsBusinessLayerControl obc = new OperationsBusinessLayerControl();
            obc.DeleteProgram(bm);
            return RedirectToAction("Index");
        }