public IActionResult Edit(ArtworkVM model) { if (!ModelState.IsValid) { model.Artist = new SelectList(artistRepository.GetArtists(), "Id", "Name"); model.ArtworkType = new SelectList(artworkTypeRepository.GetArtworkTypes(), "Id", "Name"); model.Country = new SelectList(countryRepository.GetCountries(), "Id", "Name"); model.Material = new SelectList(materialRepository.GetMaterials(), "Id", "Name"); model.Style = new SelectList(styleRepository.GetStyles(), "Id", "Name"); return(View("Add", model)); } Artworks a = new Artworks(); a.Id = model.Id; a.AccessionNumber = model.AccessionNumber; a.Active = true; a.ArtistId = model.ArtistId; a.ArtworkTypeId = model.ArtworkTypeId; a.CatalogueEntry = model.CatalogueEntry; a.CountryId = model.CountryId; a.Date = model.Date; a.MaterialId = model.MaterialId; a.MuseumId = model.MuseumId; a.Name = model.Name; a.Provenance = model.Provenance; a.StyleId = model.StyleId; artworkRepository.UpdateArtwork(a); artworkRepository.Save(); return(RedirectToAction("Details", new { id = a.Id })); }
public IActionResult GetArtwork(int id) { Artworks a = artworkRepository.GetArtworkById(id); ArtworkVM model = new ArtworkVM(); model.AccessionNumber = a.AccessionNumber; model.Active = a.Active; model.ArtistId = a.ArtistId; model.ArtworkTypeId = a.ArtworkTypeId; model.CatalogueEntry = a.CatalogueEntry; model.CountryId = a.CountryId; model.Date = a.Date; model.Id = a.Id; model.MaterialId = a.MaterialId; model.MuseumId = a.MuseumId; model.Name = a.Name; model.Provenance = a.Provenance; model.StyleId = a.StyleId; model.Images = null; model.Artist = new SelectList(artistRepository.GetArtists(), "Id", "Name"); model.ArtworkType = new SelectList(artworkTypeRepository.GetArtworkTypes(), "Id", "Name"); model.Country = new SelectList(countryRepository.GetCountries(), "Id", "Name"); model.Material = new SelectList(materialRepository.GetMaterials(), "Id", "Name"); model.Style = new SelectList(styleRepository.GetStyles(), "Id", "Name"); return(View("Edit", model)); }
public IActionResult Details(int id) { Artists a = artistRepository.GetArtistById(id); ArtistVM model = new ArtistVM(); model.Artworks = new List <ArtworkVM>(); model.Styles = new List <string>(); List <Artworks> artworks = artworkRepository.GetArtworksByArtist(a.Id); foreach (Artworks art in artworks) { ArtworkVM vm = new ArtworkVM(); vm.Id = art.Id; vm.Name = art.Name; vm.Artist = a.Name; vm.Image = imageRepository.GetArtworkImage(art.Id); vm.Museum = art.Museum.Name; if (vm.Image != null) { vm.ImageId = vm.Image.Id; } vm.Likes = likesRepository.GetLikes(a.Id); if (Autentification.GetLoggedUser(HttpContext) != null) { Clients c = clientRepository.GetClientByUserId(Autentification.GetLoggedUser(HttpContext).Id); vm.Liked = likesRepository.IsLiked(c.Id, a.Id); } else { vm.Liked = false; } model.Artworks.Add(vm); } model.Biography = a.Biography; model.Born = a.Born; model.Country = a.Country.Name; model.Died = a.Died; model.Id = a.Id; model.Image = imageRepository.GetArtistImage(a.Id); if (model.Image != null) { model.ImageId = model.Image.Id; } model.Images = imageRepository.GetArtistImages(a.Id); model.Name = a.Name; IEnumerable <ArtistMovements> movements = stylesRepository.GetArtistMovementsByArtist(a.Id); foreach (ArtistMovements am in movements) { string style = am.Style.Name; model.Styles.Add(style); } return(View("Details", model)); }
public IActionResult Add() { int id = Autentification.GetLoggedUser(HttpContext).Id; Museums m = museumRepository.GetMuseumByAccId(id); ArtworkVM model = new ArtworkVM(); model.Artist = new SelectList(artistRepository.GetArtists(), "Id", "Name"); model.ArtworkType = new SelectList(artworkTypeRepository.GetArtworkTypes(), "Id", "Name"); model.Country = new SelectList(countryRepository.GetCountries(), "Id", "Name"); model.Material = new SelectList(materialRepository.GetMaterials(), "Id", "Name"); model.Style = new SelectList(styleRepository.GetStyles(), "Id", "Name"); model.MuseumId = m.Id; return(View("Add", model)); }
public IActionResult Get(int id) { //int c = Int32.Parse(id); Artworks a = artworkRepository.ScanTickets(id); if (a != null) { ArtworkVM model = new ArtworkVM(); model.Id = a.Id; model.Artist = a.Artist.Name; model.Description = a.CatalogueEntry; model.Material = a.Material.Name; model.Name = a.Name; model.Style = a.Style.Name; model.Type = a.ArtworkType.Name; model.Year = a.Date; return(Ok(model)); } return(Ok()); }
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)); }
public IActionResult Details(int id) { Artworks a = artworkRepository.GetArtworkById(id); Museums m = museumRepository.GetMuseum(a.MuseumId); ArtworkVM model = new ArtworkVM(); model.AccessionNumber = a.AccessionNumber; model.Active = a.Active; model.ArtistId = a.ArtistId; model.ArtworkTypeId = a.ArtworkTypeId; model.CatalogueEntry = a.CatalogueEntry; model.CountryId = a.CountryId; model.Date = a.Date; model.Id = a.Id; model.MaterialId = a.MaterialId; model.MuseumId = a.MuseumId; model.Name = a.Name; model.Provenance = a.Provenance; model.StyleId = a.StyleId; model.Artist_S = a.Artist.Name; model.ArtworkType_S = a.ArtworkType.Name; model.Country_S = a.Country.Name; model.Material_S = a.Material.Name; model.Style_S = a.Style.Name; model.Images = imageRepository.GetArtworkImages(a.Id); model.Artist = new SelectList(artistRepository.GetArtists(), "Id", "Name"); model.ArtworkType = new SelectList(artworkTypeRepository.GetArtworkTypes(), "Id", "Name"); model.Country = new SelectList(countryRepository.GetCountries(), "Id", "Name"); model.Material = new SelectList(materialRepository.GetMaterials(), "Id", "Name"); model.Style = new SelectList(styleRepository.GetStyles(), "Id", "Name"); ViewData["download"] = m.QrScanning; return(View("Details", model)); }
public IActionResult Details(int id) { Artworks x = artworkRepository.GetArtworkById(id); ArtworkVM vm = new ArtworkVM(); vm.Id = x.Id; vm.Artist = x.Artist.Name; vm.ArtworkType = x.ArtworkType.Name; vm.ArtworkTypeId = x.ArtworkTypeId; vm.CatalogueEntry = x.CatalogueEntry; vm.Country = x.Country.Name; vm.Image = imageRepository.GetArtworkImage(x.Id); if (vm.Image != null) { vm.ImageId = vm.Image.Id; } vm.Likes = likesRepository.GetLikes(x.Id); vm.Material = x.Material.Name; vm.Museum = x.Museum.Name; vm.MuseumId = x.MuseumId; vm.Name = x.Name; vm.Provenance = x.Provenance; vm.Style = x.Style.Name; vm.Images = imageRepository.GetArtworkImages(x.Id); if (Autentification.GetLoggedUser(HttpContext) != null) { Clients c = clientRepository.GetClientByUserId(Autentification.GetLoggedUser(HttpContext).Id); vm.Liked = likesRepository.IsLiked(c.Id, x.Id); } else { vm.Liked = false; } return(View(vm)); }
public IActionResult Index() { UserAccounts u = Autentification.GetLoggedUser(HttpContext); Administrators admin = null; Museums museum = null; if (u != null) { if (adminRepository.GetAdministrator(u.Id) != null) { admin = adminRepository.GetAdministrator(u.Id); } if (museumRepository.GetMuseumByAccId(u.Id) != null) { museum = museumRepository.GetMuseumByAccId(u.Id); } } if (admin != null) { return(RedirectToAction("Index", "Home", new { area = "Administrator" })); } else if (museum != null) { return(RedirectToAction("Index", "Home", new { area = "Moderator" })); } else { HomeVM model = new HomeVM(); List <Museums> list = museumRepository.GetTop3(); model.Museums = new List <MuseumVM>(); model.Artworks = new List <ArtworkVM>(); model.News = new List <NewsVM>(); List <Artworks> artworks = artworkRepository.GetTop6(); List <News> news = newsRepository.GetLatest(); foreach (Museums x in list) { MuseumVM m = new MuseumVM(); m.Id = x.Id; m.Description = x.Description; m.Image = imageRepository.GetMuseumImage(x.Id); m.Name = x.Name; if (m.Image != null) { m.ImageId = m.Image.Id; } model.Museums.Add(m); } foreach (Artworks x in artworks) { ArtworkVM a = new ArtworkVM(); a.Id = x.Id; a.Name = x.Name; a.Artist = x.Artist.Name; a.Museum = x.Museum.Name; a.Image = imageRepository.GetArtworkImage(x.Id); if (a.Image != null) { a.ImageId = a.Image.Id; } model.Artworks.Add(a); } foreach (News x in news) { NewsVM n = new NewsVM(); n.Id = x.Id; n.Date = x.Date; n.Image = imageRepository.GetNewsImage(x.Id); if (n.Image != null) { n.ImageId = n.Image.Id; } n.Museum = x.Museum.Name; n.Subtitle = x.SubTitle; n.Text = x.Text; n.Title = x.Title; model.News.Add(n); } return(View("Index", model)); } }
public IActionResult Details(int id) { Museums m = museumRepository.GetMuseum(id); MuseumVM model = new MuseumVM(); model.Id = m.Id; model.Address = m.Address; model.Description = m.Description; model.Email = m.Email; if (model.Image != null) { model.ImageId = model.Image.Id; } model.Images = imageRepository.GetMuseumImages(id); model.Latitude = m.Latitude; model.Longitude = m.Longitude; model.Image = imageRepository.GetMuseumImage(m.Id); model.Name = m.Name; model.OpeningYear = m.OpeningYear; model.Phone = m.Phone; model.TicketSelling = m.OnlineTickets; model.Type = m.MuseumType.Name; model.UserId = m.UserId; List <Artworks> artworks = artworkRepository.GetArtworksByMuseum(m.Id); model.Artworks = new List <ArtworkVM>(); foreach (Artworks a in artworks) { ArtworkVM vm = new ArtworkVM(); vm.Artist = a.Artist.Name; vm.ArtworkType = a.ArtworkType.Name; vm.ArtworkTypeId = a.ArtworkTypeId; vm.Country = a.Country.Name; vm.Id = a.Id; vm.Image = imageRepository.GetArtworkImage(a.Id); if (vm.Image != null) { vm.ImageId = vm.Image.Id; } vm.Name = a.Name; vm.MuseumId = a.MuseumId; model.Artworks.Add(vm); } List <News> news = newsRepository.GetNews(m.Id); model.News = new List <NewsVM>(); foreach (News x in news) { NewsVM n = new NewsVM(); n.Id = x.Id; n.Date = x.Date; n.Image = imageRepository.GetNewsImage(x.Id); if (n.Image != null) { n.ImageId = n.Image.Id; } n.Museum = x.Museum.Name; n.Subtitle = x.SubTitle; n.Text = x.Text; n.Title = x.Title; model.News.Add(n); } model.Collections = collectionRepository.GetCollections(m.Id); model.Events = eventRepository.GetEvents(m.Id); model.TicketTypes = tickettypeRepository.GetTicketTypes(m.Id); model.WorkingHours = workinghoursRepository.GetWorkingHours(m.Id); model.Review = new Reviews(); model.Review.MuseumId = m.Id; return(View("Details", model)); }
public IActionResult Index(int page = 1) { List <Artworks> list = artworkRepository.GetArtworks(); List <ArtworkVM> model = new List <ArtworkVM>(); const int PageSize = 12; var count = list.Count(); if (page == 1) { list = list.Skip(0).Take(PageSize).ToList(); } else { list = list.Skip((page - 1) * PageSize).Take(PageSize).ToList(); } if (count <= PageSize) { ViewBag.MaxPage = 1; } else { if (count % PageSize == 0) { ViewBag.MaxPage = (count / PageSize); } else { ViewBag.MaxPage = (count / PageSize) + 1; } } ViewBag.Page = page; ViewBag.NextPage = page + 1; foreach (Artworks x in list) { ArtworkVM vm = new ArtworkVM(); vm.Id = x.Id; vm.Artist = x.Artist.Name; vm.ArtworkType = x.ArtworkType.Name; vm.ArtworkTypeId = x.ArtworkTypeId; vm.CatalogueEntry = x.CatalogueEntry; vm.Country = x.Country.Name; vm.Image = imageRepository.GetArtworkImage(x.Id); if (vm.Image != null) { vm.ImageId = vm.Image.Id; } vm.Likes = likesRepository.GetLikes(x.Id); vm.Material = x.Material.Name; vm.Museum = x.Museum.Name; vm.MuseumId = x.MuseumId; vm.Name = x.Name; vm.Provenance = x.Provenance; vm.Style = x.Style.Name; if (Autentification.GetLoggedUser(HttpContext) != null) { Clients c = clientRepository.GetClientByUserId(Autentification.GetLoggedUser(HttpContext).Id); vm.Liked = likesRepository.IsLiked(c.Id, x.Id); } else { vm.Liked = false; } model.Add(vm); } return(View(model)); }