public ToDoStatus_List() { ToDoStatusService = DependencyResolver.Kernel.Get <IToDoStatusService>(); InitializeComponent(); this.DataContext = this; }
public ToDoStatusPopup() { toDoStatusService = DependencyResolver.Kernel.Get <IToDoStatusService>(); InitializeComponent(); // MVVM Data binding (this.Content as FrameworkElement).DataContext = this; AddHandler(Keyboard.PreviewKeyDownEvent, (KeyEventHandler)HandleKeyDownEvent); }
public ToDoStatus_AddEdit(ToDoStatusViewModel ToDoStatusViewModel, bool isCreateProcess, bool isPopup = false) { ToDoStatusService = DependencyResolver.Kernel.Get <IToDoStatusService>(); InitializeComponent(); this.DataContext = this; CurrentToDoStatus = ToDoStatusViewModel; IsCreateProcess = isCreateProcess; IsPopup = isPopup; }
public ToDoStatusController(IServiceProvider provider) { ToDoStatusService = provider.GetRequiredService <IToDoStatusService>(); }
public void Sync(IToDoStatusService toDoStatusService, Action <int, int> callback = null) { try { SyncToDoStatusRequest request = new SyncToDoStatusRequest(); request.CompanyId = MainWindow.CurrentCompanyId; request.LastUpdatedAt = GetLastUpdatedAt(MainWindow.CurrentCompanyId); int toSync = 0; int syncedItems = 0; ToDoStatusListResponse response = toDoStatusService.Sync(request); if (response.Success) { toSync = response?.ToDoStatuses?.Count ?? 0; List <ToDoStatusViewModel> toDoStatusesFromDB = response.ToDoStatuses; using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); using (var transaction = db.BeginTransaction()) { SqliteCommand deleteCommand = db.CreateCommand(); deleteCommand.CommandText = "DELETE FROM ToDoStatuses WHERE Identifier = @Identifier"; SqliteCommand insertCommand = db.CreateCommand(); insertCommand.CommandText = SqlCommandInsertPart; foreach (var toDoStatus in toDoStatusesFromDB) { deleteCommand.Parameters.AddWithValue("@Identifier", toDoStatus.Identifier); deleteCommand.ExecuteNonQuery(); deleteCommand.Parameters.Clear(); if (toDoStatus.IsActive) { toDoStatus.IsSynced = true; insertCommand = AddCreateParameters(insertCommand, toDoStatus); insertCommand.ExecuteNonQuery(); insertCommand.Parameters.Clear(); syncedItems++; callback?.Invoke(syncedItems, toSync); } } transaction.Commit(); } db.Close(); } } else { throw new Exception(response.Message); } } catch (Exception ex) { MainWindow.ErrorMessage = ex.Message; } }