Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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)));
        }
Exemplo n.º 4
0
        public IActionResult Get()
        {
            var animalModels = _animalService
                               .GetAll()
                               .ToApiModels();

            return(Ok(animalModels));
        }
Exemplo n.º 5
0
        public IActionResult Create()
        {
            var vm = new TreatmentViewModel()
            {
                Animals = _animalService.GetAll().ToList()
            };

            return(View(vm));
        }
Exemplo n.º 6
0
        // 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"));
            }
        }
Exemplo n.º 7
0
        // 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);
        }
Exemplo n.º 8
0
        public IActionResult Index()
        {
            var vm = new StayViewModel()
            {
                Stays   = _stayService.GetAll().ToList(),
                Animals = _animalService.GetAll().ToList(),
                Lodges  = _lodgingService.GetAll().ToList()
            };

            return(View(vm));
        }
Exemplo n.º 9
0
 public ActionResult <IEnumerable <AnimalDTO> > Get()
 {
     try
     {
         return(Ok(_service.GetAll()));
     }
     catch (NullDataException ex)
     {
         return(NotFound(ex.Message));
     }
 }
Exemplo n.º 10
0
 public IActionResult Get()
 {
     try
     {
         var animales = animalService.GetAll();
         return(Ok(animales));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 11
0
 // 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"));
     }
 }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
 public IActionResult Index()
 {
     return(Ok(_animalService.GetAll()));
 }
Exemplo n.º 14
0
        public ActionResult Get()
        {
            var animals = _animalService.GetAll();

            return(Ok(animals));
        }
Exemplo n.º 15
0
        public JsonResult GetAll()
        {
            var result = _animalService.GetAll();

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
 public IEnumerable <AnimalViewModel> GetAll()
 {
     return(_mapper.Map <IEnumerable <AnimalViewModel> >(_animalService.GetAll()));
 }
Exemplo n.º 17
0
        public async Task <IActionResult> Get()
        {
            var animals = await _animalService.GetAll();

            return(Ok(animals));
        }
Exemplo n.º 18
0
 public async Task <IEnumerable <AnimalDto> > GetAnimals()
 {
     return(await _animalService.GetAll());
 }
Exemplo n.º 19
0
 public IActionResult Index()
 {
     // TODO create custom viewModel
     return(View(_animalService.GetAll()));
 }
Exemplo n.º 20
0
 public IActionResult GetAnimals()
 {
     return(Ok(_animalService.GetAll()));
 }