public Task <ActivityFinishedInfo> CreateActivityFinishedInfoAsync(ActivityFinishedInfo newActivityFinishedInfo) { if (newActivityFinishedInfo == null) { throw new ArgumentNullException(); } activityFinishedInfo.InsertOne(newActivityFinishedInfo); return(Task.FromResult(newActivityFinishedInfo)); }
public Task UpdateAsync(ActivityFinishedInfo info) { var newActivityFinishedInfo = new ActivityFinishedInfo() { Id = info.Id, ActivityId = info.ActivityId, Title = info.Title, Description = info.Description, IsChecked = true }; activityFinishedInfo.ReplaceOne(user => user.Id == info.Id, newActivityFinishedInfo); return(Task.CompletedTask); }
public async void GenerateEventOfEndActivityAsync() { var dateOfLastCheckedActivity = await settingsRepository.GetLastActivitySettings(); var activities = await activityRepository.GetAsync(); foreach (var activity in activities) { if (dateOfLastCheckedActivity == null) { break; } if (activity.EndAt.CompareTo(dateOfLastCheckedActivity.DateOfLastCheckedActivity) > 0 && activity.EndAt.CompareTo(DateTime.Now) < 0) { var maraphoneByActivity = await maraphoneRepository.GetAsync(activity.MaraphoneId, CancellationToken.None); var activityFinishedInfo = new ActivityFinishedInfo() { ActivityId = activity.Id, Title = maraphoneByActivity.Title, Description = maraphoneByActivity.Description, IsChecked = false }; await activityFinishedInfoRepository.CreateActivityFinishedInfoAsync(activityFinishedInfo); } } var settingOfActivityFinishedInfo = new SettingsEventOfActivity() { DateOfLastCheckedActivity = DateTime.Now }; await settingsRepository.CreateLastActivitySettings(settingOfActivityFinishedInfo); }