public ActionResult Create(GoalStep goalstep, int goalid) { if (ModelState.IsValid) { int checkYear = 1900; //int checkYear2 = DateTime.Now.Year - 15; int inYear = goalstep.DueDate.Year; if (inYear < checkYear) { ViewBag.DateValidation = "Please enter a date between 1900 and now."; return View(); } Goal goal = db.Goals.Find(goalid); goalstep.Goal = goal; goal.Steps.Add(goalstep); db.GoalSteps.Add(goalstep); db.SaveChanges(); return RedirectToAction("edit", "Goal", new { id = goalid }); } return View(goalstep); }
public ActionResult Edit(GoalStep goalstep, int goalID) { if (ModelState.IsValid) { db.Entry(goalstep).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction( actionName:"Edit", controllerName:"Goal", routeValues: new { id = goalID}); } return View(goalstep); }