private void SendReminders() { bool todoRemindersExisting = true; while (todoRemindersExisting) { var reminder = ReminderRepository.GetNextTimeHasComeReminder(); if (reminder != null) { try { //send reminder this.MessageService.SendReminder(reminder); //increase next reminding date for this reminder ReminderRepository.IncreaseNextRemindingDate(reminder.ID); } catch (Exception ex) { Logger.LogError(ex); } } //All reminders have been processed, exit loop else { todoRemindersExisting = false; } } }
public async Task <IHttpActionResult> RemoveReminders(int id) { var reminderRepo = new ReminderRepository(); await reminderRepo.RemoveReminders(id); return(Ok()); }
public void WhenUpdatingReminder_ThenPersists() { var repository = new ReminderRepository(this.GetUnitOfWork()); Reminder reminder = new Reminder() { DueDate = DateTime.UtcNow.AddDays(30), DueDistance = 1000, Title = "Test Reminder" }; repository.Create(this.defaultVehicle.VehicleId, reminder); var repositoryForUpdate = new ReminderRepository(this.GetUnitOfWork()); var reminderToUpdate = repositoryForUpdate.GetRemindersForVehicle(this.defaultVehicle.VehicleId).First(); reminderToUpdate.Title = "updated"; repositoryForUpdate.Update(reminderToUpdate); var repositoryForVerification = new ReminderRepository(this.GetUnitOfWork()); var returnedReminder = repositoryForVerification.GetRemindersForVehicle(this.defaultVehicle.VehicleId).First(); Assert.NotNull(returnedReminder); Assert.Equal("updated", returnedReminder.Title); }
public List <UtilityModel <uint> > GetReminderKinds() { using (var db = DB.GetContext()) { return(ReminderRepository.GetReminderKinds(db)); } }
public UnitOfWork(TelegramContext context) { _context = context; MessageHistorys = new MessageHistoryRepository(_context); TelegramUsers = new TelegramUserRepository(_context); Reminders = new ReminderRepository(_context); }
public ReminderService(DiscordSocketClient client, ReminderRepository repository, ILogger <ReminderService> logger) { this._client = client; this._repository = repository; this._logger = logger; this._reminders = new List <ReminderDto>(); }
public void WhenRetrievingUpcomingReminders_ThenRemindersInDueDateRangeRetrieved() { DateTime dateStart = DateTime.UtcNow; DateTime dateEnd = DateTime.UtcNow.AddDays(5); int odometer = 1000; int warningThreshold = 500; int outsideOdometerRange = odometer + warningThreshold + 1; var repository = new ReminderRepository(this.GetUnitOfWork()); // reminders just inside range var inRangeReminder1 = new Reminder() { DueDate = dateStart.AddDays(1), DueDistance = outsideOdometerRange, Title = "UpcomingReminder" }; repository.Create(this.defaultVehicle.VehicleId, inRangeReminder1); var inRangeReminder2 = new Reminder() { DueDate = dateEnd.AddDays(-1), DueDistance = outsideOdometerRange, Title = "UpcomingReminder1" }; repository.Create(this.defaultVehicle.VehicleId, inRangeReminder2); // reminders just outside of range repository.Create(this.defaultVehicle.VehicleId, new Reminder() { DueDate = dateStart.AddDays(-1), DueDistance = outsideOdometerRange, Title = "OutsideRangeReminder1" }); repository.Create(this.defaultVehicle.VehicleId, new Reminder() { DueDate = dateEnd.AddDays(1), DueDistance = outsideOdometerRange, Title = "OutsideRangeReminder2" }); var reminders = repository.GetUpcomingReminders( this.defaultVehicle.VehicleId, dateStart, dateEnd, odometer, warningThreshold ); Assert.Equal(2, reminders.Count()); Assert.True(reminders.Any(r => r.ReminderId == inRangeReminder1.ReminderId)); Assert.True(reminders.Any(r => r.ReminderId == inRangeReminder2.ReminderId)); }
public UnitOfWork(ApplicationDbContext context) { _context = context; Reminders = new ReminderRepository(context); Notifications = new NotificationsRepository(context); ReminderTypes = new ReminderTypesRepository(context); }
public void WhenDeletingReminder_ThenPersists() { var repository = new ReminderRepository(); Reminder reminder = new Reminder() { DueDate = DateTime.UtcNow.AddDays(30), DueDistance = 1000, Title = "Test Reminder" }; repository.Create(defaultVehicle.VehicleId, reminder); var repositoryForDelete = new ReminderRepository(); Assert.Equal(1, repositoryForDelete.GetRemindersForVehicle(defaultVehicle.VehicleId).Count()); repositoryForDelete.Delete(reminder.ReminderId); var repositoryForVerification = new ReminderRepository(); var returnedReminders = repositoryForVerification.GetRemindersForVehicle(defaultVehicle.VehicleId); Assert.NotNull(returnedReminders); Assert.Equal(0, returnedReminders.Count()); }
public ActionResult DeleteReminder(Guid reminderID) { ReminderRepository.DeleteReminder(reminderID); return(View()); }
private ReminderDataService GetReminderDataServiceWithFakes(DatabaseConnectionFake databaseConnectionFake) { ReminderRepository repository = new ReminderRepository(databaseConnectionFake); ReminderDataService dataService = new ReminderDataService(repository); return(dataService); }
public void WhenDeletingReminder_ThenPersists() { var repository = new ReminderRepository(this.GetUnitOfWork()); Reminder reminder = new Reminder() { DueDate = DateTime.UtcNow.AddDays(30), DueDistance = 1000, Title = "Test Reminder" }; repository.Create(this.defaultVehicle.VehicleId, reminder); var repositoryForDelete = new ReminderRepository(this.GetUnitOfWork()); Assert.Equal(1, repositoryForDelete.GetRemindersForVehicle(this.defaultVehicle.VehicleId).Count()); repositoryForDelete.Delete(reminder.ReminderId); var repositoryForVerification = new ReminderRepository(this.GetUnitOfWork()); var returnedReminders = repositoryForVerification.GetRemindersForVehicle(this.defaultVehicle.VehicleId); Assert.NotNull(returnedReminders); Assert.Equal(0, returnedReminders.Count()); }
private E_ReminderCreationStatus TryCreateReminder(ReminderModel model) { string passwordHash = Security.GetSHA1Hash(model.Password); E_ReminderCreationStatus resultStatus = E_ReminderCreationStatus.error; E_VerificationStatus verificationStatus = ReminderRepository.GetVerificationStatus(model.Email, passwordHash); int mailID = 0; DateTime nextReminder; switch (verificationStatus) { case E_VerificationStatus.emailUnknown: Guid verificationCode = Guid.NewGuid(); int emailID = ReminderRepository.InsertUnverifiedEmail(model.Email, passwordHash, verificationCode); MessageService.SendVerificationEmail(model.Email, verificationCode); nextReminder = GetNextRemindingDate(model, DateTime.Now); ReminderRepository.AddReminder(model, emailID, nextReminder); resultStatus = E_ReminderCreationStatus.successVerifyEmail; Logger.LogInfo( string.Format("unkown address remindii for:'{0}', Name: {1}" , model.Email, model.Name)); break; case E_VerificationStatus.emailNotYetVerified: mailID = ReminderRepository.GetEmailID(model.Email); nextReminder = GetNextRemindingDate(model, DateTime.Now); ReminderRepository.AddReminder(model, mailID, nextReminder); resultStatus = E_ReminderCreationStatus.successVerifyEmail; Logger.LogInfo( string.Format("not verified remindii for:'{0}', Name: {1}" , model.Email, model.Name)); break; case E_VerificationStatus.successfull: mailID = ReminderRepository.GetEmailID(model.Email); nextReminder = GetNextRemindingDate(model, DateTime.Now); ReminderRepository.AddReminder(model, mailID, nextReminder); resultStatus = E_ReminderCreationStatus.successfull; Logger.LogInfo( string.Format("verified remindii for:'{0}', Name: {1}" , model.Email, model.Name)); break; case E_VerificationStatus.wrongPassword: resultStatus = E_ReminderCreationStatus.wrongPassword; Logger.LogInfo("Wrong password for email: " + model.Email); break; } if (resultStatus == E_ReminderCreationStatus.error) { throw new ApplicationException("Fehler"); } return(resultStatus); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); //set reminder and email count for master page ViewData["ReminderCount"] = ReminderRepository.GetReminderCount(); ViewData["UserCount"] = ReminderRepository.GetUserCount(); }
public List <UtilityModel <uint> > GetReminderTypes() { using (var db = DB.GetContext()) { return(ReminderRepository.GetReminderTypes(db, isLicense: true) .Select(r => new UtilityModel <uint>(r.ReminderID, r.ReminderName)) .ToList()); } }
public ReminderUI(MainUI frmMain, Guid reminderId) { this.frmMain = frmMain; formMode = FormMode.Edit; this.reminderId = reminderId; reminderRepository = new ReminderRepository(); InitializeComponent(); }
public List <UtilityModel <uint> > GetReminderKinds() { using (var db = DB.GetContext()) { var kinds = ReminderRepository.GetReminderKinds(db); kinds.RemoveAll(r => r.Value == 3); return(kinds); } }
public ReminderRepositoryShould() { var logger = new Mock <ILogger <ReminderRepository> >(); var options = new DbContextOptionsBuilder <TodoContext>() .UseInMemoryDatabase(databaseName: "TodoDb") .Options; var context = new TodoContext(options); context.EnsureSeedData(); _reminders = new ReminderRepository(context, logger.Object); }
private ReminderEditViewModel GetReminderViewModelWithFakes() { DialogServiceDummy dialogService = new DialogServiceDummy(); DatabaseConnectionFake connectionService = new DatabaseConnectionFake(); ReminderRepository repository = new ReminderRepository(connectionService); ReminderDataService dataService = new ReminderDataService(repository); ReminderEditViewModel viewModel = new ReminderEditViewModel(dataService, dialogService); return(viewModel); }
public IEnumerable <Reminder> Get() { var tableConfiguration = new TableConfiguration { ConfigurationString = @"DefaultEndpointsProtocol=https;AccountName=grace1002;AccountKey=oxFfz+dgsWONgXbVTX0KKeH0L5X4kBANp10siMiobJTt9Q6P8TXHw9wb7RDx3f3ALwMCjS4rpYu9Zwe8trYNPg==;EndpointSuffix=core.windows.net", TableName = "Reminders" }; var repository = new ReminderRepository(tableConfiguration); return(repository.GetReminders(new DateTime(1950, 01, 01), DateTime.Now)); }
public void Post([FromBody] Reminder reminder) { var tableConfiguration = new TableConfiguration { ConfigurationString = @"DefaultEndpointsProtocol=https;AccountName=grace1002;AccountKey=oxFfz+dgsWONgXbVTX0KKeH0L5X4kBANp10siMiobJTt9Q6P8TXHw9wb7RDx3f3ALwMCjS4rpYu9Zwe8trYNPg==;EndpointSuffix=core.windows.net", TableName = "Reminders" }; var repository = new ReminderRepository(tableConfiguration); repository.AddReminder(reminder); }
public ReminderRepositoryTests() { //Connection var connection = new SqliteConnection("datasource=:memory:"); connection.Open(); //Context var builder = new DbContextOptionsBuilder <ScrumContext>().UseSqlite(connection); var context = new ScrumTestContext(builder.Options); context.Database.EnsureCreated(); _reminderRepository = new ReminderRepository(context); }
public ActionResult VerifyMailAddress(string verificationCode) { if (string.IsNullOrEmpty(verificationCode)) { return(RedirectToAction("Index")); } ViewData["VerificationSuccess"] = ReminderRepository.VerifyMailAddress(verificationCode); string msg = "Verified mail address by code: " + verificationCode; Logger.LogInfo(msg); return(View()); }
public ReminderModule( DiscordClient client, Scheduler scheduler, ReminderRepository repository ) { this._client = client; this._scheduler = scheduler; this._repository = repository; // Setup the UpdateElections function to run in the general scheduler: this._scheduler.AddTask( new TaskThunk( this.ShouldUpdateElections, this.UpdateElections ) ); }
public void WhenCreatingReminder_ThenPersists() { var repository = new ReminderRepository(); Reminder reminder = new Reminder() { DueDate = DateTime.UtcNow.AddDays(30), DueDistance = 1000, Title = "Test Reminder" }; repository.Create(defaultVehicle.VehicleId, reminder); var repositoryForVerification = new ReminderRepository(); var returnedReminder = repositoryForVerification.GetRemindersForVehicle(defaultVehicle.VehicleId).First(); Assert.NotNull(returnedReminder); Assert.Equal("Test Reminder", returnedReminder.Title); }
public async Task <IHttpActionResult> AddReminders(int id) { var order = await _repo.Get(id); if (order?.Inquiry == null) { return(NotFound()); } var reminderRepo = new ReminderRepository(); if (order.Inquiry.EventDate.HasValue) { var easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"); var date = DateTime.Parse(order.Inquiry.EventDate.Value.AddDays(-1).ToString("yyyy-MM-dd") + " 8:00 AM"); var offset = new DateTimeOffset(date, easternZone.BaseUtcOffset); var reminder = new Reminder { OrderId = id, ReminderTime = offset }; await reminderRepo.CreateReminder(reminder); if (order.Inquiry.EventTime.HasValue) { var time = new DateTime(order.Inquiry.EventTime.Value.Ticks).AddHours(-2).ToString("hh:mm tt"); date = DateTime.Parse(order.Inquiry.EventDate.Value.ToString("yyyy-MM-dd ") + time); offset = new DateTimeOffset(date, easternZone.BaseUtcOffset); reminder = new Reminder { OrderId = id, ReminderTime = offset }; await reminderRepo.CreateReminder(reminder); } } return(Ok()); }
private async Task WriteReminder(StreamWriter writer, string message, ChatReply chatReply, string replyTo, IServiceProvider services) { string username = chatReply.User.Substring(1).Split("!")[0]; string[] input = message.Split("-"); Reminder reminder = Reminder.CreateReminder(input, username, replyTo); if (reminder != null) { using var scope = services.CreateScope(); ReminderRepository repository = scope.ServiceProvider.GetRequiredService <ReminderRepository>(); Reminder newReminder = await repository.Insert(reminder); writer.WriteLine(newReminder?.GetSendMessage()); writer.Flush(); await ReminderContainer.AddReminder(reminder); } else { writer.WriteLine($"PRIVMSG {replyTo} reminder format is #y#mo#w#d#m#h#s - reminder message"); writer.Flush(); } }
public RemindMeCommands(ReminderRepository repository) { this._repository = repository; }
public ReminderRepositoryTest(DatabaseFixture fixture) { repository = new ReminderRepository(fixture.context); }
public ReminderRepositoryTest(ReminderDbFixture fixture) { repository = new ReminderRepository(fixture.context); }
public void WhenRetrievingUpcomingReminders_ThenRemindersInDueDateRangeRetrieved() { DateTime dateStart = DateTime.UtcNow; DateTime dateEnd = DateTime.UtcNow.AddDays(5); int odometer = 1000; int warningThreshold = 500; int outsideOdometerRange = odometer + warningThreshold + 1; var repository = new ReminderRepository(); // reminders just inside range var inRangeReminder1 = new Reminder() { DueDate = dateStart.AddDays(1), DueDistance = outsideOdometerRange, Title = "UpcomingReminder" }; repository.Create(defaultVehicle.VehicleId, inRangeReminder1); var inRangeReminder2 = new Reminder() { DueDate = dateEnd.AddDays(-1), DueDistance = outsideOdometerRange, Title = "UpcomingReminder1" }; repository.Create(defaultVehicle.VehicleId, inRangeReminder2); // reminders just outside of range repository.Create(defaultVehicle.VehicleId, new Reminder() { DueDate = dateStart.AddDays(-1), DueDistance = outsideOdometerRange, Title = "OutsideRangeReminder1" }); repository.Create(defaultVehicle.VehicleId, new Reminder() { DueDate = dateEnd.AddDays(1), DueDistance = outsideOdometerRange, Title = "OutsideRangeReminder2" }); var reminders = repository.GetUpcomingReminders( defaultVehicle.VehicleId, dateStart, dateEnd, odometer, warningThreshold ); Assert.Equal(2, reminders.Count()); Assert.True(reminders.Any(r => r.ReminderId == inRangeReminder1.ReminderId)); Assert.True(reminders.Any(r => r.ReminderId == inRangeReminder2.ReminderId)); }
public ReminderDaemonDataService() { _reminderRepository = new ReminderRepository(new DatabaseConnection()); }
public ReminderRepositoryTest(ReminderDbFixture _fixture) { this.fixture = _fixture; repository = new ReminderRepository(fixture.context); }