public ActionResult Index() { try { if (_animalService.GetAll().Where(a => !_adotanteService.GetAll().Any(e => e.AnimalId == a.Id)).Count() > 1) { ViewBag.menssageanimalantigo = _animalService.GetAll().Where(a => !_adotanteService.GetAll().Any(e => e.AnimalId == a.Id)).FirstOrDefault().Nome; } else { ViewBag.menssageanimalantigo = null; } ViewBag.menssageanimalnovo = _animalService.GetAll().Where(a => !_adotanteService.GetAll().Any(e => e.AnimalId == a.Id)).LastOrDefault().Nome; } catch (Exception) { ViewBag.menssageanimalantigo = null; ViewBag.menssageanimalnovo = null; } try { ViewBag.menssagenomeadotante = _adotanteService.GetAll().LastOrDefault().Pessoa.Nome; ViewBag.menssagenomeanimal = _adotanteService.GetAll().LastOrDefault().Animal.Nome; } catch (Exception) { ViewBag.menssagenomeadotant = null; ViewBag.menssagenomeanimal = null; } return(View()); }
public OperationResult <List <AdoptionContract> > GetAll() { try { var animals = _animalService.GetAll() .Result .Where(x => x.AdoptedBy != null) .ToList(); var adoptions = new List <AdoptionContract>(); foreach (var item in animals) { adoptions.Add(new AdoptionContract() { Adopter = _adopterService.Get(item.AdoptedBy.Value).Result, Animal = item, }); } return(new OperationResult <List <AdoptionContract> >(true, "Success", adoptions)); } catch (Exception e) { return(new OperationResult <List <AdoptionContract> >(false, e.Message, null)); } }
public ActionResult All(string sortOrder, string currentFilter, string searchString, int?page) { ViewBag.CurrentSort = sortOrder; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; var result = animals.GetAll().ProjectTo <AnimalsListView>(); if (!string.IsNullOrEmpty(searchString)) { result = result .Where(a => a.Name.ToLower().Contains(searchString.ToLower())); } int pageNumber = (page ?? 1); var sorted = this.Sorted(result, sortOrder); return(View(sorted.ToPagedList(pageNumber, ControllersConst.PageSizeOrg))); }
public IActionResult Get() { var animalModels = _animalService .GetAll() .ToApiModels(); return(Ok(animalModels)); }
public IActionResult Create() { var vm = new TreatmentViewModel() { Animals = _animalService.GetAll().ToList() }; return(View(vm)); }
// GET: Adotante public ActionResult Index() { if (Session["usuarioLogadoID"] != null) { var animaldisponivel = _animalService.GetAll().Where(a => !_adotanteService.GetAll().Any(e => e.AnimalId == a.Id)); if (animaldisponivel.ToList().Count() == 0) { ViewBag.Message = "Não Existem Animais Disponíveis Para Adoção! Parabéns!"; } return(View(_adotanteService.GetAll())); } else { return(RedirectToAction("login", "Home")); } }
// GET: Adotante public ActionResult Index() { if (Session["usuarioLogadoID"] != null) { var animaldisponivel = _animalService.GetAll().Where(a => !_adotanteService.GetAll().Any(e => e.AnimalId == a.Id)); if (animaldisponivel.ToList().Count() == 0) { ViewBag.Message = "Não há animais para adotar!"; } return(View(_adotanteService.GetAll())); } else { return(RedirectToAction("login", "Home")); } // var adotantes = db.Adotantes.Include(a => a.Animal).Include(a => a.Pessoa); }
public IActionResult Index() { var vm = new StayViewModel() { Stays = _stayService.GetAll().ToList(), Animals = _animalService.GetAll().ToList(), Lodges = _lodgingService.GetAll().ToList() }; return(View(vm)); }
public ActionResult <IEnumerable <AnimalDTO> > Get() { try { return(Ok(_service.GetAll())); } catch (NullDataException ex) { return(NotFound(ex.Message)); } }
public IActionResult Get() { try { var animales = animalService.GetAll(); return(Ok(animales)); } catch (Exception ex) { throw ex; } }
// GET: Animal public ActionResult Index() { if (Session["usuarioLogadoID"] != null) { var animaldisponivel = _animalService.GetAll().Where(a => !_adotanteService.GetAll().Any(e => e.AnimalId == a.Id)); //var animais = db.Animais.Include(a => a.Especie); return(View(animaldisponivel.ToList())); } else { return(RedirectToAction("login", "Home")); } }
public void DeveObterTodosOsAnimaisCadastrados_RetornarAnimais() { var idUsuario = Guid.NewGuid(); var usuario = UsuarioFactory.CriarUmUsuarioValido(idUsuario); var usuarioViewModel = UsuarioViewModelFactory.CriarUmUsuarioValido(idUsuario); var listaDeAnimalDomain = new List <Animal> { AnimalFactory.CriarUmAnimal(usuario) }; var listaDeAnimalViewModel = new List <AnimalViewModel> { AnimalViewModelFactory.CriarUmAnimal(usuarioViewModel) }; _animalService.GetAll().Returns(listaDeAnimalDomain); _mapper.Map <IEnumerable <AnimalViewModel> >(listaDeAnimalDomain).Returns(listaDeAnimalViewModel); var retorno = animalAppService.GetAll(); Assert.IsNotNull(retorno); Assert.AreEqual(listaDeAnimalViewModel, retorno); _animalService.Received().GetAll(); _mapper.Received().Map <IEnumerable <AnimalViewModel> >(listaDeAnimalDomain); }
public IActionResult Index() { return(Ok(_animalService.GetAll())); }
public ActionResult Get() { var animals = _animalService.GetAll(); return(Ok(animals)); }
public JsonResult GetAll() { var result = _animalService.GetAll(); return(Json(result, JsonRequestBehavior.AllowGet)); }
public IEnumerable <AnimalViewModel> GetAll() { return(_mapper.Map <IEnumerable <AnimalViewModel> >(_animalService.GetAll())); }
public async Task <IActionResult> Get() { var animals = await _animalService.GetAll(); return(Ok(animals)); }
public async Task <IEnumerable <AnimalDto> > GetAnimals() { return(await _animalService.GetAll()); }
public IActionResult Index() { // TODO create custom viewModel return(View(_animalService.GetAll())); }
public IActionResult GetAnimals() { return(Ok(_animalService.GetAll())); }