Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,ArtistId,GenreId")] Song song)
        {
            if (id != song.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(song);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SongExists(song.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(song));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Artist artist)
        {
            if (id != artist.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(artist);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ArtistExists(artist.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(artist));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,PostId")] Favorite favorite)
        {
            if (id != favorite.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(favorite);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FavoriteExists(favorite.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PostId"] = new SelectList(_context.Posts, "Id", "SongId", favorite.PostId);
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "UserName", favorite.UserId);
            return(View(favorite));
        }
Пример #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,SongId,ArtistId,ViewCount,YoutubeLink,PdfFilePath,Reviewed")] EditPostModel editPost)
        {
            if (id != editPost.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var post = _context.Find <Post>(editPost.Id);
                    post.Id          = editPost.Id;
                    post.ArtistId    = editPost.ArtistId;
                    post.SongId      = editPost.SongId;
                    post.ViewCount   = editPost.ViewCount;
                    post.YoutubeLink = editPost.YoutubeLink;
                    post.PdfFilePath = editPost.PdfFilePath;
                    post.Reviewed    = editPost.Reviewed;

                    _context.Update(post);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PostExists(editPost.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ArtistId"] = new SelectList(_context.Artists, "Id", "Id", editPost.ArtistId);
            ViewData["SongId"]   = new SelectList(_context.Songs, "Id", "Id", editPost.SongId);
            return(View(editPost));
        }