Ejemplo n.º 1
0
        public ActionResult CreateAnimal(AnimalCreateModel model)
        {
            model.ShelterId = _shelterId;
            var result = _animalRepository.CreateAnimal(model);

            if (result.IsError)
            {
                return(BadRequest(result.Message));
            }

            return(Ok(result.Data.Id));
        }
Ejemplo n.º 2
0
        public ActionResult EditAnimalDetails([FromQuery] int animalId, [FromBody] AnimalCreateModel model)
        {
            var access = _accessValidator.CheckAnimalAccess(animalId);

            if (!access)
            {
                return(Forbid());
            }

            var result = _animalRepository.EditAnimalDetails(animalId, model);

            return(ResponseToActionResult(result));
        }
Ejemplo n.º 3
0
        public ResponseResult EditAnimalDetails(int animalId, AnimalCreateModel model)
        {
            var animal = _dbContext.Animals.Find(animalId);

            animal.Name                 = model.Name;
            animal.Specie               = model.Specie;
            animal.Age                  = model.Age;
            animal.Gender               = model.Gender;
            animal.IsSterilized         = model.IsSterilized;
            animal.IsGoodWithChildren   = model.IsGoodWithChildren;
            animal.IsGoodWithCats       = model.IsGoodWithCats;
            animal.IsGoodWithDogs       = model.IsGoodWithDogs;
            animal.IsVaccinated         = model.IsVaccinated;
            animal.IsRequiredExperience = model.IsRequiredExperience;
            animal.IsDangerous          = model.IsDangerous;

            var descriptionFilePath = @$ "AnimalDescription\{animal.Id}.txt";