Exemple #1
0
        public async override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            IEnumerable <UserModel> user = null;
            string id = null;

            if (context.ActionArguments.Values.Count() != 0)
            {
                id = (string)context.ActionArguments.Values.FirstOrDefault();

                try
                {
                    user = await _userModel.GetAsync(id);
                }
                catch (Exception)
                {
                    ErrorDto errorDto = new ErrorDto();

                    errorDto.status = 404;

                    errorDto.Errors.Add($"id'si {id} olan data veri tabanında bulunamadı");

                    context.Result = new NotFoundObjectResult(errorDto);
                }
            }


            if (id == null)
            {
                await next();
            }
            if (id != null && user != null)
            {
                await next();
            }
            //if (id != null && user.Count() > 0)
            //{
            //    await next();
            //}
            else
            {
                ErrorDto errorDto = new ErrorDto();

                errorDto.status = 404;

                errorDto.Errors.Add($"id'si {id} olan data veri tabanında bulunamadı");

                context.Result = new NotFoundObjectResult(errorDto);
            }
        }
        private async Task <IActionResult> GetPersonInfo()
        {
            var data = await _userOperationsRepository.GetAsync(null);

            return(Ok(data));
        }