Example #1
0
 public EitherAsync <DatabaseFailure, Unit> Update(TodoItemDto todoItem) =>
 TryAsync(() => _todoCollection.UpdateOneAsync(x => x.Id == todoItem.Id, Updater(todoItem)).ToUnit())
 .ToEither()
 .MapLeft(DatabaseFailureCon.Update);
Example #2
0
 private static UpdateDefinition <TodoItemDto> Updater(TodoItemDto dto) => Builders <TodoItemDto> .Update
 .Set(x => x.Content, dto.Content)
 .Set(x => x.IsDone, dto.IsDone);
Example #3
0
 public EitherAsync <DatabaseFailure, Unit> Add(TodoItemDto todoItem) =>
 TryAsync(() => _todoCollection.InsertOneAsync(todoItem).ToUnit())
 .ToEither()
 .MapLeft(DatabaseFailureCon.Insert);