public PartialViewResult Index(int id) { List <ArtworkCollections> model = artworkCollectionRepository.GetArtworkCollections(id); List <ArtworkInfoVM> list = new List <ArtworkInfoVM>(); foreach (ArtworkCollections x in model) { ArtworkInfoVM vm = new ArtworkInfoVM(); vm.Id = x.ArtworkId; vm.Artist = x.Artwork.Artist.Name; vm.ArtistId = x.Artwork.ArtistId; vm.Likes = likesRepository.GetLikes(x.Id); vm.Name = x.Artwork.Name; vm.Image = imageRepository.GetArtworkImage(x.ArtworkId); if (vm.Image != null) { vm.ImageId = vm.Image.Id; } list.Add(vm); } return(PartialView("Index", list)); }
public IActionResult Collection(int id) { Collections c = collectionRepository.GetCollectionById(id); CollectionVM model = new CollectionVM(); model.Artworks = new List <ArtworkVM>(); List <ArtworkCollections> artworks = artworkcollectionRepository.GetArtworkCollections(c.Id); foreach (ArtworkCollections art in artworks) { ArtworkVM vm = new ArtworkVM(); vm.Id = art.ArtworkId; vm.Name = art.Artwork.Name; vm.Artist = art.Artwork.Artist.Name; vm.Image = imageRepository.GetArtworkImage(art.ArtworkId); vm.Museum = art.Artwork.Museum.Name; if (vm.Image != null) { vm.ImageId = vm.Image.Id; } vm.Liked = false; model.Artworks.Add(vm); } model.Image = c.Image; if (model.Image != null) { model.ImageId = model.Image.Id; } model.Description = c.Description; model.Id = c.Id; model.MuseumId = c.MuseumId; model.Name = c.Name; return(View("Collection", model)); }