public Calendar_List() { InitializeComponent(); calendarAssignmentService = DependencyResolver.Kernel.Get <ICalendarAssignmentService>(); this.DataContext = this; DisplayDates(); }
public Calendar_AddEdit(CalendarAssignmentViewModel calendarAssignment, bool isCreateProcess, bool isPopup = false) { InitializeComponent(); calendarAssignmentService = DependencyResolver.Kernel.Get <ICalendarAssignmentService>(); this.DataContext = this; CurrentCalendarAssignment = calendarAssignment; IsCreateProcess = isCreateProcess; IsPopup = isPopup; }
public CalendarAssignmentController(IServiceProvider provider) { calendarAssignmentService = provider.GetRequiredService <ICalendarAssignmentService>(); }
public void Sync(ICalendarAssignmentService CalendarAssignmentService, Action <int, int> callback = null) { try { SyncCalendarAssignmentRequest request = new SyncCalendarAssignmentRequest(); request.CompanyId = MainWindow.CurrentCompanyId; request.LastUpdatedAt = GetLastUpdatedAt(MainWindow.CurrentCompanyId); int toSync = 0; int syncedItems = 0; CalendarAssignmentListResponse response = CalendarAssignmentService.Sync(request); if (response.Success) { toSync = response?.CalendarAssignments?.Count ?? 0; List <CalendarAssignmentViewModel> employeesFromDB = response.CalendarAssignments; using (SqliteConnection db = new SqliteConnection(SQLiteHelper.SqLiteTableName)) { db.Open(); using (var transaction = db.BeginTransaction()) { SqliteCommand deleteCommand = db.CreateCommand(); deleteCommand.CommandText = "DELETE FROM CalendarAssignments WHERE Identifier = @Identifier"; SqliteCommand insertCommand = db.CreateCommand(); insertCommand.CommandText = SqlCommandInsertPart; foreach (var employee in employeesFromDB) { deleteCommand.Parameters.AddWithValue("@Identifier", employee.Identifier); deleteCommand.ExecuteNonQuery(); deleteCommand.Parameters.Clear(); if (employee.IsActive) { employee.IsSynced = true; insertCommand = AddCreateParameters(insertCommand, employee); 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; } }