public async Task <Course> GetCourseAsync(string courseTitle) { Guard.NotNullOrEmpty(courseTitle, nameof(courseTitle)); var filter = Builders <BsonDocument> .Filter .Eq(Fields.CourseTitle, courseTitle); var document = await _context.Courses .Find(filter) .SingleOrDefaultAsync(); if (document == null) { return(null); } return(new Course( id: FromBson.GetId(document), version: FromBson.GetVersion(document), title: FromBson.GetCourseTitle(document), teacher: FromBson.GetCourseTeacher(document), capacity: FromBson.GetCourseCapacity(document) )); }