/// <summary> /// Returns Jurisdiction by code. /// </summary> /// <param name="code">The jurisdiction code.</param> /// <param name="returnAllGroups">True, to return all jurisdiction groups.</param> /// <returns></returns> public static JurisdictionDto GetJurisdiction(string code, bool returnAllGroups) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = OrderCache.CreateCacheKey("jurisdiction-code", code, returnAllGroups.ToString()); JurisdictionDto dto = null; // check cache first object cachedObject = OrderCache.Get(cacheKey); if (cachedObject != null) { dto = (JurisdictionDto)cachedObject; } // Load the object if (dto == null) { DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_Jurisdiction_JurisdictionCode]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("JurisdictionCode", code, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("ReturnAllGroups", returnAllGroups, DataParameterType.Bit)); cmd.DataSet = new JurisdictionDto(); cmd.TableMapping = DataHelper.MapTables("Jurisdiction", "JurisdictionGroup", "JurisdictionRelation"); DataResult results = DataService.LoadDataSet(cmd); dto = (JurisdictionDto)results.DataSet; } return(dto); }
/// <summary> /// Gets the taxes. /// </summary> /// <param name="siteId">The site id.</param> /// <param name="taxCategory">The tax category.</param> /// <param name="languageCode">The language code.</param> /// <param name="countryCode">The country code.</param> /// <param name="stateProvinceCode">The state province code.</param> /// <param name="zipPostalCode">The zip postal code.</param> /// <param name="district">The district.</param> /// <param name="county">The county.</param> /// <param name="city">The city.</param> /// <returns></returns> public static DataTable GetTaxes( Guid siteId, string taxCategory, string languageCode, string countryCode, string stateProvinceCode, string zipPostalCode, string district, string county, string city) { DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = String.Format("ecf_GetTaxes"); cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("SiteId", siteId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("TaxCategory", taxCategory, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("LanguageCode", languageCode, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("CountryCode", countryCode, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("StateProvinceCode", stateProvinceCode, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("ZipPostalCode", zipPostalCode, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("District", district, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("County", county, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("City", city, DataParameterType.NVarChar, 50)); return(DataService.LoadTable(cmd)); }
/// <summary> /// Returns shippping method cases by shipping method id. /// </summary> /// <returns></returns> public static DataTable GetShippingMethodCases(Guid shippingMethodId) { DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_ShippingMethod_GetCases]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ShippingMethodId", shippingMethodId, DataParameterType.UniqueIdentifier)); return(DataService.LoadTable(cmd)); }
/// <summary> /// Returns shippping package by shipping option id. /// </summary> /// <returns></returns> public static ShippingMethodDto GetShippingPackages() { DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_ShippingPackage]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.DataSet = new ShippingMethodDto(); cmd.TableMapping = DataHelper.MapTables("Package"); DataResult results = DataService.LoadDataSet(cmd); return((ShippingMethodDto)results.DataSet); }
/// <summary> /// Saves the jurisdiction. /// </summary> /// <param name="dto">The dto.</param> public static void SaveJurisdiction(JurisdictionDto dto) { if (dto == null) { throw new ArgumentNullException("dto", String.Format("JurisdictionDto can not be null")); } DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); using (TransactionScope scope = new TransactionScope()) { DataHelper.SaveDataSetSimple(OrderContext.MetaDataContext, cmd, dto, "Jurisdiction", "JurisdictionGroup", "JurisdictionRelation"); scope.Complete(); } }
/// <summary> /// Saves changes in CountryDto. Not implemented! /// </summary> /// <param name="dto">The dto.</param> public static void SaveCountry(CountryDto dto) { if (dto == null) { throw new ArgumentNullException("dto", String.Format("CountryDto can not be null")); } DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); using (TransactionScope scope = new TransactionScope()) { DataHelper.SaveDataSetSimple(OrderContext.MetaDataContext, cmd, dto, "Country", "StateProvince"); scope.Complete(); } }
/// <summary> /// Gets the order status. /// </summary> /// <returns></returns> public static OrderStatusDto GetOrderStatus() { //TODO: cache results DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = String.Format("select * from OrderStatus where ApplicationId = '{0}';", OrderConfiguration.Instance.ApplicationId); cmd.CommandType = CommandType.Text; cmd.Parameters = new DataParameters(); cmd.DataSet = new OrderStatusDto(); cmd.TableMapping = DataHelper.MapTables("OrderStatus"); DataResult results = DataService.LoadDataSet(cmd); return((OrderStatusDto)results.DataSet); }
/// <summary> /// Saves the payment. /// </summary> /// <param name="dto">The dto.</param> public static void SavePayment(PaymentMethodDto dto) { if (dto == null) { throw new ArgumentNullException("dto", String.Format("PaymentMethodDto can not be null")); } DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); using (TransactionScope scope = new TransactionScope()) { DataHelper.SaveDataSetSimple(OrderContext.MetaDataContext, cmd, dto, "PaymentMethod", "PaymentMethodParameter", "ShippingPaymentRestriction"); scope.Complete(); } }
/// <summary> /// Gets the country by code. /// </summary> /// <param name="code">Country code.</param> /// <param name="returnInactive">If true, all regions will be returned, otherwise only visible.</param> /// <returns></returns> public static CountryDto GetCountry(string code, bool returnInactive) { DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_Country_Code]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("Code", code, DataParameterType.NVarChar, 3)); cmd.Parameters.Add(new DataParameter("ReturnInactive", returnInactive, DataParameterType.Bit)); cmd.DataSet = new CountryDto(); cmd.TableMapping = DataHelper.MapTables("Country", "StateProvince"); DataResult results = DataService.LoadDataSet(cmd); return((CountryDto)results.DataSet); }
/// <summary> /// Saves the package. /// </summary> /// <param name="dto">The dto.</param> public static void SavePackage(ShippingMethodDto dto) { if (dto == null) { throw new ArgumentNullException("dto", String.Format("ShippingMethodDto can not be null")); } // TODO: Check if user is allowed to perform this operation DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); using (TransactionScope scope = new TransactionScope()) { DataHelper.SaveDataSetSimple(OrderContext.MetaDataContext, cmd, dto, "Package"); scope.Complete(); } }
/// <summary> /// Returns shippping method by shipping method id. /// </summary> /// <param name="shippingMethodId">The shipping method id.</param> /// <param name="returnInactive">If true, return inactive shipping methods</param> /// <returns></returns> public static ShippingMethodDto GetShippingMethod(Guid shippingMethodId, bool returnInactive) { DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_ShippingMethod_ShippingMethodId]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("ShippingMethodId", shippingMethodId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("ReturnInactive", returnInactive, DataParameterType.Bit)); cmd.DataSet = new ShippingMethodDto(); cmd.TableMapping = DataHelper.MapTables("ShippingOption", "ShippingOptionParameter", "ShippingMethod", "ShippingMethodParameter", "ShippingMethodCase", "ShippingCountry", "ShippingRegion", "ShippingPaymentRestriction", "Package", "ShippingPackage"); DataResult results = DataService.LoadDataSet(cmd); return((ShippingMethodDto)results.DataSet); }
/// <summary> /// Gets the tax by name. /// </summary> /// <returns></returns> public static TaxDto GetTax(string name) { //TODO: cache results DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_Tax_TaxName]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("Name", name, DataParameterType.NVarChar, 50)); cmd.DataSet = new TaxDto(); cmd.TableMapping = DataHelper.MapTables("Tax", "TaxLanguage", "TaxValue"); DataResult results = DataService.LoadDataSet(cmd); return((TaxDto)results.DataSet); }
/// <summary> /// Returns shippping method cases by shipping method id. /// </summary> /// <returns></returns> public static DataTable GetShippingMethodCases(Guid shippingMethodId, string countryCode, string stateProvinceCode, string zipPostalCode, string district, string county, string city, decimal?total) { DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_ShippingMethod_GetCases]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ShippingMethodId", shippingMethodId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("CountryCode", String.IsNullOrEmpty(countryCode) ? null : countryCode, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("Total", total, DataParameterType.Money)); cmd.Parameters.Add(new DataParameter("StateProvinceCode", String.IsNullOrEmpty(stateProvinceCode) ? null : stateProvinceCode, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("ZipPostalCode", String.IsNullOrEmpty(zipPostalCode) ? null : zipPostalCode, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("District", String.IsNullOrEmpty(district) ? null : district, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("County", String.IsNullOrEmpty(county) ? null : county, DataParameterType.NVarChar, 50)); cmd.Parameters.Add(new DataParameter("City", String.IsNullOrEmpty(city) ? null : city, DataParameterType.NVarChar, 50)); return(DataService.LoadTable(cmd)); }
/// <summary> /// Returns payment method by id. /// </summary> /// <param name="paymentMethodId">PaymentMethodId</param> /// <param name="returnInactive">if set to <c>true</c> [return inactive].</param> /// <returns></returns> public static PaymentMethodDto GetPaymentMethod(Guid paymentMethodId, bool returnInactive) { //TODO: cache results DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_PaymentMethod_PaymentMethodId]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("PaymentMethodId", paymentMethodId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("ReturnInactive", returnInactive, DataParameterType.Bit)); cmd.DataSet = new PaymentMethodDto(); cmd.TableMapping = DataHelper.MapTables("PaymentMethod", "PaymentMethodParameter", "ShippingPaymentRestriction"); DataResult results = DataService.LoadDataSet(cmd); return((PaymentMethodDto)results.DataSet); }
/// <summary> /// Returns payment method by system name. /// </summary> /// <param name="name">PaymentMethod SystemKeyword</param> /// <param name="languageid">The languageid.</param> /// <param name="returnInactive">if set to <c>true</c> [return inactive].</param> /// <returns></returns> public static PaymentMethodDto GetPaymentMethodBySystemName(string name, string languageid, bool returnInactive) { //TODO: cache results DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_PaymentMethod_SystemKeyword]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("SystemKeyword", name, DataParameterType.NVarChar, 30)); cmd.Parameters.Add(new DataParameter("LanguageId", languageid, DataParameterType.NVarChar, 128)); cmd.Parameters.Add(new DataParameter("ReturnInactive", returnInactive, DataParameterType.Bit)); cmd.DataSet = new PaymentMethodDto(); cmd.TableMapping = DataHelper.MapTables("PaymentMethod", "PaymentMethodParameter", "ShippingPaymentRestriction"); DataResult results = DataService.LoadDataSet(cmd); return((PaymentMethodDto)results.DataSet); }
/// <summary> /// Gets the taxes. /// </summary> /// <returns></returns> public static TaxDto GetTaxDto(TaxType?type, string languageCode) { //TODO: cache results DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_Tax]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); if (type.HasValue) { cmd.Parameters.Add(new DataParameter("TaxType", type.Value.GetHashCode(), DataParameterType.Int)); } cmd.DataSet = new TaxDto(); cmd.TableMapping = DataHelper.MapTables("Tax", "TaxLanguage", "TaxValue"); DataResult results = DataService.LoadDataSet(cmd); return((TaxDto)results.DataSet); }
/// <summary> /// Gets the jurisdictions and jurisdiction groups for the specified jurisdiction type. /// </summary> /// <param name="jurisdictionType">JurisdictionType. 1 - tax, 2 - shipping. null - all jurisdictions.</param> /// <returns></returns> public static JurisdictionDto GetJurisdictions(JurisdictionType?jurisdictionType) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = OrderCache.CreateCacheKey("jurisdictions", jurisdictionType.HasValue ? jurisdictionType.Value.ToString() : String.Empty); JurisdictionDto dto = null; // check cache first object cachedObject = OrderCache.Get(cacheKey); if (cachedObject != null) { dto = (JurisdictionDto)cachedObject; } // Load the object if (dto == null) { DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_Jurisdiction]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); if (jurisdictionType.HasValue) { cmd.Parameters.Add(new DataParameter("JurisdictionType", jurisdictionType.Value.GetHashCode(), DataParameterType.Int)); } cmd.DataSet = new JurisdictionDto(); cmd.TableMapping = DataHelper.MapTables("Jurisdiction", "JurisdictionGroup", "JurisdictionRelation"); DataResult results = DataService.LoadDataSet(cmd); dto = (JurisdictionDto)results.DataSet; // Insert to the cache collection OrderCache.Insert(cacheKey, dto, OrderConfiguration.Instance.Cache.PaymentCollectionTimeout); } return(dto); }
/// <summary> /// Gets the shipping methods. /// </summary> /// <param name="languageid">The languageid.</param> /// <param name="returnInactive">if set to <c>true</c> [return inactive].</param> /// <returns></returns> public static ShippingMethodDto GetShippingMethods(string languageid, bool returnInactive) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = OrderCache.CreateCacheKey("shipping-methods", languageid, returnInactive.ToString()); ShippingMethodDto dto = null; // check cache first object cachedObject = OrderCache.Get(cacheKey); if (cachedObject != null) { dto = (ShippingMethodDto)cachedObject; } // Load the object if (dto == null) { DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_ShippingMethod_Language]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("LanguageId", String.IsNullOrEmpty(languageid) ? null : languageid, DataParameterType.NVarChar, 10)); cmd.Parameters.Add(new DataParameter("ReturnInactive", returnInactive, DataParameterType.Bit)); cmd.DataSet = new ShippingMethodDto(); cmd.TableMapping = DataHelper.MapTables("ShippingOption", "ShippingOptionParameter", "ShippingMethod", "ShippingMethodParameter", "ShippingMethodCase", "ShippingCountry", "ShippingRegion", "ShippingPaymentRestriction", "Package", "ShippingPackage"); DataResult results = DataService.LoadDataSet(cmd); dto = (ShippingMethodDto)results.DataSet; // Insert to the cache collection OrderCache.Insert(cacheKey, dto, OrderConfiguration.Instance.Cache.ShippingCollectionTimeout); } return(dto); }
/// <summary> /// Gets the countries. /// </summary> /// <param name="returnInactive">If true, all countries will be returned, otherwise only visible.</param> /// <returns></returns> public static CountryDto GetCountries(bool returnInactive) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = OrderCache.CreateCacheKey("countries", returnInactive.ToString()); CountryDto dto = null; // check cache first object cachedObject = OrderCache.Get(cacheKey); if (cachedObject != null) { dto = (CountryDto)cachedObject; } // Load the object if (dto == null) { DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); cmd.CommandText = "[ecf_Country]"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", OrderConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("ReturnInactive", returnInactive, DataParameterType.Bit)); cmd.DataSet = new CountryDto(); cmd.TableMapping = DataHelper.MapTables("Country", "StateProvince"); DataResult results = DataService.LoadDataSet(cmd); dto = (CountryDto)results.DataSet; // Insert to the cache collection OrderCache.Insert(cacheKey, dto, OrderConfiguration.Instance.Cache.CountryCollectionTimeout); } return(dto); }