public async Task <IActionResult> Update(int id)
        {
            // var category = await _categoryService.GetEntityAsync(id);

            var category = await _categoryApiService.GetByIdAsync(id);

            return(View(_mapper.Map <CategoryDto>(category)));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Update(int id)
        {
            var category = await _categoryApiService.GetByIdAsync(id);

            await _categoryApiService.Update(category);

            //return RedirectToAction("Index");
            return(View(category));
        }
Ejemplo n.º 3
0
        public async override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            int id      = (int)context.ActionArguments.Values.FirstOrDefault();
            var product = await _categoryApiService.GetByIdAsync(id);

            if (product != null)
            {
                await next();
            }
            else
            {
                ErrorDto errorDto = new ErrorDto();
                errorDto.Errors.Add($"Id'si {id} olan kategori veritabanın'da bulunamadı.");
                context.Result = new RedirectToActionResult("Error", "Home", errorDto);
            }
        }
Ejemplo n.º 4
0
        public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            int id = (int)context.ActionArguments.Values.FirstOrDefault();

            CategoryDto category = await _categoryApiService.GetByIdAsync(id);

            if (category != null)
            {
                await next();
            }
            else
            {
                ErrorDto errorDto = new ErrorDto();
                errorDto.Errors.Add($"ID`si {id} olan kategori bulunamamistir.");
                context.Result = new RedirectToActionResult("Error", "Home", errorDto);
            }
        }
Ejemplo n.º 5
0
        public async override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            int id      = (int)context.ActionArguments.Values.FirstOrDefault();
            var product = await _categoryApiService.GetByIdAsync(id);

            if (product != null)
            {
                await next();
            }
            else
            {
                ErrorDto errorDto = new ErrorDto();
                errorDto.Status = 404;
                errorDto.Errors.Add($"id'si {id} olan ürün bulunamadı.");

                context.Result = new NotFoundObjectResult(errorDto);
            }
        }
Ejemplo n.º 6
0
        public async override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            // ** method that take id parameters in product has one value so FirstOrDefault() will work.
            int id = (int)context.ActionArguments.Values.FirstOrDefault();

            var product = await _categoryApiService.GetByIdAsync(id);

            if (product != null)
            {
                await next();
            }
            else
            {
                ErrorDto errorDto = new ErrorDto();
                errorDto.Errors.Add($"CategoryId = {id} was not found in the Database.");
                context.Result = new RedirectToActionResult("Error", "Home", errorDto);
            }
        }
Ejemplo n.º 7
0
        public async override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            int id = (int)context.ActionArguments.Values.FirstOrDefault();

            var product = await _categoryApiService.GetByIdAsync(id);

            if (product != null)
            {
                await next();
            }

            else
            {
                ErrorDto error = new ErrorDto();
                error.Errors.Add($"id {id} was not found in DB ");

                context.Result = new RedirectToActionResult("Error", "Home", error);
            }
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Update(int id)
        {
            var category = await _categoryApiService.GetByIdAsync(id);

            return(View(category));
        }
        public IActionResult Update(int id)
        {
            var category = _categoryApiService.GetByIdAsync(id).Result;

            return(View(category));
        }