Example #1
0
        public async Task <IActionResult> Edit(int id)
        {
            PodCast podCastFromDb = await _mediaDbContext.PodCasts.FindAsync(id);

            PodCastEditViewmodel model = new PodCastEditViewmodel
            {
                Id          = podCastFromDb.Id,
                ReleaseDate = podCastFromDb.ReleaseDate,
                Title       = podCastFromDb.Title,
                Url         = podCastFromDb.Url,
                Guest       = podCastFromDb.Guest
            };

            return(View(model));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, PodCastEditViewmodel vm)
        {
            if (!TryValidateModel(vm))
            {
                return(View(vm));
            }

            PodCast domainFilm = await _mediaDbContext.PodCasts.FindAsync(id);

            domainFilm.Title       = vm.Title;
            domainFilm.Guest       = vm.Guest;
            domainFilm.ReleaseDate = vm.ReleaseDate;
            domainFilm.Url         = vm.Url;
            domainFilm.Host        = vm.Host;

            _mediaDbContext.Update(domainFilm);

            await _mediaDbContext.SaveChangesAsync();

            return(RedirectToAction("Detail", new { Id = id }));
        }