public IActionResult CurCreate(TPCurric curriculum, int?Pid, string actionType) { if (actionType == "Add") { if (ModelState.IsValid) { try{ _dbContext.TPCurrics.Add(curriculum); _dbContext.SaveChanges(); } catch { return(View("Error")); } } else { loadPersonViewBag(Pid); return(View(curriculum)); } } var model = _dbContext.TPersons .SingleOrDefault(u => u.PerId.Equals(Pid)); CreateViewBags(Pid); ViewData["panel"] = 4; return(View("Edit", model)); }
public IActionResult CurEdit(TPCurric curriculum, string actionType) { int?Pid = curriculum.CurrPerId; if (actionType == "Update") { if (ModelState.IsValid) { try{ _dbContext.TPCurrics.Update(curriculum); _dbContext.SaveChanges(); } catch {} } else { loadPersonViewBag(Pid); return(View(curriculum)); } } var model = _dbContext.TPersons .SingleOrDefault(u => u.PerId.Equals(Pid)); CreateViewBags(Pid); ViewData["panel"] = 4; return(View("Edit", model)); //return RedirectToAction("Index"); }
public IActionResult CurEdit(TPCurric curriculum, string actionType) { int?Pid = curriculum.CurrPerId; if (actionType == "Update") { if (ModelState.IsValid) { try{ _dbContext.TPCurrics.Update(curriculum); _dbContext.SaveChanges(); } catch {} } else { loadPersonViewBag(Pid); return(View(curriculum)); } } var model = _dbContext.TPersons .SingleOrDefault(u => u.PerId.Equals(Pid)); string dName = model.PerName1 + " " + model.PerName; ViewData["dName"] = dName; ViewData["PerId"] = Pid; CreateViewBags(Pid); ViewData["panel"] = 4; return(RedirectToAction("Edit", new { id = Pid, panel = 4, move = 0 })); }