public ActionResult Edit(int id) { FindFaqItemByIdQueryResult result = Query.For <FindFaqItemByIdQueryResult>().ById(id); if (!result.IsFounded) { return(RedirectToAction("Index")); } FaqItem item = result.Item; EditFaqItemViewModel vm = new EditFaqItemViewModel { Id = id, FaqCategoryId = item.FaqCategoryId, Title = item.Title, ShortContent = item.ShortContent, HtmlContent = item.HtmlContent, IsDysplayOnMainScreen = item.IsDysplayOnMainScreen, IsHtmlContentDisplay = item.IsHtmlContentDisplay, IsPublished = item.IsPublished, CategorySelectListItems = GetFaqCategoriesList(item.FaqCategoryId) }; return(View(vm)); }
public ActionResult Edit(EditFaqItemViewModel vm) { if (!ModelState.IsValid) { vm.CategorySelectListItems = GetFaqCategoriesList(vm.FaqCategoryId); return(View(vm)); } Command.Execute(new EditFaqItemCommand { Id = vm.Id, Title = vm.Title, ShortContent = vm.ShortContent, HtmlContent = vm.HtmlContent, FaqCategoryId = vm.FaqCategoryId.Value, IsPublished = vm.IsPublished, IsHtmlContentDisplay = vm.IsHtmlContentDisplay, IsDysplayOnMainScreen = vm.IsDysplayOnMainScreen }); return(RedirectToAction("Index")); }