예제 #1
0
        public IActionResult List(DataSourceRequest command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(Content("Access denied"));
            }

            var shippingPoints = _shippingPointService.GetAllStoreShippingPoint(storeId: "", pageIndex: command.Page - 1, pageSize: command.PageSize);
            var viewModel      = new List <ShippingPointModel>();

            foreach (var shippingPoint in shippingPoints)
            {
                var storeName = _storeService.GetStoreById(shippingPoint.StoreId);
                viewModel.Add(new ShippingPointModel
                {
                    ShippingPointName = shippingPoint.ShippingPointName,
                    Description       = shippingPoint.Description,
                    Id           = shippingPoint.Id,
                    OpeningHours = shippingPoint.OpeningHours,
                    PickupFee    = shippingPoint.PickupFee,
                    StoreName    = storeName != null ? storeName.Name : _localizationService.GetResource("Admin.Configuration.Settings.StoreScope.AllStores"),
                });
            }

            return(Json(new DataSourceResult
            {
                Data = viewModel,
                Total = shippingPoints.TotalCount
            }));
        }
        public async Task <IViewComponentResult> InvokeAsync(string shippingOption)
        {
            var parameter = shippingOption.Split(new[] { "___" }, StringSplitOptions.RemoveEmptyEntries)[0];

            if (parameter == _localizationService.GetResource("Plugins.Shipping.ShippingPoint.PluginName"))
            {
                var shippingPoints = await _shippingPointService.GetAllStoreShippingPoint(_storeContext.CurrentStore.Id);

                var shippingPointsModel = new List <SelectListItem>();
                shippingPointsModel.Add(new SelectListItem()
                {
                    Value = "", Text = _localizationService.GetResource("Plugins.Shipping.ShippingPoint.SelectShippingOption")
                });

                foreach (var shippingPoint in shippingPoints)
                {
                    shippingPointsModel.Add(new SelectListItem()
                    {
                        Value = shippingPoint.Id, Text = shippingPoint.ShippingPointName
                    });
                }

                return(View("~/Plugins/Shipping.ShippingPoint/Views/FormComboBox.cshtml", shippingPointsModel));
            }
            return(Content("ShippingPointController: given Shipping Option doesn't exist"));
        }
        public async Task <IActionResult> List(DataSourceRequest command)
        {
            var shippingPoints = await _shippingPointService.GetAllStoreShippingPoint(storeId : "", pageIndex : command.Page - 1, pageSize : command.PageSize);

            var viewModel = new List <ShippingPointModel>();

            foreach (var shippingPoint in shippingPoints)
            {
                var storeName = await _storeService.GetStoreById(shippingPoint.StoreId);

                viewModel.Add(new ShippingPointModel
                {
                    ShippingPointName = shippingPoint.ShippingPointName,
                    Description       = shippingPoint.Description,
                    Id           = shippingPoint.Id,
                    OpeningHours = shippingPoint.OpeningHours,
                    PickupFee    = shippingPoint.PickupFee,
                    StoreName    = storeName != null ? storeName.Shortcut : _translationService.GetResource("Admin.Settings.StoreScope.AllStores"),
                });
            }

            return(Json(new DataSourceResult
            {
                Data = viewModel,
                Total = shippingPoints.TotalCount
            }));
        }