Esempio n. 1
0
 private async Task <Either <Ingredient, Unit> > Validate(CreateIngredient command) =>
 (await _ingredientRepository.Get(command.Name))
 .ToEither(new Unit())
 .Swap();
Esempio n. 2
0
 public async Task <Either <string, int> > Handle(CreateIngredient command) =>
 await(await Validate(command))
 .Match <Task <Either <string, int> > >(
     async id => await _ingredientRepository.Create(new Ingredient(command.Name, command.Value)),
     (v) => Task.FromResult(new Either <string, int>($"Ja existe um ingrendient com id {v.Id}, cadastrado com o nome {command.Name}"))
     );