public async Task <AddBreedResponse> Handle(AddBreedRequest request, CancellationToken cancellationToken) { var breed = _mapper.Map <Breed>(request); var command = new AddBreedCommand() { Parameter = breed }; var breedFromDb = await _commandExecutor.Executor(command); return(new AddBreedResponse() { Data = _mapper.Map <Domain.Models.Breed>(breedFromDb) }); }
public async Task <AddSpecieResponse> Handle(AddSpecieRequest request, CancellationToken cancellationToken) { var specie = _mapper.Map <Specie>(request); var command = new AddSpecieCommand() { Parameter = specie }; var specieFromDb = await _commandExecutor.Executor(command); return(new AddSpecieResponse() { Data = _mapper.Map <Domain.Models.Specie>(specieFromDb) }); }
public async Task <AddAnimalResponse> Handle(AddAnimalRequest request, CancellationToken cancellationToken) { var animal = _mapper.Map <Animal>(request); var command = new AddAnimalCommand() { Parameter = animal }; var animalFromDb = await _commandExecutor.Executor(command); return(new AddAnimalResponse() { Data = _mapper.Map <Domain.Models.Animal>(animalFromDb) }); }
public async Task <RemoveSpecieResponse> Handle(RemoveSpecieRequest request, CancellationToken cancellationToken) { var specie = _mapper.Map <Specie>(request); var command = new RemoveSpecieCommand() { Parameter = specie }; await _commandExecutor.Executor(command); if (specie == null) { return(new RemoveSpecieResponse() { Error = new ErrorModel(ErrorType.NotFound) }); } return(new RemoveSpecieResponse() { Data = null }); }
public async Task <UpdateSpecieResponse> Handle(UpdateSpecieRequest request, CancellationToken cancellationToken) { var specie = _mapper.Map <Specie>(request); var command = new UpdateSpecieCommand() { Parameter = specie }; var specieFromDb = await _commandExecutor.Executor(command); if (specie == null) { return(new UpdateSpecieResponse() { Error = new ErrorModel(ErrorType.NotFound) }); } return(new UpdateSpecieResponse() { Data = _mapper.Map <Domain.Models.Specie>(specieFromDb) }); }
public async Task <UpdateAnimalResponse> Handle(UpdateAnimalRequest request, CancellationToken cancellationToken) { var animal = _mapper.Map <Animal>(request); var command = new UpdateAnimalCommand() { Parameter = animal }; var animalFromDb = await _commandExecutor.Executor(command); if (animal == null) { return(new UpdateAnimalResponse() { Error = new ErrorModel(ErrorType.NotFound) }); } return(new UpdateAnimalResponse() { Data = _mapper.Map <Domain.Models.Animal>(animalFromDb) }); }
public async Task <RemoveAnimalResponse> Handle(RemoveAnimalRequest request, CancellationToken cancellationToken) { var animal = _mapper.Map <Animal>(request); var command = new RemoveAnimalCommand() { Parameter = animal }; await _commandExecutor.Executor(command); if (animal == null) { return(new RemoveAnimalResponse() { Error = new ErrorModel(ErrorType.NotFound) }); } return(new RemoveAnimalResponse() { Data = null }); }
public async Task <UpdateBreedResponse> Handle(UpdateBreedRequest request, CancellationToken cancellationToken) { var breed = _mapper.Map <Breed>(request); var command = new UpdateBreedCommand() { Parameter = breed }; var breedFromDb = await _commandExecutor.Executor(command); if (breed == null) { return(new UpdateBreedResponse() { Error = new ErrorModel(ErrorType.NotFound) }); } return(new UpdateBreedResponse() { Data = _mapper.Map <Domain.Models.Breed>(breedFromDb) }); }