public ActionResult Add(int?categoryId, int?requestId) { AddFaqItemViewModel vm = new AddFaqItemViewModel { FaqCategoryId = categoryId, RequestId = requestId, CategorySelectListItems = GetFaqCategoriesList(categoryId) }; if (requestId.HasValue) { vm.Request = GetFaqRequestDetail(requestId.Value); vm.Title = vm.Request?.Question; } return(View(vm)); }
public ActionResult Add(AddFaqItemViewModel vm) { if (!ModelState.IsValid) { vm.CategorySelectListItems = GetFaqCategoriesList(vm.FaqCategoryId); return(View(vm)); } Command.Execute(new AddFaqItemCommand { Title = vm.Title, ShortContent = vm.ShortContent, HtmlContent = vm.HtmlContent, FaqCategoryId = vm.FaqCategoryId.Value, RequestId = vm.RequestId, IsPublished = vm.IsPublished, IsHtmlContentDisplay = vm.IsHtmlContentDisplay, IsDysplayOnMainScreen = vm.IsDysplayOnMainScreen }); return(RedirectToAction("Index")); }