Пример #1
0
        public async Task <IActionResult> Create([Bind("Id,Artist,ArtistPhoto,ArtistThumb")] Photo photo, IFormFile artistPhoto)
        {
            if (ModelState.IsValid)
            {
                // Handle the photo
                HandlePhoto <Photo>(photo, artistPhoto, 350);
                photo.Id = Guid.NewGuid();
                _context.Add(photo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            var chords = await _context.Chords.ToListAsync();

            var photos = await _context.Photo.ToListAsync();

            List <string> artists   = chords.Distinct().Select(x => x.Artist).ToList();
            List <string> artistsEx = photos.Distinct().Select(x => x.Artist).ToList();

            artists            = artists.Except(artistsEx).ToList();
            ViewBag.AllArtists = artists;


            return(View(photo));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Id,Artist,Song,Capo,Key,Content,DateAdded,DateEdited,Uploader")] Chords chords)
        {
            if (ModelState.IsValid)
            {
                chords.Id = Guid.NewGuid();
                // ob kreiranju nastavimo oba datuma na trenutni čas
                chords.DateAdded  = DateTime.Now;
                chords.DateEdited = DateTime.Now;
                _context.Add(chords);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(chords));
        }