Пример #1
0
        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)
            });
        }
Пример #2
0
        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)
            });
        }
Пример #4
0
        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
            });
        }
Пример #5
0
        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)
            });
        }
Пример #6
0
        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)
            });
        }
Пример #7
0
        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)
            });
        }