public AnimalModel AddAnimal(AnimalModel animalModel) { var animal = AnimalMapper(animalModel); _repo.AddAnimal(animal); return(animalModel); }
public async Task HandleAsync(CreateAnimalCommand command) { var allSpecies = await _speciesRepository.GetAllSpecies(); var species = allSpecies.FirstOrDefault(x => x.Name == command.Name); var animal = new Animal(command.Name, command.Age, command.Gender, species); await _repository.AddAnimal(animal); }
public async Task <IActionResult> Post(AnimalRequestDto animalDto) { var animal = _mapper.Map <AnimalRequestDto, Animal>(animalDto); await _repository.AddAnimal(animal); var animalresponseDto = _mapper.Map <Animal, AnimalResponseDto>(animal); var response = new ApiResponse <AnimalResponseDto>(animalresponseDto); return(Ok(response)); }
public override void PreformDatabaseActions() { var eggs = _eggrepo.GetEggsInNeedOfHatching(); foreach (var egg in eggs) { Animal al = egg.Hatch(); _eggrepo.Delete(egg); _animalrepo.AddAnimal(al, true); } _animalrepo.SaveChanges(); System.Diagnostics.Debug.WriteLine("Preformed Egg operation"); }
public IActionResult Add(Animal animal) { if (ModelState.IsValid) { var userAnimal = _repository.GetAnimal(animal.Id); if (userAnimal == null) { animal.UserId = _userManager.GetUserId(HttpContext.User); _repository.AddAnimal(animal); return(RedirectToAction("Index", "Animal")); } else { ModelState.AddModelError("", "Zwierzak juz istnieje"); } } ModelState.AddModelError("", "Datas are not valid"); return(View(animal)); }
public async Task AddAnimal(Animal animal) { await _repository.AddAnimal(animal); }
public async Task <IActionResult> Post(Animal animal) { await animalRepository.AddAnimal(animal); return(Ok(animal)); }
public void AddAnimal(Animal animal) { animalRepo.AddAnimal(animal); }