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))); }
public async Task <IActionResult> Update(int id) { var category = await _categoryApiService.GetByIdAsync(id); await _categoryApiService.Update(category); //return RedirectToAction("Index"); return(View(category)); }
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); } }
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); } }
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); } }
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); } }
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); } }
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)); }