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));
        }
Пример #3
0
        public void LoadFromTrack(TrackViewModel tracky)
        {
            myTracky         = tracky;
            txtTitle.Text    = myTracky.Title;
            txtArtist.Text   = myTracky.Artist;
            txtAlbum.Text    = myTracky.Album;
            txtGenre.Text    = myTracky.Genre;
            txtYear.Text     = myTracky.Year.ToString();
            txtComposer.Text = myTracky.Composer;
            txtPath.Text     = tracky.Path;
            txtFileType.Text = new FileInfo(tracky.Path).Extension;
            txtListens.Text  = tracky.Listens.ToString();
            txtBitrate.Text  = tracky.Bitrate + "Kbps";
            txtChannels.Text = tracky.Channels.ToString();

            Thread tr = new Thread(() =>
            {
                var al = Artworks.GetAlbumArt(tracky);

                Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                {
                    imgArt.Source = al;
                }));
            });

            tr.Start();
        }
Пример #4
0
        public IgdbApi(UpdatableAppSettings settings)
        {
            this.settings         = settings;
            requestLimiterHandler = TimeLimiter
                                    .GetFromMaxCountByInterval(4, TimeSpan.FromSeconds(1))
                                    .AsDelegatingHandler();
            HttpClient = new HttpClient(requestLimiterHandler);
            HttpClient.DefaultRequestHeaders.Add("Accept", "application/json");
            CacheRoot = settings.Settings.IGDB.CacheDirectory;
            if (!Path.IsPathRooted(CacheRoot))
            {
                CacheRoot = Path.Combine(Paths.ExecutingDirectory, CacheRoot);
            }

            Games              = new Games(this);
            AlternativeNames   = new AlternativeNames(this);
            InvolvedCompanies  = new InvolvedCompanies(this);
            Genres             = new Genres(this);
            Websites           = new Websites(this);
            GameModes          = new GameModes(this);
            PlayerPerspectives = new PlayerPerspectives(this);
            Covers             = new Covers(this);
            Artworks           = new Artworks(this);
            Screenshots        = new Screenshots(this);
            AgeRatings         = new AgeRatings(this);
            Collections        = new Collections(this);
        }
        public IActionResult Activate(int id)
        {
            Artworks artwork = artworkRepository.GetArtworkById(id);

            artwork.Active = true;
            artworkRepository.UpdateArtwork(artwork);
            artworkRepository.Save();

            return(RedirectToAction("Details", new { id = artwork.Id }));
        }
        public IActionResult Download(int id)
        {
            Artworks artwork = artworkRepository.GetArtworkById(id);

            byte[] file = GenerateBarCode.GenerateQr(artwork.AccessionNumber.ToString());

            ImageConverter converte    = new ImageConverter();
            string         contentType = "application/png";

            return(File(file, contentType, "image.png"));
        }
        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 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));
        }
Пример #10
0
 public void UpdateArtwork(Artworks artwork)
 {
     context.Entry(artwork).State = EntityState.Modified;
 }
Пример #11
0
 public void InsertArtwork(Artworks artwork)
 {
     context.Artworks.Add(artwork);
 }