Example #1
0
        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"));
        }
Example #2
0
        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 }));
        }
Example #3
0
        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"));
        }
Example #4
0
        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"));
        }