public ShipmentSettingsViewModel()
        {
            localSql = new ShippingMethodDataAccess();

            bool result = localSql.IsShippingMethodTableExists();

            if (!result)
            {
                NotificationHelper.ShowMessage("ShippingMethod table not found", Utilities.GetResourceValue("CaptionError"));
                return;
            }

            Responses       = new ObservableRangeCollection <ShipmentSettingsModel>();
            Carriers        = new ObservableRangeCollection <IntegerComboBoxModel>();
            SearchCarriers  = new ObservableRangeCollection <IntegerComboBoxModel>();
            SearchModel     = new ShippingMethodSearchModel();
            ShippingMethods = new List <StringComboBoxModel>();

            BindData();

            AddNewShipmentCommand = new BaseCommand(AddNewShipmentRecord);
            SaveShipmentCommand   = new BaseCommand(SaveShipments);
            ClosePopupCommand     = new BaseCommand(ClosePopup);
            ViewRecordCommand     = new BaseCommand(ViewRecord);
            FindCommand           = new BaseCommand(FindRecords);
            ResetCommand          = new BaseCommand(Reset);
        }
Пример #2
0
        public virtual IActionResult Methods(ShippingMethodSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedKendoGridJson());
            }

            //prepare model
            var model = _shippingModelFactory.PrepareShippingMethodListModel(searchModel);

            return(Json(model));
        }
Пример #3
0
        public virtual async Task <IActionResult> Methods(ShippingMethodSearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageShippingSettings))
            {
                return(await AccessDeniedDataTablesJson());
            }

            //prepare model
            var model = await _shippingModelFactory.PrepareShippingMethodListModelAsync(searchModel);

            return(Json(model));
        }
Пример #4
0
        /// <summary>
        /// Prepare shipping method search model
        /// </summary>
        /// <param name="searchModel">Shipping method search model</param>
        /// <returns>Shipping method search model</returns>
        public virtual ShippingMethodSearchModel PrepareShippingMethodSearchModel(ShippingMethodSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
Пример #5
0
        /// <summary>
        /// Prepare paged shipping method list model
        /// </summary>
        /// <param name="searchModel">Shipping method search model</param>
        /// <returns>Shipping method list model</returns>
        public virtual ShippingMethodListModel PrepareShippingMethodListModel(ShippingMethodSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get shipping methods
            var shippingMethods = _shippingService.GetAllShippingMethods().ToPagedList(searchModel);

            //prepare grid model
            var model = new ShippingMethodListModel().PrepareToGrid(searchModel, shippingMethods, () =>
            {
                return(shippingMethods.Select(method => method.ToModel <ShippingMethodModel>()));
            });

            return(model);
        }
Пример #6
0
        /// <summary>
        /// Prepare paged shipping method list model
        /// </summary>
        /// <param name="searchModel">Shipping method search model</param>
        /// <returns>Shipping method list model</returns>
        public virtual ShippingMethodListModel PrepareShippingMethodListModel(ShippingMethodSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get shipping methods
            var shippingMethods = _shippingService.GetAllShippingMethods();

            //prepare grid model
            var model = new ShippingMethodListModel
            {
                //fill in model values from the entity
                Data  = shippingMethods.PaginationByRequestModel(searchModel).Select(method => method.ToModel()),
                Total = shippingMethods.Count
            };

            return(model);
        }
Пример #7
0
        private static SqlResult PrepareQuery(ShippingMethodSearchModel searchModel)
        {
            Query query = new Query("ShippingMethod as S").Select("ShippingMethodId", "EcommerceShippingMethod", "ERPShippingMethod", "Description", "IsEcommerceDefault", "IsErpDefault");

            query.Join("ShippingCarrier as C", "S.CarrierId", "C.CarrierId").Select("C.CarrierDescription", "C.CarrierId");
            if (!string.IsNullOrEmpty(searchModel.ErpShippingMethod))
            {
                query.WhereLike("S.ERPShippingMethod", "%" + searchModel.ErpShippingMethod + "%");
            }
            if (!string.IsNullOrEmpty(searchModel.EcommerceShippingMethod))
            {
                query.WhereLike("S.EcommerceShippingMethod", "%" + searchModel.EcommerceShippingMethod + "%");
            }
            if (searchModel.CarrierId > 0)
            {
                query.Where("S.CarrierId", searchModel.CarrierId);
            }

            query.OrderBy("C.CarrierDescription");
            query.OrderBy("S.ShippingMethodId");
            return(new SqlServerCompiler().Compile(query));
        }
Пример #8
0
        public IList <ShipmentSettingsModel> GetShipmentMethodsList(ShippingMethodSearchModel searchModel)
        {
            var shipmentMethodDetails = new List <ShipmentSettingsModel>();

            using (var connection = new SqlConnection(Constants.ConnectorDatabase))
            {
                SqlResult sqlResult = PrepareQuery(searchModel);

                using (var command = new SqlCommand(sqlResult.Sql, connection))
                {
                    connection.Open();

                    foreach (KeyValuePair <string, object> resultBinding in sqlResult.Bindings)
                    {
                        command.Parameters.AddWithValue(resultBinding.Key, resultBinding.Value);
                    }

                    using (SqlDataReader dataReader = command.ExecuteReader())
                    {
                        while (dataReader.Read())
                        {
                            shipmentMethodDetails.Add(new ShipmentSettingsModel
                            {
                                ShipmentMethodId   = Convert.ToInt32(dataReader["ShippingMethodId"], Constants.DefaultCulture),
                                MagentoShipmentId  = dataReader["EcommerceShippingMethod"].ToString(),
                                GpShipmentId       = dataReader["ERPShippingMethod"].ToString(),
                                Description        = dataReader["Description"].ToString(),
                                CarrierName        = dataReader["CarrierDescription"].ToString(),
                                CarrierId          = Convert.ToInt32(dataReader["CarrierId"], Constants.DefaultCulture),
                                IsEcommerceDefault = !dataReader.IsDBNull(4) && dataReader.GetBoolean(4),
                                IsErpDefault       = !dataReader.IsDBNull(5) && dataReader.GetBoolean(5)
                            });
                        }
                    }
                }
            }
            return(shipmentMethodDetails);
        }
Пример #9
0
        /// <summary>
        /// Prepare shipping method search model
        /// </summary>
        /// <param name="searchModel">Shipping method search model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the shipping method search model
        /// </returns>
        public virtual Task <ShippingMethodSearchModel> PrepareShippingMethodSearchModelAsync(ShippingMethodSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(Task.FromResult(searchModel));
        }
 private void Reset()
 {
     SearchModel = new ShippingMethodSearchModel();
     BindShippingMethods();
 }