public ActionResult Create() { var perspectiveEdit = new PerspectiveEdit { /*Commented -> Category replaced by tours CategoryList = _perspectiveQueryService.Categories(), CategoriesFromPost = new System.Collections.Generic.List<string>() */ TourList = _tourQueryService.Tours() }; return View(perspectiveEdit); }
public ActionResult Create(PerspectiveEdit perspectiveEdit) { if (ModelState.IsValid) { /*Commented -> Category replaced by tours perspectiveEdit.SelectedCategories = new System.Collections.Generic.List<int>(); foreach (string s in perspectiveEdit.CategoriesFromPost) perspectiveEdit.SelectedCategories.Add(Convert.ToInt32(s)); */ var perspectivePostUpdate = Mapper.Map<PerspectivePostUpdate>(perspectiveEdit); perspectivePostUpdate.UserId = UserContext.UserId; _perspectiveCommandService.Add(perspectivePostUpdate); return RedirectToRoute("admin-perspectives"); } perspectiveEdit.TourList = _tourQueryService.Tours(); /*Commented -> Category replaced by tours if (perspectiveEdit.CategoriesFromPost == null) perspectiveEdit.CategoriesFromPost = new System.Collections.Generic.List<string>(); perspectiveEdit.CategoryList = _perspectiveQueryService.Categories(); */ return View(perspectiveEdit); }
public ActionResult Edit(PerspectiveEdit perspectiveEdit) { if (!ModelState.IsValid) { /*Commented -> Category replaced by tours perspectiveEdit.CategoryList = _perspectiveQueryService.Categories(); ; perspectiveEdit.CategoriesFromPost = new System.Collections.Generic.List<string>(); */ perspectiveEdit.TourList = _tourQueryService.Tours(); return View(perspectiveEdit); } /*Commented -> Category replaced by tours perspectiveEdit.SelectedCategories = new System.Collections.Generic.List<int>(); foreach (string s in perspectiveEdit.CategoriesFromPost) perspectiveEdit.SelectedCategories.Add(Convert.ToInt32(s)); */ var perspectiveUpdate = Mapper.Map<PerspectivePostUpdate>(perspectiveEdit); _perspectiveCommandService.Update(perspectiveUpdate); TempData["Info"] = "Perspective post updated"; return RedirectToRoute("admin-perspective-edit", new { perspectiveEdit.Id }); }