public ActionResult DeleteConfirmed(int id) { Genre genre = _genreRepository.GetEntity(id).FirstOrDefault(); _genreRepository.Delete(genre); return(RedirectToAction("Index")); }
/// <summary> /// Handling delete request and response /// </summary> /// <param name="request">Messaging.Genres.DeleteGenreRequest</param> /// <returns>Messaging.Genres.DeleteGenreResponse</returns> public DeleteGenreResponse DeleteGenre(DeleteGenreRequest request) { var response = new DeleteGenreResponse() { Request = request, ResponseToken = Guid.NewGuid() }; try { _repository.Delete( new Genre() { Id = request.Id, LastModified = DateTimeOffset.Now, UserLastModified = new Model.Users.UserInfo() { Id = request.UserId } } ); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; response.Success = false; } return(response); }
public async Task <IActionResult> Delete(int genreId) { try { var oldGenre = await _repository.GetGenreAsync(genreId); if (oldGenre == null) { return(NotFound($"Could not find genre with id of {genreId}")); } _repository.Delete(oldGenre); if (await _repository.SaveChangesAsync()) { return(Ok()); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } return(BadRequest()); }
public IActionResult DeleteGenre(string genreId) { Genre genre = genreRepository.GetAll().FirstOrDefault(g => g.Id == genreId); genreRepository.Delete(genre); return(Ok("success")); }
public bool Delete(int id) { var genre = _repository.FindById(id); _repository.Delete(genre); return(_repository.SaveChanges()); }
public ActionResult DeleteConfirmed(int id) { genreRepository.Delete(id); genreRepository.Save(); return(RedirectToAction("Index")); }
public void DeleteGenre(long id) { var genre = _genreRepository.GetById(id); _genreRepository.Delete(genre); _unitOfWork.Commit(); }
public IActionResult Delete(int id) { if (genreRepository.Delete(id)) { return(RedirectToAction("Index")); } return(View()); }
public void Should_Delete_An_Author() { _repository.Delete(2); var obj = _repository.ById(2); Assert.Null(obj); Assert.Equal(_repository.FindAll().Count(), 3); }
public IActionResult Delete(int id) { Genre genre = _genrerepo.FindById(id); _genrerepo.Delete(genre); return(RedirectToAction(nameof(Index))); }
public async Task Delete(int id) { var genre = await _genreRepository.GetById(id); if (genre == null) { throw new GenreNotFound(); } await _genreRepository.Delete(genre); }
public void Delete(int GenreID) { try { _genreRepository.Delete(GenreID); _logger.LogInformation(LoggerMessageDisplay.GenreDeleted); } catch (Exception ex) { _logger.LogInformation(LoggerMessageDisplay.GenreDeletedError, ex); } }
public ActionResult Delete(Genre genre) { try { genreRepo.Delete(genre.GenreId); return(RedirectToAction("Index")); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(RedirectToAction("Index")); } }
public async Task <ServiceResult> Delete(string id) { var serviceResult = new ServiceResult(); var result = await _genreRepository.Delete(id); serviceResult.Success = result.Success; if (!result.Success) { serviceResult.Error.Code = ErrorStatusCode.BudRequest; serviceResult.Error.Description = result.Message; } return(serviceResult); }
public ActionResult Delete(string genre, bool foo) { try { _repository.Delete(genre); return(RedirectToAction("index")); } catch (KeyNotFoundException e) { return(NotFound()); } }
public IActionResult DeleteGenre(int id) { Genre genre = _genreRepository.GetById(id); if (genre == null) { return(NotFound()); } _genreRepository.Delete(genre); _genreRepository.Save(); return(Ok(genre)); }
public async Task Delete(string genreId) { if (genreId.IsNullOrEmpty()) { throw new CustomException("genreId = null"); } var result = await _genreRepository.GetById(genreId); if (result == null) { throw new CustomException("Жанра с таким id нет"); } await _genreRepository.Delete(result); }
public ActionResult <Genre> DeleteGenre(int id) { Genre genre = _genreRepository.GetById(id); if (genre == null) { return(NotFound()); } else { _genreRepository.Delete(genre); _genreRepository.SaveChanges(); return(Ok(genre)); } }
public void Delete(int id) { if (id == null) { throw new ArgumentNullException(nameof(id)); } var genre = _genreRepository.GetById(id); if (genre is null) { throw new Exception("Genre not found"); } _genreRepository.Delete(genre); }
public HttpResponseMessage Delete(int id) { HttpResponseMessage result; try { _genreRepo.Delete(id); _genreRepo.SaveChanges(); result = Request.CreateResponse(HttpStatusCode.Accepted); } catch (Exception ex) { result = Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, ex); } return(result); }
public DeleteGenreResponse DeleteGenre(DeleteGenreRequest request) { DeleteGenreResponse response = new DeleteGenreResponse(); try { _genreRepository.Delete(request.GenreId); response.Success = true; } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); }
public async Task<ActionResult> DeleteGenreById(int id) { try { var genre = await _repository.Get<Genre>(id); if (genre == null) { return BadRequest($"Could not delete genre. Genre with Id {id} was not found."); } await _repository.Delete<Genre>(id); return NoContent(); } catch (Exception e) { var result = new { Status = StatusCodes.Status500InternalServerError, Data = $"Failed to delete the genre. Exception thrown when attempting to delete data from the database: {e.Message}"}; return this.StatusCode(StatusCodes.Status500InternalServerError,result); } }
public IActionResult DeleteConfirmed(int id) { try { if (ModelState.IsValid) { _genreRepository.Delete(id); _logger.LogInformation(LoggerMessageDisplay.GenreDeleted); } } catch (DbUpdateException ex) { _logger.LogError(LoggerMessageDisplay.GenreDeletedError + "--->" + ex); ViewBag.ErrorTitle = "Genre is in use"; ViewBag.ErrorMessage = " Genre cannot be deleted as there are games using this genre. If you want to delete this genre, please remove the games using this genre"; return(View("Error")); } return(RedirectToAction(nameof(Index))); }
public async Task <GenreResponse> DeleteAsync(int id) { var existingUser = await genreRepository.FindById(id); if (existingUser == null) { return(new GenreResponse("User not found")); } try { genreRepository.Delete(existingUser); await unitOfWork.CompleteAsync(); return(new GenreResponse(existingUser)); } catch (Exception ex) { return(new GenreResponse($"Error when deleting user: {ex.Message}")); } }
public async Task <IActionResult> Delete(int id) { try { _logger.LogInfo("Delete started"); if (id < 1) { _logger.LogWarn("Empty request"); return(BadRequest()); } var isExists = await _genreRepository.IsExists(id); if (!isExists) { _logger.LogWarn("Genre does not exists"); return(BadRequest()); } var genre = await _genreRepository.FindById(id); if (genre == null) { _logger.LogWarn("Genre not found"); return(NotFound()); } var isSuccess = await _genreRepository.Delete(genre); if (!isSuccess) { return(InternalError("Genre deletion failed")); } _logger.LogInfo("Genre deleted"); return(NoContent()); } catch (Exception ex) { return(InternalError($"Something went wrong: {ex.Message}")); } }
public async Task <ActionResult> DeleteGenre(int genreid) { try { var oldGenre = await _genreRepository.GetGenreById(genreid); if (oldGenre == null) { return(NotFound($"Could not find any genre with id: {genreid}")); } _genreRepository.Delete(oldGenre); if (await _genreRepository.Save()) { return(NoContent()); } } catch (Exception e) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database failure, could not delete item. {e.Message}")); } return(BadRequest()); }
public void DeleteGenre(int id) { _genreRepository.Delete(id); }
public void Delete(int id) { db.Delete(id); }
public void DeleteGenre(Genre delGenre) { _genreRepository.Delete(delGenre); Genres.Remove(delGenre); }
protected override async Task Handle(DeleteGenreCommand request, CancellationToken cancellationToken) { await _genreRepository.Delete(request.Genre, cancellationToken); }