/// <summary> /// Creates SelectLists for Foreign-keys /// </summary> private void LoadSelectLists(Need need) { var categories = Model.New<Category>().GetAll().ToList(); ViewData["Categories"] = new SelectList(categories, "ID", "Name", need.CategoryID); }
public ActionResult Create(Need need) { if (ModelState.IsValid) { try { need.SubmittedByID = CurrentUser.ID; need.ChurchID = CurrentUser.ChurchID; need.NeedStatusID = (int)NeedStatusEnum.Pending; need.Save(); return RedirectToAction("Index"); } catch (Exception ex) { // put exception somewhere on screen or redirect throw (ex); } } // Unsuccessful, so load the necessary data for the form and show it again LoadSelectLists(need); return View("New", need); }