Example #1
0
        public IActionResult Edit(int id, Genre genre)
        {
            if (id != genre.Id)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(genre));
            }

            try
            {
                _genreRepo.Update(genre);
                _genreRepo.Save();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GenreExists(genre.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
        public IActionResult PutGenreEntity(int id, GenreCreateDto genreEntity)
        {
            if (id != genreEntity.GenreId)
            {
                return(BadRequest());
            }

            _repository.Update(id, _mapper.Map <GenreEntity>(genreEntity));

            if (!_repository.Save())
            {
                throw new Exception("Failed on save");
            }

            return(NoContent());
        }