public ActionResult Manage(Question question) { if (!ModelState.IsValid) { return QuestionView(question); } if (string.IsNullOrWhiteSpace(question.UserId)) { question.UserId = User.Identity.GetUserId(); } question.CreatedAt = DateTime.Now; if (question.Id == 0) { _questionService.Create(question); } else { _questionService.Update(question); } return RedirectToAction("Index", "Question", new {question.Id}); }
private ActionResult QuestionView(Question question) { ViewBag.Categories = _categoryService.GetAll().Select(c => new SelectListItem {Text = c.Name, Value = c.Id.ToString()}); return View("Manage", question); }