// GET: Animal public async Task <IActionResult> Index() { var model = new AnimalListModel(); model.Animals = (await _bll.Animals.AllAsync()).Select( animal => new AnimalItemModel() { Id = animal.Id, Name = animal.Name, Image = animal.FeaturedImgId != null ? new ImageModel() { Name = animal.FeaturedImg.Name, Url = animal.FeaturedImg.Url } : new ImageModel() { Name = "", Url = "" //TODO icon or default image in no featured image is present } } ); return(View(model)); }
// GET: Animals public ActionResult Index() { using (var tinyShelterPageContext = new TinyShelterPageContext()) { var animalList = new AnimalListModel { Pet = tinyShelterPageContext.Pet.Select(p => new EntryModel { AnimalId = p.AnimalId, Name = p.Name, Type = p.Type, Age = p.Age, Description = p.Description, Date = p.Date }).ToList() }; animalList.TotalPet = animalList.Pet.Count; return(View(animalList)); } }