public IActionResult GoogleProductList(DataSourceRequest command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins)) { return(AccessDeniedKendoGridJson()); } var products = _productService.SearchProducts(pageIndex: command.Page - 1, pageSize: command.PageSize, showHidden: true); var productsModel = products .Select(x => { var gModel = new FeedGoogleShoppingModel.GoogleProductModel { ProductId = x.Id, ProductName = x.Name }; var googleProduct = _googleService.GetByProductId(x.Id); if (googleProduct != null) { gModel.GoogleCategory = googleProduct.Taxonomy; gModel.Gender = googleProduct.Gender; gModel.AgeGroup = googleProduct.AgeGroup; gModel.Color = googleProduct.Color; gModel.GoogleSize = googleProduct.Size; gModel.CustomGoods = googleProduct.CustomGoods; gModel.Cimri = googleProduct.Cimri; gModel.GoogleShop = googleProduct.GoogleShop; } return(gModel); }) .ToList(); var gridModel = new DataSourceResult { Data = productsModel, Total = products.TotalCount }; return(Json(gridModel)); }
public async Task <IActionResult> GoogleProductList(DataSourceRequest command) { if (!await _permissionService.Authorize(StandardPermissionProvider.ManagePlugins)) { return(Content("Access denied")); } var products = (await _productService.SearchProducts(pageIndex: command.Page - 1, pageSize: command.PageSize, showHidden: true)).products; var productsModel = new List <FeedGoogleShoppingModel.GoogleProductModel>(); foreach (var x in products) { var gModel = new FeedGoogleShoppingModel.GoogleProductModel { ProductId = x.Id, ProductName = x.Name }; var googleProduct = await _googleService.GetByProductId(x.Id); if (googleProduct != null) { gModel.GoogleCategory = googleProduct.Taxonomy; gModel.Gender = googleProduct.Gender; gModel.AgeGroup = googleProduct.AgeGroup; gModel.Color = googleProduct.Color; gModel.GoogleSize = googleProduct.Size; gModel.CustomGoods = googleProduct.CustomGoods; } productsModel.Add(gModel); } var gridModel = new DataSourceResult { Data = productsModel, Total = products.TotalCount }; return(new JsonResult(gridModel)); }
public ActionResult GoogleProductUpdate(FeedGoogleShoppingModel.GoogleProductModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins)) { return(Content("Access denied")); } var googleProduct = _googleService.GetByProductId(model.ProductId); if (googleProduct != null) { googleProduct.Taxonomy = model.GoogleCategory; googleProduct.Gender = model.Gender; googleProduct.AgeGroup = model.AgeGroup; googleProduct.Color = model.Color; googleProduct.Size = model.GoogleSize; googleProduct.CustomGoods = model.CustomGoods; _googleService.UpdateGoogleProductRecord(googleProduct); } else { //insert googleProduct = new GoogleProductRecord { ProductId = model.ProductId, Taxonomy = model.GoogleCategory, Gender = model.Gender, AgeGroup = model.AgeGroup, Color = model.Color, Size = model.GoogleSize, CustomGoods = model.CustomGoods }; _googleService.InsertGoogleProductRecord(googleProduct); } return(new NullJsonResult()); }