public async Task ReadDocumentById() { //Init var id = _sampleDocumentId; //Action var document = await _reader.GetAsync(id); //Assert Assert.IsNotNull(document); Assert.AreEqual(id, document.Id); }
public static async Task <TView> GetOrNewAsync <TView>(this IDocumentReader <unit, TView> reader) where TView : new() { var entityMaybe = await reader.GetAsync(unit.it).ConfigureAwait(false); return(entityMaybe.GetValue(new TView())); }
public override async Task <CommandResult> ProcessAsync(UpdateQuestion command) { var originalQuestion = await _reader.GetAsync(command.UpdatedQuestion.Id); if (originalQuestion == null) { throw new DomainValidationException(command.Id, "This question doesn't exist", 15) { Suggestion = "Create this question as a new question" } } ; var question = _domainValidator.FromDto(command.UpdatedQuestion, command.Id); question.Update(originalQuestion.Id, originalQuestion.CreatedBy, originalQuestion.CreatedOn, command.UpdatedQuestion.LastModifiedBy); var document = _dtoParser.Create(question); await _writer.CreateOrUpdateAsync(document); return(new IdentityResult(command.Id, originalQuestion.Id)); } }
public static async Task <TEntity> LoadAsync <TKey, TEntity>(this IDocumentReader <TKey, TEntity> self, TKey key) { var entityMaybe = await self.GetAsync(key).ConfigureAwait(false); if (entityMaybe.HasValue) { return(entityMaybe.Value); } var txt = string.Format("Failed to load '{0}' with key '{1}'.", typeof(TEntity).Name, key); throw new InvalidOperationException(txt); }
public async Task <List <CategoryDto> > GetAsync() { return(await _reader.GetAsync()); }
public static Task <Maybe <TSingleton> > GetAsync <TSingleton>(this IDocumentReader <unit, TSingleton> reader) { return(reader.GetAsync(unit.it)); }
public async Task <List <QuestionDto> > GetAsync() { return(await _reader.GetAsync()); }