public ActionResult Create(QuestionInputModel inputModel) { try { if (ModelState.IsValid) { var question = Mapper.Map<QuestionInputModel, Core.Entities.Question>(inputModel); question.CreatedByUserId = User.Identity.UserId; _questionService.Store(question); DocumentSession.SaveChanges(); return RedirectToAction("Index", "Home", new {area = ""}); } } catch (Exception exception) { ModelState.AddModelError("RuRoh", exception.Message); } var viewModel = new QuestionViewModel(User.Identity); Mapper.Map(inputModel, viewModel); return View("Create", viewModel); }
public ActionResult Create() { var inputModel = new QuestionViewModel(User.Identity) { Header = "Ask a Question" }; return View("Create", inputModel); }