public ActionResult AdvertisementList(DataSourceRequest command, AdvertisementListModel model) { var ads = _advertisementService.SearchAdvertisements( storeId: model.SearchStoreId, vendorId: model.SearchVendorId, keywords: model.SearchAdvertisementName, pageIndex: command.Page - 1, pageSize: command.PageSize); var gridModel = new DataSourceResult(); gridModel.Data = ads.Select(x => { var adModel = new ModelsMapper().CreateMap<Advertisement, AdvertisementModel>(x); //little hack here: //ensure that product full descriptions are not returned //otherwise, we can get the following error if products have too long descriptions: //"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. " //also it improves performance adModel.Description = string.Empty; //picture //var defaultProductPicture = _pictureService.GetPicturesByProductId(x.Id, 1).FirstOrDefault(); //adModel.PictureThumbnailUrl = _pictureService.GetPictureUrl(defaultProductPicture, 75, true); ////product type //adModel.ProductTypeName = x.ProductType.GetLocalizedEnum(_localizationService, _workContext); ////friendly stock qantity ////if a simple product AND "manage inventory" is "Track inventory", then display //if (x.ProductType == ProductType.SimpleProduct && x.ManageInventoryMethod == ManageInventoryMethod.ManageStock) // adModel.StockQuantityStr = x.GetTotalStockQuantity().ToString(); return adModel; }); gridModel.Total = ads.TotalCount; return Json(gridModel); }
public ActionResult List() { var model = new AdvertisementListModel(); return View(model); }