public async Task <ActionResult> CategoryList(DataSourceRequest command, CategoryListModel model) { //if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) // return AccessDeniedKendoGridJson(); CategoryViewModel categoryViewModel = new CategoryViewModel(); model.Page = command.Page - 1; model.PageSize = command.PageSize; TEBApiResponse apiResponse = await Post <CategoryListModel>("/Category/CategoryList", model); if (apiResponse.IsSuccess) { List <Category> listCategories = JsonConvert.DeserializeObject <List <Category> >(Convert.ToString(apiResponse.Data)); PagedList <Category> categories = new PagedList <Category>(listCategories, 0, 10); var gridModel = new DataSourceResult(); gridModel.Data = listCategories.Select(x => { var categoryModel = CategoryMapping.ModelToView(x); return(categoryModel); }); gridModel.Total = categories.TotalCount; return(Json(gridModel)); } return(Json(0)); }
public async Task <ActionResult> Edit(int id) { CategoryViewModel model = new CategoryViewModel(); TEBApiResponse apiResponse = await Get("/Category/GetCategoryById?Id=" + id); if (apiResponse.IsSuccess) { Category product = JsonConvert.DeserializeObject <Category>(Convert.ToString(apiResponse.Data)); model = CategoryMapping.ModelToView(product); } return(View(model)); }