Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(PerformersEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var performer = _dbContext.Performers.Find(model.Id);

                performer.Name        = model.Name;
                performer.Description = model.Description;

                try
                {
                    _dbContext.Performers.Update(performer);
                    await _dbContext.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_dbContext.Performers.Any(e => e.Id == performer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(Redirect("/Performer"));
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var performer = await _dbContext.Performers.FindAsync(id);

            if (performer == null)
            {
                return(NotFound());
            }

            var model = new PerformersEditViewModel()
            {
                Id          = performer.Id,
                Name        = performer.Name,
                Description = performer.Description,
            };

            return(View(model));
        }