public ActionResult Create(NewMenuViewModel newMenuViewModel) { ControllerResult result = ControllerResult.SuccResult; Path path = new Path() { Name = newMenuViewModel.MenuName, OrderNo = newMenuViewModel.MenuOrderNo, IsCategory = newMenuViewModel.IsCategory == 1, CategoryId = newMenuViewModel.CategoryId, Status = newMenuViewModel.MenuStatus, Icon = newMenuViewModel.MenuIcon, Url = string.IsNullOrWhiteSpace(newMenuViewModel.MenuUrl) ? string.Empty : newMenuViewModel.MenuUrl.Trim() }; string errorMsg = string.Empty; bool editResult = pathServcie.AddPath(path, out errorMsg); if (!editResult) { result = ControllerResult.FailResult; result.ErroMsg = errorMsg; } else { LogUserAction("对模块进行了新增操作,模块名称为{0},模块编号为{1},模块状态为{2}".Fmt(newMenuViewModel.MenuName, newMenuViewModel.MenuOrderNo, newMenuViewModel.MenuStatus)); } return(Content(result.ToJson())); }
public ActionResult CreateMenu(NewMenuViewModel model) { var context = new AppSecurityContext(); var menuRepository = new MenuRepository(context); if (ModelState.IsValid) { var menu = mapper.Map <AppMenu>(model); menuRepository.Add(menu); context.SaveChanges(); return(RedirectToAction("Menus")); } return(View()); }
public ViewModelLocator() { _navigationService = new NavigationService(); _dataService = new DataService(new UserRepository(), new MenuRepository(), new DishRepository(), new CustomerRepository(), new DelivererRepository(), new EventRepository(), new IngredientRepository()); CustomerOverviewViewModel = new CustomerOverviewViewModel(_navigationService, _dataService); DelivererOverviewViewModel = new DelivererOverviewViewModel(_navigationService, _dataService); EventOverviewViewModel = new EventOverviewViewModel(_navigationService, _dataService); LoginViewModel = new LoginViewModel(_navigationService, _dataService); MainViewModel = new MainViewModel(_navigationService, _dataService); EditCustomerViewModel = new EditCustomerViewModel(_navigationService, _dataService); EditDelivererViewModel = new EditDelivererViewModel(_navigationService, _dataService); EditEventViewModel = new EditEventViewModel(_navigationService, _dataService); EditStaffViewModel = new EditStaffViewModel(_navigationService, _dataService); NewDelivererViewModel = new NewDelivererViewModel(_navigationService, _dataService); NewDishViewModel = new NewDishViewModel(_navigationService, _dataService); NewEventViewModel = new NewEventViewModel(_navigationService, _dataService); NewMenuViewModel = new NewMenuViewModel(_navigationService, _dataService); NewStaffViewModel = new NewStaffViewModel(_navigationService, _dataService); StaffViewModel = new StaffViewModel(_navigationService, _dataService); }