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; })); }
// GET: Trainers/Details/5 public IActionResult Details(Guid id) { if (id == null || id == Guid.Empty) { return(NotFound()); } var trainer = _trainerService.Get(id); if (trainer == null) { return(NotFound()); } ResultViewModel <TrainerDto> resultViewModel = AutoMapper.Mapper.Map <ResultHandler <TrainerDto>, ResultViewModel <TrainerDto> >(trainer); return(View(resultViewModel)); }
public async Task <IActionResult> Get(Guid id, CancellationToken cancellationToken = default) { return(Ok(await _trainerService.Get(id, cancellationToken))); }