public ActionResult CreateUserRequest(UserRequest u) { // Same method as above for the drop down list. List<SelectListItem> languageList = new List<SelectListItem>(); languageList.Add(new SelectListItem { Text = "Veldu tungumál", Value = string.Empty }); languageList.Add(new SelectListItem { Text = "Enska", Value = "Enska" }); languageList.Add(new SelectListItem { Text = "Franska", Value = "Franska" }); languageList.Add(new SelectListItem { Text = "Íslenska", Value = "Íslenska" }); languageList.Add(new SelectListItem { Text = "Þýska", Value = "Þýska" }); ViewData["requestLanguage"] = languageList; // If the the model is valid then create new request. if (ModelState.IsValid) { u.userName = User.Identity.Name; userReqRepo.AddUserRequests(u); return RedirectToAction("GetRequests"); } return View(u); }
public void AddUserRequests(UserRequest newReq) { userRequestDb.userRequest.Add(newReq); Save(); }