//Returns partial view: List option values and associated set values public ActionResult ViewOptionValues(int id) { try { //if (id == null) //{ // ViewBag.Error = "A null parameter was passed to the function"; // return View("Error"); //} var model = new Option(); var ov = db.Option.Include(x => x.OptionValues).FirstOrDefault(x => x.OptionID == id); model.OptionValues = ov.OptionValues; //foreach(var item in ov.OptionValues) //{ // var sv = db.OptionValue.Include(x => x.SetValue).FirstOrDefault(x => x.OptionValueID == item.OptionValueID); // model.OptionValues.FirstOrDefault().SetValue = sv.SetValue; //} var op = db.Option.FirstOrDefault(x => x.OptionID == id); var tc = db.Option.FirstOrDefault(x => x.OptionID == id).TechnicalCharacteristic; model.TechnicalCharacteristic = tc; ViewBag.Option = op.OptionName; ViewBag.Lsystem = op.Lsystem.LsystemName; ViewBag.FamilyName = op.Lsystem.LsystemFamily.FamilyName; ViewBag.id = op.LsystemID; return PartialView(model); } catch(Exception e) { ViewBag.Error = e.Message; return View("Error"); } }
public ActionResult OptionCreate(string OptionName, int lsysid) { if (db.UserRight.FirstOrDefault(x => x.UserCode == User.Identity.Name).IsAdmin || db.UserRight.FirstOrDefault(x => x.UserCode == User.Identity.Name).IsEditor) { var model = new Option { OptionName = OptionName, LsystemID = lsysid }; var sys = db.Lsystem.FirstOrDefault(x => x.LsystemID == lsysid); ViewBag.Lsystem = sys.LsystemName; ViewBag.FamilyName = sys.LsystemFamily.FamilyName; ViewBag.TechnicalCharacteristicID = new SelectList(db.TechnicalCharacteristic.OrderBy(x => x.TCName), "TechnicalCharacteristicID", "TCName"); var tc = db.TechnicalCharacteristic.Any(); if (!tc) ViewBag.Message = "There are no technical Characteristics to display. Please Add new Technical Characteristics"; return View(model); } else return View("AuthorizationError"); }
// GET: Options/Create public ActionResult Create(int id) { if (db.UserRight.FirstOrDefault(x => x.UserCode == User.Identity.Name).IsAdmin || db.UserRight.FirstOrDefault(x => x.UserCode == User.Identity.Name).IsEditor) { try { //if (id == null) //{ // ViewBag.Error = "A null parameter was passed to the function"; // return View("Error"); //} var model = new Option { LsystemID = id }; //ViewBag.LsystemID = new SelectList(db.Lsystem, "LsystemID", "LsystemName"); var sys = db.Lsystem.FirstOrDefault(x => x.LsystemID == id); ViewBag.Lsystem = sys.LsystemName; ViewBag.FamilyName = sys.LsystemFamily.FamilyName; ViewBag.TechnicalCharacteristicID = new SelectList(db.TechnicalCharacteristic.OrderBy(x=>x.TCName), "TechnicalCharacteristicID", "TCName"); var tc = db.TechnicalCharacteristic.Any(); if (!tc) ViewBag.Message = "There are no technical Characteristics to display. Please Add new Technical Characteristics"; return View(model); } catch(Exception e) { ViewBag.Error = e.Message; return View("Error"); } } else return View("AuthorizationError"); }
public ActionResult ViewOptionValues (int id) { try { //if (id == null) //{ // ViewBag.Error = "A null parameter was passed to the function"; // return View("Error"); //} ViewBag.id = id; var model = new Option(); model.OptionValues = new List<OptionValue>(); model = db.Option.Include(x=>x.OptionValues).FirstOrDefault(x => x.OptionID == id); var ov = db.OptionValue.Where(x => x.OptionID == id); ViewBag.Option = model.OptionName; ViewBag.Lsystem = model.Lsystem.LsystemName; ViewBag.FamilyName = model.Lsystem.LsystemFamily.FamilyName; ViewBag.LsystemID = model.LsystemID; model.OptionValues = ov.OrderBy(x => x.OptionVal).ToList(); //model.OptionValues = ((from ov in model.OptionValues orderby ov.OptionVal ascending select ov).ToList<OptionValue>()); return View(model); } catch(Exception e) { ViewBag.Error = e.Message; return View("Error"); } }