public ActionGroupViewModel(SimpleAutoMapper autoMapper, ViewModelFactory viewModelFactory, ViewModelClipboard clipboard) : base(clipboard) { this.autoMapper = autoMapper; this.viewModelFactory = viewModelFactory; InitializeCommands(); }
public async Task <object> AddInstructor([FromBody] InstructorClassViewModel model) { InstructorClass item = new SimpleAutoMapper <InstructorClass>().Map(model); try { if (await this.CheckPermissionToAddInstructor(item)) { Response response = await _classService.AddInstructor(new Class() { ID = item.ClassID }, new Instructor() { ID = item.InstructorID }); return(new { success = response.Success }); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public async Task <object> CreateCourse(CourseViewModel model) { Course course = new SimpleAutoMapper <Course>().Map(model); try { if (await this.CheckPermissionToCreateCourse(course)) { User user = (await _userService.GetByID(this.GetUserID())).Data[0]; if (course.Owners != null) { course.Owners.Clear(); } int id = (await _courseService.CreateAndReturnId(course)).Data[0]; course = (await _courseService.GetByID(id)).Data[0]; return(this.SendResponse(await _courseService.AddOwner(course, user.Owner))); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public SwipeViewModel(SimpleAutoMapper autoMapper, ViewModelFactory viewModelFactory) { this.autoMapper = autoMapper; this.viewModelFactory = viewModelFactory; InitializeCommands(); }
public FoodViewModel(IPredefinedActionProvider actionProvider, SimpleAutoMapper autoMapper) { this.actionProvider = actionProvider; this.autoMapper = autoMapper; InitializeCommands(); }
public async Task <object> AddCoordinator([FromBody] CoordinatorClassViewModel model) { CoordinatorClass item = new SimpleAutoMapper <CoordinatorClass>().Map(model); try { if (await CheckPermissionToAddCoordinator(item)) { Response response = await _classService.AddCoordinator(new Class() { ID = item.ClassID }, new Coordinator() { ID = item.CoordinatorID }); return(response); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public AEMG SetupMainWindow() { //reset working directory Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var dataIO = new DataIO(); var aeActionFactory = new AEActionFactory(); var autoMapper = new SimpleAutoMapper(); var messageBox = new MessageBoxService(); var scriptApplyDict = new Dictionary <Emulator, IApplyScriptToFolder>() { { Emulator.Nox, new NoxScriptApply(messageBox) }, { Emulator.Memu, new MemuScriptApply(messageBox) } }; var scriptApply = new ScriptApplyFactory(messageBox, scriptApplyDict); var scanner = new MacroScanner(dataIO, aeActionFactory); var macroManager = new AEMacroManager(scanner, messageBox); var aESettingVM = new AESettingViewModel(new AESetting()); var aeScriptGenerator = new AEScriptGenerator(scriptApply, aESettingVM, messageBox, autoMapper); var autoUpdater = new AutoUpdater(messageBox); var actionList = new AEActionListViewModel(macroManager); return(new AEMG { DataContext = new AEMGViewModel(macroManager, actionList, aESettingVM, aeScriptGenerator, messageBox, autoUpdater) }); }
public BossBattleViewModel(IPredefinedActionProvider actionProvider, SimpleAutoMapper autoMapper, ITurnFactory turnFactory) : base(actionProvider, autoMapper, turnFactory) { base.TurnList = new ObservableCollection <TurnViewModel>() { new BossTurnViewModel() }; base.CurrentTurn = base.TurnList[0]; base.InitializeCommand(); }
public TrashMobBattleViewModel(IPredefinedActionProvider actionProvider, SimpleAutoMapper autoMapper, ITurnFactory turnFactory) : base(actionProvider) { this.autoMapper = autoMapper; this.turnFactory = turnFactory; base.TurnList = new ObservableCollection <TurnViewModel>() { new TurnViewModel() }; base.CurrentTurn = base.TurnList[0]; base.InitializeCommand(); }
public ActionProvider(SimpleAutoMapper autoMapper, IMessageBoxService messageBoxService) { this.autoMapper = autoMapper; this.messageBoxService = messageBoxService; defaultAction = new DefaultAction { Version = new Version(1, 0, 0, 0) }; if (!CreateDefaultActionIfNotExistedOrOutDated()) { LoadDefaultAction(); } }
public EXPBattleViewModel(IPredefinedActionProvider actionProvider, SimpleAutoMapper autoMapper, ITurnFactory turnFactory) : base(actionProvider, autoMapper, turnFactory) { this.actionProvider = actionProvider; SelectedLeftRight = new ObservableCollection <Action>(new List <Action> { Action.RunLeft, Action.RunRight, Action.RunLeft, Action.RunRight }); base.TurnList = new ObservableCollection <TurnViewModel>() { new EXPTurnViewModel() }; base.CurrentTurn = base.TurnList[0]; this.InitializeCommand(); }
public AEMG SetupMainWindow() { //reset working directory Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); //set culture Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); var dataIO = new DataIO(); var autoMapper = new SimpleAutoMapper(); var messageBox = new MessageBoxService(); var repository = new AERepository(); var mtpManager = new MTPManager(); var saverepo = new AESavedSetupRepository(); var actionProvider = new ActionProvider(autoMapper, messageBox); var aeActionFactory = new AEActionFactory(actionProvider); var DependencyDict = new Dictionary <Type, object>() { { typeof(SimpleAutoMapper), autoMapper }, { typeof(MessageBoxService), messageBox }, { typeof(ViewModelClipboard), new ViewModelClipboard() }, }; var viewModelFactory = new ViewModelFactory(DependencyDict); var appSettingVM = new ApplicationSettingViewModel(actionProvider, viewModelFactory); SetupWindowInit(appSettingVM, out IWindowInitlizer windowinit); (new ScriptGenerateBootstrap()).SetUp(out IActionToScriptFactory actionToScriptFactory, out IEmulatorToScriptFactory emulatorToScriptFactory); var scriptApply = new ScriptApplyBootStrap(messageBox, mtpManager).GetScriptApplyFactory(); var scanner = new MacroScanner(dataIO, aeActionFactory); var macroManager = new AEMacroManager(scanner); var macroManagerVM = new AEMacroManagerViewModel(scanner, messageBox, macroManager, windowinit); var aESettingVM = new AESettingViewModel(new AESetting(), mtpManager); var aeScriptGenerator = new AEScriptGenerator(scriptApply, aESettingVM, messageBox, autoMapper, emulatorToScriptFactory, actionToScriptFactory, dataIO, actionProvider); var autoUpdater = new AutoUpdater(messageBox); var actionList = new AEActionListViewModel(macroManager, repository, messageBox); var savemanager = new AEMacroSaveManagerViewModel(saverepo, macroManager); return(new AEMG { DataContext = new AEMGViewModel(macroManagerVM, actionList, aESettingVM, aeScriptGenerator, messageBox, autoUpdater, savemanager, macroManager) }); }
public async Task <object> AddOwner(OwnerCourseViewModel model) { OwnerCourse ownerCourse = new SimpleAutoMapper <OwnerCourse>().Map(model); try { if (await this.CheckPermissionToAddOwner(ownerCourse)) { return(await _courseService.AddOwner((await _courseService.GetByID(ownerCourse.CourseID)).Data[0], (await _ownerService.GetByID(ownerCourse.OwnerID)).Data[0])); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public async Task <object> UpdateCourse(CourseViewModel model, int id) { Course course = new SimpleAutoMapper <Course>().Map(model); course.ID = id; try { User user = (await _userService.GetByID(this.GetUserID())).Data[0]; if (await this.CheckPermissionToUpdateCourse(course)) { return(this.SendResponse(await _courseService.Update(course))); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public async Task <object> UpdateInstructor(InstructorViewModel model, int id) { Instructor instructor = new SimpleAutoMapper <Instructor>().Map(model); instructor.ID = id; try { if (await CheckPermissionToCreateUpdateInstructor(instructor)) { Response response = await _service.Update(instructor); return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { return(null); } }
public async Task <object> CreateAttendance(AttendanceViewModel model) { try { Attendance attendance = new SimpleAutoMapper <Attendance>().Map(model); if (await this.CheckPermissionToCreateOrUpdateAttendance(attendance)) { Response response = await _service.Create(attendance); return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public async Task <object> CreateCoordinator(CoordinatorViewModel model) { Coordinator coordinator = new SimpleAutoMapper <Coordinator>().Map(model); try { if (coordinator.UserID == this.GetUserID()) { Response response = await _service.Create(coordinator); return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public async Task <object> CreateSubject(SubjectViewModel model) { Subject subject = new SimpleAutoMapper <Subject>().Map(model); try { if (await CheckPermissionToCreateUpdateSubject(subject)) { Response response = await _service.Create(subject); return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public async Task <object> UpdateStudent(StudentViewModel model, int id) { Student student = new SimpleAutoMapper <Student>().Map(model); student.ID = id; try { if (await CheckPermissionToCreateUpdateStudent(student)) { Response response = await _service.Update(student); return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public async Task <object> UpdateOwner(OwnerViewModel model, int id) { Owner owner = new SimpleAutoMapper <Owner>().Map(model); owner.ID = id; try { if (await CheckPermissionToCreateUpdateOwner(owner)) { Response response = await _service.Update(owner); return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public async Task <object> Create(ClassViewModel model) { Class Class = new SimpleAutoMapper <Class>().Map(model); try { if (await this.CheckPermissionToCreateOrUpdateClass(Class)) { Response response = await _classService.Create(Class); return(response); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public async Task <object> CreateEvaluation(EvaluationViewModel model) { Evaluation evaluation = new SimpleAutoMapper <Evaluation>().Map(model); try { if (await this.CheckPermissionToCreateEvaluation(evaluation)) { Response response = await _service.Create(evaluation); return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public SettingViewModel(Settings settings, SimpleAutoMapper autoMapper) { this.autoMapper = autoMapper; this.settings = settings; this.autoMapper.SimpleAutoMap <Settings, SettingViewModel>(this.settings, this); Messenger.Register((sender, e) => { if (e.EventMessage != EventMessage.SaveSettings) { return; } this.autoMapper.SimpleAutoMap <SettingViewModel, Settings>(this, this.settings); this.settings.Save(); }); InitializeCommands(); }
public async Task <object> UpdateCoordinator(CoordinatorViewModel model, int id) { Coordinator coordinator = new SimpleAutoMapper <Coordinator>().Map(model); coordinator.ID = id; try { if (await this.CheckPermissionToUpdateOrDeleteCoordinator(id)) { Response response = await _service.Update(coordinator); return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public AEActionFactory(IPredefinedActionProvider actionProvider) { this.AEActionDict = new Dictionary <AEAction, Type>() { { AEAction.TrashMobBattle, typeof(TrashMobBattleViewModel) }, { AEAction.EXPBattle, typeof(EXPBattleViewModel) }, { AEAction.BossBattle, typeof(BossBattleViewModel) }, { AEAction.FoodAD, typeof(FoodViewModel) }, { AEAction.ReFoodAD, typeof(ReFoodViewModel) }, { AEAction.Wait, typeof(WaitViewModel) }, }; var autoMapper = new SimpleAutoMapper(); var turnFactory = new TurnFactory(); this.DependencyDict = new Dictionary <Type, object>() { { typeof(SimpleAutoMapper), autoMapper }, { typeof(ITurnFactory), turnFactory }, { typeof(IPredefinedActionProvider), actionProvider } }; }
public async Task <object> UpdateEvaluation(EvaluationViewModel model, int id) { Evaluation evaluation = new SimpleAutoMapper <Evaluation>().Map(model); evaluation.ID = id; try { User user = (await this._userService.GetByID(this.GetUserID())).Data[0]; if (await this.CheckPermissionToUpdateEvaluation(evaluation)) { Response response = await _service.Update(evaluation); return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public AEScriptGenerator(ScriptApplyFactory scriptApplyFactory, AESettingViewModel setting, IMessageBoxService messageBoxService, SimpleAutoMapper autoMapper) { this.scriptApplyFactory = scriptApplyFactory; this.setting = setting; this.messageBoxService = messageBoxService; this.autoMapper = autoMapper; }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); //reset working directory Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); //set culture Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); var autoMapper = new SimpleAutoMapper(); var dataIO = new DataIO(); var messageBox = new MessageBoxService(); var mouseHook = new MouseHook(); var timerTool = new TimerTool(); var autoUpdater = new AutoUpdater(messageBox); var clipboard = new ViewModelClipboard(); var recent = new RecentFileManager(); var mtpManager = new MTPManager(); var DependencyDict = new Dictionary <Type, object>() { { typeof(SimpleAutoMapper), autoMapper }, { typeof(MessageBoxService), messageBox }, { typeof(ViewModelClipboard), clipboard }, }; var viewModelFactory = new ViewModelFactory(DependencyDict); (new ScriptGenerateBootstrap()).SetUp(out IActionToScriptFactory actionToScriptFactory, out IEmulatorToScriptFactory emulatorToScriptFactory); var settingVM = new SettingViewModel(Settings.Default(), autoMapper, mtpManager); var macroManagerVM = new MacroManagerViewModel(dataIO, messageBox, viewModelFactory, recent); var scriptApplyFactory = new ScriptApplyBootStrap(messageBox, mtpManager).GetScriptApplyFactory(); var scriptGenerator = new ScriptGenerator(scriptApplyFactory, settingVM, messageBox, emulatorToScriptFactory, actionToScriptFactory); var scriptGeneratorVM = new ScriptGeneratorViewModel(macroManagerVM, scriptGenerator, messageBox); var customActionManager = new CustomActionManager(macroManagerVM, viewModelFactory, dataIO, messageBox); var timerToolVM = new TimerToolViewModel(mouseHook, timerTool); var resulutionTool = new ResolutionConverterTool(viewModelFactory); var resolutionToolVM = new ResolutionConverterToolViewModel(resulutionTool, macroManagerVM, messageBox); var autoLocationVM = new AutoLocationViewModel(new MouseHook(), new AutoLocation(), macroManagerVM); var mainWindowViewModel = new MainWindowViewModel(macroManagerVM, settingVM, autoUpdater, timerToolVM, resolutionToolVM, scriptGeneratorVM, customActionManager, autoLocationVM); MainWindow = new MainWindow { DataContext = mainWindowViewModel }; //Handle arguments var agrs = Environment.GetCommandLineArgs(); if (agrs.Length > 1) { var filepath = agrs.Where(s => s.Contains(".emm")).First(); macroManagerVM.SetCurrentMacro(filepath, agrs.Any(s => s.Equals(StaticVariables.NO_SAVE_AGRS))); } // Select the text in a TextBox when it receives focus. EventManager.RegisterClassHandler(typeof(TextBox), TextBox.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(SelectivelyIgnoreMouseButton)); EventManager.RegisterClassHandler(typeof(TextBox), TextBox.GotKeyboardFocusEvent, new RoutedEventHandler(SelectAllText)); EventManager.RegisterClassHandler(typeof(TextBox), TextBox.MouseDoubleClickEvent, new RoutedEventHandler(SelectAllText)); MainWindow.Show(); }
public AEViewModel(SimpleAutoMapper autoMapper, ViewModelFactory viewModelFactory) { this.autoMapper = autoMapper; this.viewModelFactory = viewModelFactory; }
public WaitViewModel(IPredefinedActionProvider actionProvider, SimpleAutoMapper autoMapper) { this.actionProvider = actionProvider; this.autoMapper = autoMapper; }