コード例 #1
0
        public async override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            int id      = (int)context.ActionArguments.Values.FirstOrDefault();
            var ogrenci = await _sinifService.GetByIdAsync(id);

            if (ogrenci != null)
            {
                await next();
            }
            else
            {
                ErrorDto errorDto = new ErrorDto();
                errorDto.Errors.Add($"Id'si {id} olan sinif veritabanında bulunamadı.");
                context.Result = new RedirectToActionResult("Error", "Home", errorDto);
            }
        }
コード例 #2
0
        public async Task <IActionResult> Update(int id)
        {
            var sinif = await _sinifService.GetByIdAsync(id);

            return(View(_mapper.Map <SinifDto>(sinif)));
        }