Ejemplo n.º 1
0
        public async Task <IActionResult> Put(string email, string name, [FromBody] UpdateAnimal request)
        {
            if (email != await GetLoggedUserEmail())
            {
                throw new ServiceException(ErrorCodes.AnimalNotAvailable, "You can only edit animals in your account.");
            }

            await _animalService.UpdateAsync(email, name, request.Name, request.YearOfBirth);

            return(NoContent());
        }
Ejemplo n.º 2
0
        public UpdateAnimalViewModel(Animal animal, EFDbContext context)
        {
            _animal = animal;

            _kinds   = new EFRepository <AnimalKind>(context);
            _animals = new EFRepository <Animal>(context);
            _rations = new EFRepository <Ration>(context);

            sex    = (int)animal.Sex;
            ration = animal.RationId;
            kind   = animal.AnimalKindId;

            UpdateAnimal window = new UpdateAnimal(this);

            window.ShowDialog();
        }
Ejemplo n.º 3
0
        public AnimalControllerTests()
        {
            // Initializate data on start
            _existingAnimal = new CreateAnimal
            {
                Name        = "Tajger",
                YearOfBirth = 2015
            };

            _existingAnimalForDelete = new CreateAnimal
            {
                Name        = "AnimalToDelete",
                YearOfBirth = 2017
            };

            _nonExistingAnimal = new UpdateAnimal
            {
                Name        = "NonExistingAnimal",
                YearOfBirth = 1920
            };

            RegisterAnimalAsync(_existingAnimal);
            RegisterAnimalAsync(_existingAnimalForDelete);
        }