hadizolfi
پنج شنبه 06 آذر 1393, 21:51 عصر
از شما دوستان کسی هست که با فروشگاه ساز های رایگان smartstore/nopcommerce استفاده کرده باشه
من چند تا سئوال درباره این دو فروشگاه ساز ها دارم....
1- میخوام قیمت های اونو از دلار به ریال تبدیل کنم...سورس خود برنامه به این صورت هست:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using SmartStore.Core;
using SmartStore.Core.Caching;
using SmartStore.Core.Data;
using SmartStore.Core.Domain.Directory;
using SmartStore.Core.Domain.Localization;
using SmartStore.Core.Domain.Stores;
using SmartStore.Core.Domain.Tax;
using SmartStore.Core.Infrastructure;
using SmartStore.Core.Plugins;
using SmartStore.Services.Catalog;
using SmartStore.Services.Customers;
using SmartStore.Services.Directory;
using SmartStore.Services.Localization;
using SmartStore.Tests;
using NUnit.Framework;
using Rhino.Mocks;
using SmartStore.Services.Stores;
namespace SmartStore.Services.Tests.Catalog
{
[TestFixture]
public class PriceFormatterTests : ServiceTest
{
IRepository<Currency> _currencyRepo;
IStoreMappingService _storeMappingService;
ICurrencyService _currencyService;
CurrencySettings _currencySettings;
IWorkContext _workContext;
ILocalizationService _localizationService;
TaxSettings _taxSettings;
IPriceFormatter _priceFormatter;
[SetUp]
public new void SetUp()
{
var cacheManager = new NullCache();
_workContext = null;
_currencySettings = new CurrencySettings();
var currency1 = new Currency
{
Id = 1,
Name = "Euro",
CurrencyCode = "EUR",
DisplayLocale = "",
CustomFormatting = "0:N0",
DisplayOrder = 1,
Published = true,
CreatedOnUtc = DateTime.UtcNow,
UpdatedOnUtc= DateTime.UtcNow
};
var currency2 = new Currency
{
Id = 1,
Name = "US Dollar",
CurrencyCode = "USD",
DisplayLocale = "en-US",
CustomFormatting = "0:N0",
DisplayOrder = 2,
Published = true,
CreatedOnUtc = DateTime.UtcNow,
UpdatedOnUtc= DateTime.UtcNow
};
_currencyRepo = MockRepository.GenerateMock<IRepository<Currency>>();
_currencyRepo.Expect(x => x.Table).Return(new List<Currency>() { currency1, currency2 }.AsQueryable());
_storeMappingService = MockRepository.GenerateMock<IStoreMappingService>();
var pluginFinder = new PluginFinder();
_currencyService = new CurrencyService(cacheManager, _currencyRepo, _storeMappingService,
_currencySettings, pluginFinder, null, this.ProviderManager);
_taxSettings = new TaxSettings();
_localizationService = MockRepository.GenerateMock<ILocalizationService>();
_localizationService.Expect(x => x.GetResource("Products.InclTaxSuffix", 1, false)).Return("{0} incl tax");
_localizationService.Expect(x => x.GetResource("Products.ExclTaxSuffix", 1, false)).Return("{0} ");
_priceFormatter = new PriceFormatter(_workContext, _currencyService,_localizationService, _taxSettings);
}
[Test]
public void Can_formatPrice_with_custom_currencyFormatting()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
var currency = new Currency()
{
Id = 1,
Name = "Euro",
CurrencyCode = "EUR",
DisplayLocale = "",
CustomFormatting = "0:N0"
};
var language = new Language()
{
Id = 1,
Name = "English",
LanguageCulture = "en-US"
};
_priceFormatter.FormatPrice(1234.5M, false, currency, language, false, false).ShouldEqual("€234,000");
}
[Test]
public void Can_formatPrice_with_distinct_currencyDisplayLocal e()
{
var usd_currency = new Currency()
{
Id = 1,
Name = "US Dollar",
CurrencyCode = "USD",
DisplayLocale = "en-US",
};
var rub_currency = new Currency()
{
Id = 2,
Name = "Russian Ruble",
CurrencyCode = "RUB",
DisplayLocale = "ru-RU",
};
var language = new Language()
{
Id = 1,
Name = "English",
LanguageCulture = "en-US"
};
_priceFormatter.FormatPrice(1234.5M, true, usd_currency, language, false, false).ShouldEqual("$1,234");
_priceFormatter.FormatPrice(1234.5M, true, rub_currency, language, false, false).ShouldEqual("1 234р.");
}
[Test]
public void Can_formatPrice_with_showTax()
{
var currency = new Currency()
{
Id = 1,
Name = "US Dollar",
CurrencyCode = "USD",
DisplayLocale = "en-US",
};
var language = new Language()
{
Id = 1,
Name = "English",
LanguageCulture = "en-US"
};
_priceFormatter.FormatPrice(1234.5M, true, currency, language, true, true).ShouldEqual("$1,234 incl tax");
_priceFormatter.FormatPrice(1234.5M, true, currency, language, false, true).ShouldEqual("$1,234 ");
}
[Test]
public void Can_formatPrice_with_showCurrencyCode()
{
var currency = new Currency()
{
Id = 1,
Name = "US Dollar",
CurrencyCode = "USD",
DisplayLocale = "en-US",
};
var language = new Language()
{
Id = 1,
Name = "English",
LanguageCulture = "en-US"
};
_priceFormatter.FormatPrice(1234.5M, true, currency, language, false, false).ShouldEqual("$1,234");
}
}
}
من چند تا سئوال درباره این دو فروشگاه ساز ها دارم....
1- میخوام قیمت های اونو از دلار به ریال تبدیل کنم...سورس خود برنامه به این صورت هست:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using SmartStore.Core;
using SmartStore.Core.Caching;
using SmartStore.Core.Data;
using SmartStore.Core.Domain.Directory;
using SmartStore.Core.Domain.Localization;
using SmartStore.Core.Domain.Stores;
using SmartStore.Core.Domain.Tax;
using SmartStore.Core.Infrastructure;
using SmartStore.Core.Plugins;
using SmartStore.Services.Catalog;
using SmartStore.Services.Customers;
using SmartStore.Services.Directory;
using SmartStore.Services.Localization;
using SmartStore.Tests;
using NUnit.Framework;
using Rhino.Mocks;
using SmartStore.Services.Stores;
namespace SmartStore.Services.Tests.Catalog
{
[TestFixture]
public class PriceFormatterTests : ServiceTest
{
IRepository<Currency> _currencyRepo;
IStoreMappingService _storeMappingService;
ICurrencyService _currencyService;
CurrencySettings _currencySettings;
IWorkContext _workContext;
ILocalizationService _localizationService;
TaxSettings _taxSettings;
IPriceFormatter _priceFormatter;
[SetUp]
public new void SetUp()
{
var cacheManager = new NullCache();
_workContext = null;
_currencySettings = new CurrencySettings();
var currency1 = new Currency
{
Id = 1,
Name = "Euro",
CurrencyCode = "EUR",
DisplayLocale = "",
CustomFormatting = "0:N0",
DisplayOrder = 1,
Published = true,
CreatedOnUtc = DateTime.UtcNow,
UpdatedOnUtc= DateTime.UtcNow
};
var currency2 = new Currency
{
Id = 1,
Name = "US Dollar",
CurrencyCode = "USD",
DisplayLocale = "en-US",
CustomFormatting = "0:N0",
DisplayOrder = 2,
Published = true,
CreatedOnUtc = DateTime.UtcNow,
UpdatedOnUtc= DateTime.UtcNow
};
_currencyRepo = MockRepository.GenerateMock<IRepository<Currency>>();
_currencyRepo.Expect(x => x.Table).Return(new List<Currency>() { currency1, currency2 }.AsQueryable());
_storeMappingService = MockRepository.GenerateMock<IStoreMappingService>();
var pluginFinder = new PluginFinder();
_currencyService = new CurrencyService(cacheManager, _currencyRepo, _storeMappingService,
_currencySettings, pluginFinder, null, this.ProviderManager);
_taxSettings = new TaxSettings();
_localizationService = MockRepository.GenerateMock<ILocalizationService>();
_localizationService.Expect(x => x.GetResource("Products.InclTaxSuffix", 1, false)).Return("{0} incl tax");
_localizationService.Expect(x => x.GetResource("Products.ExclTaxSuffix", 1, false)).Return("{0} ");
_priceFormatter = new PriceFormatter(_workContext, _currencyService,_localizationService, _taxSettings);
}
[Test]
public void Can_formatPrice_with_custom_currencyFormatting()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
var currency = new Currency()
{
Id = 1,
Name = "Euro",
CurrencyCode = "EUR",
DisplayLocale = "",
CustomFormatting = "0:N0"
};
var language = new Language()
{
Id = 1,
Name = "English",
LanguageCulture = "en-US"
};
_priceFormatter.FormatPrice(1234.5M, false, currency, language, false, false).ShouldEqual("€234,000");
}
[Test]
public void Can_formatPrice_with_distinct_currencyDisplayLocal e()
{
var usd_currency = new Currency()
{
Id = 1,
Name = "US Dollar",
CurrencyCode = "USD",
DisplayLocale = "en-US",
};
var rub_currency = new Currency()
{
Id = 2,
Name = "Russian Ruble",
CurrencyCode = "RUB",
DisplayLocale = "ru-RU",
};
var language = new Language()
{
Id = 1,
Name = "English",
LanguageCulture = "en-US"
};
_priceFormatter.FormatPrice(1234.5M, true, usd_currency, language, false, false).ShouldEqual("$1,234");
_priceFormatter.FormatPrice(1234.5M, true, rub_currency, language, false, false).ShouldEqual("1 234р.");
}
[Test]
public void Can_formatPrice_with_showTax()
{
var currency = new Currency()
{
Id = 1,
Name = "US Dollar",
CurrencyCode = "USD",
DisplayLocale = "en-US",
};
var language = new Language()
{
Id = 1,
Name = "English",
LanguageCulture = "en-US"
};
_priceFormatter.FormatPrice(1234.5M, true, currency, language, true, true).ShouldEqual("$1,234 incl tax");
_priceFormatter.FormatPrice(1234.5M, true, currency, language, false, true).ShouldEqual("$1,234 ");
}
[Test]
public void Can_formatPrice_with_showCurrencyCode()
{
var currency = new Currency()
{
Id = 1,
Name = "US Dollar",
CurrencyCode = "USD",
DisplayLocale = "en-US",
};
var language = new Language()
{
Id = 1,
Name = "English",
LanguageCulture = "en-US"
};
_priceFormatter.FormatPrice(1234.5M, true, currency, language, false, false).ShouldEqual("$1,234");
}
}
}