public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } if (PortaritFile != null) { string imageName = await CreatePortrait(PortaritFile, ShowModel); ShowModel.Portrait = $"/images/{imageName}.jpg"; } context.Update(ShowModel); try { await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShowModelExists(ShowModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } context.Attach(EpisodeModel).State = EntityState.Modified; try { await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EpisodeModelExists(EpisodeModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Show/Details", new { id = EpisodeModel.ShowId })); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } string imageName = await CreatePortrait(PortaritFile, ShowModel); ShowModel.Portrait = $"/images/{imageName}.jpg "; _context.Shows.Add(ShowModel); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } EpisodeModel = await context.Episodes.FindAsync(id); if (EpisodeModel != null) { context.Episodes.Remove(EpisodeModel); await context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }