예제 #1
0
 public ActionResult Add(DropDown model, string dropDownClass)
 {
     DropDown m = getDropDownType(dropDownClass);
     if (m == null)
     {
         return RedirectToAction("Index", "Home");
     }
     m.Code = model.Code;
     m.FullName = model.FullName;
     if (m.Code == null || m.Code == "" || m.FullName == null || m.FullName == "")
     {
         return View(m);
     }
     m.Enabled = true;
     if (ModelState.IsValid)
     {
         DbSet dropDowns;
         dropDowns = getDropDowns(dropDownClass);
         dropDowns.Add(m);
         db.SaveChanges();
         RouteValueDictionary routes = new RouteValueDictionary();
         routes.Add("dropDownClass", dropDownClass);
         return RedirectToAction("Index", "DropDownAdmin", routes);
     }
     else
     {
         ModelState.AddModelError("", "ModelState is not valid");
         addAdminVariables(dropDownClass);
         return View(m);
     }
 }
예제 #2
0
 public void wrongEditLogicTest()
 {
     DropDown m = new DropDown();
     ActionResult result = dDAdminController.Edit(m, "Bubba");
     Assert.AreEqual("System.Web.Mvc.RedirectToRouteResult", result.GetType().FullName);
 }
예제 #3
0
 public void nullDeleteLogicTest()
 {
     DropDown m = new DropDown();
     ActionResult result = dDAdminController.Delete(0, null);
     Assert.AreEqual("System.Web.Mvc.RedirectToRouteResult", result.GetType().FullName);
 }
예제 #4
0
 public ActionResult Edit(DropDown model, string dropDownClass)
 {
     if (dropDownClass == null || (dropDownClass != "RequesterType" && dropDownClass != "QuestionType" && dropDownClass != "TumourGroup" && dropDownClass != "Region"))
     {
         return RedirectToAction("Index", "Home");
     }
     addAdminVariables(dropDownClass);
     if (model.Code == null || model.FullName == null)
     {
         DropDown m = getDropDownType(dropDownClass);
         m.ID = model.ID;
         m.Code = model.Code;
         m.FullName = model.FullName;
         m.Enabled = model.Enabled;
         return View(m);
     }
     if (ModelState.IsValid)
     {
         DbSet dropDowns;
         DropDown dropDown = new DropDown();
         dropDowns = getDropDowns(dropDownClass);
         dropDown = (DropDown)dropDowns.Find(model.ID);
         if (model.Code == null || model.Code == "" || model.FullName == null || model.FullName == "")
         {
             return View(model);
         }
         dropDown.Code = model.Code;
         dropDown.FullName = model.FullName;
         db.SaveChanges();
         RouteValueDictionary routes = new RouteValueDictionary();
         routes.Add("dropDownClass", dropDownClass);
         return RedirectToAction("Index", "DropDownAdmin", routes);
     }
     else
     {
         ModelState.AddModelError("", "ModelState is not valid");
         return View(model);
     }
 }
예제 #5
0
 public ActionResult Delete(int dropDownId, string dropDownClass)
 {
     DbSet dropDowns;
     DropDown dropDown = new DropDown();
     dropDowns = getDropDowns(dropDownClass);
     if (dropDowns == null)
     {
         return RedirectToAction("Index", "Home");
     }
     dropDown = (DropDown)dropDowns.Find(dropDownId);
     dropDown.Enabled = !dropDown.Enabled;
     db.SaveChanges();
     RouteValueDictionary routes = new RouteValueDictionary();
     routes.Add("dropDownClass", dropDownClass);
     return RedirectToAction("Index", "DropDownAdmin", routes);
 }