// To protect from overposting attacks, enable the specific properties you want to bind to. // For more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Update(Series); try { await _context.SaveChangesAsync(); _logger.LogCritical($"User '{User.Identity.Name}' edited object with new values'{Series.ToString()}'."); } catch (DbUpdateConcurrencyException) { if (!SeriesExists(Series.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, enable the specific properties you want to bind to. // For more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var message = await _context.Message.FindAsync(Video.MessageId); if (message == null) { Console.Error.WriteLine("Unexpected null message with ID: " + Video.MessageId); return(Page()); } // Unlink the original message if linking to a new message if (OriginalMessageId != null) { var originalMessage = await _context.Message.FindAsync(OriginalMessageId); if (originalMessage != null && originalMessage.VideoId != message.VideoId) { originalMessage.VideoId = null; _context.Update(originalMessage); } } message.VideoId = Video.Id; _context.Update(Video); _context.Update(message); try { await _context.SaveChangesAsync(); _logger.LogCritical($"User '{User.Identity.Name}' edited object with new values'{Video.ToString()}'."); } catch (DbUpdateConcurrencyException) { if (!VideoExists(Video.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("/Messages/Details", new { id = Video.MessageId })); }
// To protect from overposting attacks, enable the specific properties you want to bind to. // For more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var series = await _context.Series.FindAsync(Playlist.SeriesId); if (series == null) { Console.Error.WriteLine("Unexpected null message with ID: " + Playlist.SeriesId); return(Page()); } // Unlink the original series if linking to a new series if (OriginalSeriesId != null) { var originalSeries = await _context.Series.FindAsync(OriginalSeriesId); if (originalSeries != null && originalSeries.PlaylistId != series.PlaylistId) { originalSeries.PlaylistId = null; _context.Update(originalSeries); } } series.PlaylistId = Playlist.Id; _context.Update(Playlist); _context.Update(series); try { await _context.SaveChangesAsync(); _logger.LogCritical($"User '{User.Identity.Name}' edited object with new values'{Playlist.ToString()}'."); } catch (DbUpdateConcurrencyException) { if (!PlaylistExists(Playlist.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Details", new { id = Playlist.Id })); }