public async override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { int id = (int)context.ActionArguments.Values.FirstOrDefault(); var ogrenci = await _ogrenciService.GetByIdAsync(id); if (ogrenci != null) { await next(); } else { ErrorDto errorDto = new ErrorDto(); errorDto.Status = 404; errorDto.Errors.Add($"Id'si {id} olan ogrenci veritabanında bulunamadı."); context.Result = new NotFoundObjectResult(errorDto); } }
public async Task <IActionResult> GetById(int id) { var ogrenci = await _ogrenciService.GetByIdAsync(id); return(Ok(_mapper.Map <OgrenciDto>(ogrenci))); }