public IActionResult RevCreate(TPReview rev, int Pid, string actionType) { if (actionType == "Add") { if (ModelState.IsValid) { try{ _dbContext.TPReviews.Add(rev); _dbContext.SaveChanges(); } catch { return(View("Error")); } } else { loadPersonViewBag(Pid); return(View(rev)); } } var model = _dbContext.TPersons .SingleOrDefault(u => u.PerId.Equals(Pid)); CreateViewBags(Pid); ViewData["panel"] = 7; return(View("Edit", model)); }
public IActionResult RevEdit(TPReview rev, string actionType) { int?Pid = rev.RevPerId; if (actionType == "Update") { if (ModelState.IsValid) { try{ _dbContext.TPReviews.Update(rev); _dbContext.SaveChanges(); } catch {} } else { loadPersonViewBag(Pid); return(View(rev)); } } var model = _dbContext.TPersons .SingleOrDefault(u => u.PerId.Equals(Pid)); CreateViewBags(Pid); ViewData["panel"] = 7; return(View("Edit", model)); //return RedirectToAction("Index"); }
public IActionResult RevCreate(TPReview rev, int Pid, string actionType) { if (actionType == "Add") { if (ModelState.IsValid) { try{ _dbContext.TPReviews.Add(rev); _dbContext.SaveChanges(); } catch { return(View("Error")); } } else { loadPersonViewBag(Pid); return(View(rev)); } } 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"] = 7; return(RedirectToAction("Edit", new { id = Pid, panel = 7, move = 0 })); }