public ActionResult Create() { var viewModel = new CreateMenuViewModel(); viewModel = CreateViewModel(viewModel); return View(viewModel); }
public ActionResult Create() { var viewModel = new CreateMenuViewModel(); viewModel.IsActive = true; viewModel.AddParent = true; viewModel = CreateViewModel(viewModel); return View(viewModel); }
public ActionResult Create(CreateMenuViewModel viewModel) { var request = viewModel.MapTo<CreateMenuRequest>(); var response = _menuService.Create(request); TempData["IsSuccess"] = response.IsSuccess; TempData["Message"] = response.Message; if (response.IsSuccess) { return RedirectToAction("Index"); } return View("Create", viewModel); }
public CreateMenuViewModel CreateViewModel(CreateMenuViewModel viewModel) { viewModel.RoleGroupOptions = _roleService.GetRoleGroups( new Services.Requests.RoleGroup.GetRoleGroupsRequest { Skip = 0, Take = 0 }).RoleGroups.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }).ToList(); List<SelectListItem> menuList = _menuService.GetMenus( new Services.Requests.Menu.GetMenusRequest { Skip = 0, Take = 0 }).Menus.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }).ToList(); //menuList.Insert(0, new SelectListItem { Text = "This is Root", Value = "0", Selected = true }); viewModel.MenuOptions = menuList; return viewModel; }