public HttpResponseMessage Delete(HttpRequestMessage request, int id) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { var trainerDb = _trainerService.Get(id); if (trainerDb == null) { response = request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Id."); } else { _trainerService.Delete(trainerDb); _trainerService.Save(); response = request.CreateResponse(HttpStatusCode.OK, true); } } return response; })); }
public IActionResult TrainerDelete(Trainer trainer) { _trainerService.Delete(trainer); return(RedirectToAction("Trainer")); }
public async Task <IActionResult> Delete(Guid id, CancellationToken cancellationToken = default) { await _trainerService.Delete(id, cancellationToken); return(Accepted()); }
public IActionResult DeleteConfirmed(Guid id) { _trainerService.Delete(id); return(RedirectToAction(nameof(Index))); }