public async Task <bool> Handle(SyncDatabaseCommand request, CancellationToken cancellationToken) { var reportIds = _CourseQuery.GetItems(new[] { "id" }).Result.Select(i => Guid.Parse(i.Id)); var syncCourse = await _CourseRepository .GetCourses(i => i.Updated >= request.LastExecution || !reportIds.Contains(i.Id) ); foreach (var item in syncCourse) { await _CourseQuery.RemoveItem(item.Id.ToString()); await _CourseQuery.AddItem(_Mapper.Map <Course>(item)); } return(true); }
public async Task <IEnumerable <SimpleCourse> > Handle(CourseListQuery request, CancellationToken cancellationToken) { var list = await _ReadDatabase.GetItems(new[] { "id", "Capacity", "Title", "MaxAge", "MinAge", "AvgAge", "EnrollmentCount" }); return(list as IEnumerable <SimpleCourse>); }