public void Not_Add_Book_When_Not_Exist_In_DB() { //Arrange var basketByNames = new string[] { "Test", "Test" }; var catalogCollection = new List <Catalog>() { new Catalog("Test1", "Test", 3, 5), new Catalog("Test2", "Test", 3, 5) }; var myDBMock = new Mock <IMyDB>(); myDBMock.Setup(x => x.Catalogs).Returns(catalogCollection); var catalogService = new CatalogService(myDBMock.Object); var categoryService = new CategoryService(myDBMock.Object); var CommonService = new CommonService(categoryService, catalogService); //Act var result = CommonService.GetBooks(basketByNames); //Assert Assert.AreEqual(0, result.Count); }
protected string RenderLabels(int productId, bool recomend, bool sales, bool best, bool news, float discount, int labelCount = 5) { var labels = _customLabels.Where(l => l.ProductIds.Contains(productId)).Select(l => l.LabelCode).ToList(); return(CatalogService.RenderLabels(recomend, sales, best, news, discount, labelCount, labels)); }
public static string BuildTaxTable(List <OrderTax> taxes, float currentCurrencyRate, string currentCurrencyIso3, string message) { var sb = new StringBuilder(); if (!taxes.Any()) { sb.Append("<tr><td style=\"padding-right: 3px; height: 20px; width: 100%; text-align: right;\"><strong>"); sb.Append(message); sb.Append( " </strong></td><td style=\"white-space: nowrap; padding-right: 5px; height: 20px; text-align: right;\"><span class=\"currency\">"); sb.Append(CatalogService.GetStringPrice(0, currentCurrencyRate, currentCurrencyIso3)); sb.Append("</span></td></tr>"); } else { foreach (OrderTax tax in taxes) { sb.Append( "<tr><td style=\"padding-right: 3px; height: 20px; width: 100%; text-align: right;\"><strong>"); sb.Append((tax.TaxShowInPrice ? Resource.Core_TaxServices_Include_Tax : "") + " " + tax.TaxName); sb.Append( ": </strong></td><td style=\"white-space: nowrap; padding-right: 5px; height: 20px; text-align: right;\"><span class=\"currency\">"); sb.Append(CatalogService.GetStringPrice(tax.TaxSum, currentCurrencyRate, currentCurrencyIso3)); sb.Append("</span></td></tr>"); } } return(sb.ToString()); }
public CatalogServiceClient() { stub = new CatalogService(); stub.Credentials = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD); stub.PreAuthenticate = true; stub.Url = WEBSERVICE_URL; }
private async void mi_delete_Click(object sender, RoutedEventArgs e) { CatalogModel model = this.TreeModel.GetCurrentSelect(); if (model != null) { if (model.ParentId == null) { MessageBox.Show("不允许删除根目录", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (MessageBox.Show($"将要删除目录<{model.Name}>,确认操作吗?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) == MessageBoxResult.Yes) { Catalog catalog = ObjectMapper.Map <CatalogModel, Catalog>(model); try { await CatalogService.Delete(catalog); this.TreeModel.RemoveModel(model); CatalogModel parentModel = this.TreeModel.GetModelById(model.ParentId); parentModel.IsSelected = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButton.OK, MessageBoxImage.Error); } } } }
public CatalogServiceTests() { randomizer = new Fixture(); randomizer.Behaviors.OfType <ThrowingRecursionBehavior>().ToList() .ForEach(b => randomizer.Behaviors.Remove(b)); randomizer.Behaviors.Add(new OmitOnRecursionBehavior()); workContextAccessor = new Mock <IWorkContextAccessor>(); categoriesApi = new Mock <ICatalogModuleCategories>(); productsApi = new Mock <ICatalogModuleProducts>(); searchApi = new Mock <ICatalogModuleSearch>(); pricingService = new Mock <IPricingService>(); customerService = new Mock <IMemberService>(); subscriptionService = new Mock <ISubscriptionService>(); inventoryService = new Mock <IInventoryService>(); memoryCache = new Mock <IStorefrontMemoryCache>(); apiChangesWatcher = new Mock <IApiChangesWatcher>(); customerReviewService = new Mock <ICustomerReviewService>(); service = new CatalogService( workContextAccessor.Object, categoriesApi.Object, productsApi.Object, searchApi.Object, pricingService.Object, customerService.Object, subscriptionService.Object, inventoryService.Object, memoryCache.Object, apiChangesWatcher.Object, customerReviewService.Object); }
public void SetUp() { apiClient = new Mock <IApiClient>(); cache = new Mock <ICache>(); logger = new Mock <ILogger>(); sut = new CatalogService(apiClient.Object, cache.Object, logger.Object); catalog = new Catalog { Products = new [] { new Product { Name = "Name1", Description = "Description1" }, new Product { Name = "Name2", Description = "Description2" } } }; }
private async void TreeViewItem_Drop(object sender, DragEventArgs e) { this.SetDefaultColor(e.OriginalSource); CatalogModel sourceModel = e.Data.GetData(typeof(CatalogModel)) as CatalogModel; FrameworkElement targetElement = e.OriginalSource as FrameworkElement; CatalogModel targetModel = targetElement == null ? null : targetElement.DataContext as CatalogModel; if (!this.TreeModel.IsCanDrop(sourceModel, targetModel)) { return; } Catalog sourceCatalog = ObjectMapper.Map <CatalogModel, Catalog>(sourceModel); sourceCatalog.ParentId = targetModel.Id; try { await CatalogService.Update(sourceCatalog); this.TreeModel.MoveModel(sourceModel, targetModel); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButton.OK, MessageBoxImage.Error); } finally { e.Handled = true; } }
public void TestReadCsv() { var catalogReposityMock = new Mock<ICatalogRepository>(); var eventBrokerMock = new Mock<IEventBroker>(); var catalog = new SupplierCatalog(); catalog.Id = 1; catalogReposityMock.Setup(x => x.FindById(1)) .Returns(catalog); var catalogService = new CatalogService(eventBrokerMock.Object, catalogReposityMock.Object); var filePath = @"Resources\Hardware.csv"; catalogService.ProcessAction(new ImportHardwareCommand(1, filePath)); catalogReposityMock.Verify(x => x.Save(catalog)); Assert.AreEqual(2, catalog.Hardwares.Count); Assert.AreEqual(2, catalog.Hardwares[0].Components.Count); Assert.AreEqual(4, catalog.Supplies.Count); eventBrokerMock.Verify(x => x.Publish(It.IsAny<HardwareCreatedEvent>()), Times.Exactly(2)); eventBrokerMock.Verify(x => x.Publish(It.IsAny<SupplyCreatedEvent>()), Times.Exactly(4)); }
private static string BuildTaxTable(ICollection <OrderTax> taxes, OrderCurrency currency) { var sb = new StringBuilder(); if (taxes.Count != 0) { foreach (var tax in taxes) { sb.Append( "<tr bgcolor=\"white\" runat=\"server\" id=\"rowNDS\"><td align=\"right\" width=\"82%\"><font class=\"sc\">"); sb.Append((tax.TaxShowInPrice ? Resource.Core_TaxServices_Include_Tax : "") + " " + tax.TaxName); sb.Append(":</font></td><td align=\"right\" width=\"18%\"><font class=\"sc\"><b>"); sb.Append(CatalogService.GetStringPrice(tax.TaxSum, currency.CurrencyValue, currency.CurrencyCode)); sb.Append("</b></font></td></tr>"); } } else { sb.Append( "<tr bgcolor=\"white\" runat=\"server\" id=\"rowNDS\"><td align=\"right\" width=\"82%\"><font class=\"sc\">"); sb.Append(Resource.Client_Bill2_NDSAlreadyIncluded); sb.Append("</font></td><td align=\"right\" width=\"18%\"><font class=\"sc\"><b>"); sb.Append("Без НДС"); sb.Append("</b></font></td></tr>"); } return(sb.ToString()); }
private Control GetTableRadioButton(ShippingListItem shippingListItem) { var tr = new HtmlTableRow(); var td = new HtmlTableCell(); if (divScripts.Visible == false) { divScripts.Visible = shippingListItem.Ext != null && shippingListItem.Ext.Type == ExtendedType.Pickpoint; } var radioButton = new RadioButton { GroupName = "ShippingRateGroup", ID = PefiksId + shippingListItem.Id //+ "|" + shippingListItem.Rate }; if (String.IsNullOrEmpty(_selectedID.Value.Replace(PefiksId, string.Empty))) { _selectedID.Value = radioButton.ID; } radioButton.Checked = radioButton.ID == _selectedID.Value; radioButton.Attributes.Add("onclick", "setValue(this)"); string strShippingPrice = CatalogService.GetStringPrice(shippingListItem.Rate, Currency.Value, Currency.Iso3); radioButton.Text = string.Format("{0} <span class='price'>{1}</span>", shippingListItem.MethodNameRate, strShippingPrice); if (shippingListItem.Ext != null && shippingListItem.Ext.Type == ExtendedType.Pickpoint) { string temp; if (shippingListItem.Ext.Pickpointmap.IsNotEmpty()) { temp = string.Format(",{{city:'{0}', ids:null}}", shippingListItem.Ext.Pickpointmap); } else { temp = string.Empty; } radioButton.Text += string.Format( "<br/><div id=\"address\">{0}</div><a href=\"#\" onclick=\"PickPoint.open(SetPickPointAnswer{1});return false\">" + "{2}</a><input type=\"hidden\" name=\"pickpoint_id\" id=\"pickpoint_id\" value=\"\" /><br />", pickAddress.Value, temp, Resources.Resource.Client_OrderConfirmation_Select); } using (var img = new Image { ImageUrl = ShippingIcons.GetShippingIcon(shippingListItem.Type, shippingListItem.IconName, shippingListItem.MethodNameRate) }) { td.Controls.Add(img); } td.Controls.Add(radioButton); tr.Controls.Add(td); return(tr); }
public void Return_Correct_Price_When_Pass_One_Book() { //Arrange var rules = new HashSet <ICalculatePriceRule>() { new SinglePriceRule() }; var dbCatalog = new DB.Catalog("TEST1", "TEST1", 4, 4); var dbCollectionCategory = new List <DB.Category>() { new DB.Category("TEST1", 0.1) }; var dbCollection = new List <DB.Catalog>() { dbCatalog }; var myDbMock = new Mock <IMyDB>(); myDbMock.Setup(x => x.Catalogs).Returns(dbCollection); myDbMock.Setup(x => x.Categories).Returns(dbCollectionCategory); var categoryService = new CategoryService(myDbMock.Object); var catalogService = new CatalogService(myDbMock.Object); var commonServiceMock = new CommonService(categoryService, catalogService); var store = new Store(commonServiceMock, categoryService, catalogService, rules); //Act var result = store.Buy("TEST1"); //Assert Assert.AreEqual(4, result); }
private void Seed() { if (Page.ClientQueryString.Contains("seed=true")) { CatalogService.Seed(); } }
protected string RenderPriceTag(int productId, float price, float discount, float multiPrice, bool showBonuses = false) { float totalDiscount = discount != 0 ? discount : _discountByTime; if (_productDiscountModels != null) { var prodDiscount = _productDiscountModels.Find(d => d.ProductId == productId); if (prodDiscount != null) { totalDiscount = prodDiscount.Discount; } } string productPrice; if (multiPrice == 0) { productPrice = CatalogService.RenderPrice(price, totalDiscount, false, customerGroup); } else { productPrice = Resource.Client_Catalog_From + " " + CatalogService.RenderPrice(price, totalDiscount, false, customerGroup, isWrap: true); } var bonusesPrice = showBonuses ? GetBonusPrice(price, totalDiscount) : string.Empty; return(productPrice + bonusesPrice); }
protected string RenderPrice(decimal productPrice, decimal discount) { if (productPrice == 0) { return(string.Format("<div class=\'price\'>{0}</div>", Resource.Client_Catalog_ContactWithUs)); } string res; decimal price = ProductService.CalculateProductPrice(productPrice, discount, customerGroup, null, false); decimal priceWithDiscount = ProductService.CalculateProductPrice(productPrice, discount, customerGroup, null, true); if (price.Equals(priceWithDiscount)) { res = string.Format("<div class=\'price\'>{0}</div>", CatalogService.GetStringPrice(price)); } else { res = string.Format("<div class=\"price-old\">{0}</div><div class=\"price\">{1}</div><div class=\"price-benefit\">{2} {3} {4} {5}% </div>", CatalogService.GetStringPrice(productPrice), CatalogService.GetStringPrice(priceWithDiscount), Resource.Client_Catalog_Discount_Benefit, CatalogService.GetStringPrice(price - priceWithDiscount), Resource.Client_Catalog_Discount_Or, CatalogService.FormatPriceInvariant(discount)); } return(res); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { kernel.Bind <ApplicationUserManager>().ToMethod(context => { return(HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>()); }).InSingletonScope(); kernel.Bind <ISettingsService>().To <SettingsService>().InSingletonScope(); kernel.Bind <IFinanceService>().To <FinanceService>().InSingletonScope(); kernel.Bind <ICatalogService>().ToMethod(context => { string appDataPath = HttpContext.Current.Server.MapPath("~/App_Data"); string file = System.Text.RegularExpressions.Regex.Replace(WebConfigurationManager.AppSettings["catalog:path"], @"\|DataDirectory\|", appDataPath, System.Text.RegularExpressions.RegexOptions.IgnoreCase); return(CatalogService.Create(file)); }).InSingletonScope(); kernel.Bind <IShoppingCartService>().ToMethod(context => { ApplicationDbContext dbContext = HttpContext.Current.GetOwinContext().Get <ApplicationDbContext>(); return(ShoppingCartService.Create(dbContext)); }); kernel.Bind <IErpService>().To <ErpService>(); }
private static async Task ServiceDiscoveryAsync( this IServiceProvider provider, HttpApiConsulOptions options) { IConsulClient consul = provider.GetRequiredService <IConsulClient>(); if (consul == null) { throw new InvalidOperationException( "没有找到 Consul 客户端,请使用 service.AddConsulClient(); 注入"); } QueryResult <CatalogService[]> service = await consul.Catalog.Service(options.ConsulServiceName); if (service.StatusCode == HttpStatusCode.OK && service.Response.Length > 0) { Random random = new Random(Environment.TickCount); int index = random.Next(service.Response.Length); CatalogService catalog = service.Response[index]; UriBuilder builder = new UriBuilder(catalog.ServiceAddress) { Port = catalog.ServicePort, }; options.HttpHost = builder.Uri; } }
protected void Page_Load(object sender, EventArgs e) { _log.Info($"Now loading... /Catalog/Edit.aspx"); if (!Page.IsPostBack) { // Send an OpenID Connect sign-in request. if (!Request.IsAuthenticated) { Context.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/" }, OpenIdConnectAuthenticationDefaults.AuthenticationType); } if (!CatalogConfiguration.UseAzureStorage) { UploadButton.Visible = false; } var productId = Convert.ToInt32(Page.RouteData.Values["id"]); product = CatalogService.FindCatalogItem(productId); BrandDropDownList.DataSource = CatalogService.GetCatalogBrands(); BrandDropDownList.SelectedValue = product.CatalogBrandId.ToString(); TypeDropDownList.DataSource = CatalogService.GetCatalogTypes(); TypeDropDownList.SelectedValue = product.CatalogTypeId.ToString(); this.DataBind(); } }
protected void Save_Click(object sender, EventArgs e) { if (this.ModelState.IsValid) { var catalogItem = new CatalogItem { Id = Convert.ToInt32(Page.RouteData.Values["id"]), Name = Name.Text, Description = Description.Text, CatalogBrandId = int.Parse(BrandDropDownList.SelectedValue), CatalogTypeId = int.Parse(TypeDropDownList.SelectedValue), Price = decimal.Parse(Price.Text), PictureFileName = PictureFileName.Text, AvailableStock = int.Parse(Stock.Text), RestockThreshold = int.Parse(Restock.Text), MaxStockThreshold = int.Parse(Maxstock.Text), TempImageName = TempImageName.Value }; if (!string.IsNullOrEmpty(catalogItem.TempImageName)) { ImageService.UpdateImage(catalogItem); var fileName = Path.GetFileName(catalogItem.TempImageName); catalogItem.PictureFileName = fileName; } CatalogService.UpdateCatalogItem(catalogItem); Response.Redirect("~"); } }
protected string RenderPrice(decimal price, decimal discount) { if (price == 0) { return("<span class=\'price\'>" + Resource.Client_Catalog_ContactWithUs + "</span><br />"); } string res; string priceLiteral = CatalogService.GetStringPrice(price); if (discount == 0) { res = "<span class=\'price\'>" + priceLiteral + "</span><br />"; } else { string priceWithDiscountLiteral = CatalogService.GetStringPrice(price - price * discount / 100); res = string.Format( "<span class=\"OldPrice\">{0}</span><br /><span class=\"PriceWithDiscount\">{1}</span><br /><div class=\"Discount\">" + Resource.Client_Catalog_Discount + " {2}%</div>", priceLiteral, priceWithDiscountLiteral, discount); } return(res); }
static void Main(string[] args) { var catalogService = new CatalogService("catalog"); catalogService.RegisterParsers(new BookParser(), new PaperParser(), new PatentParser()); var result = catalogService.ReadCatalog(); Book book = new Book() { Name = "1111", }; catalogService.RegisterWriters(new BookWriter()); StringBuilder str = new StringBuilder(); StringWriter writer = new StringWriter(str); catalogService.WriteEntities(writer, new List <BaseEntity>() { book }); var c = str.ToString(); }
protected void LinkButtonAddCatalog_Click(object sender, EventArgs e) { if (this.TextBoxCatalogName.Text.Length == 0) { this.LabelPageMessageInfo.Text = PageInfo.MessageInfo_CatalogNameNull; return; } CatalogService service = new CatalogService(); CatalogEntity catalog = service.GetCatalogByName(this.TextBoxCatalogName.Text); if (catalog != null) { this.LabelPageMessageInfo.Text = PageInfo.MessageInfo_CatalogNameExist; this.LabelCatalogName.Text = ""; return; } else { CatalogEntity new_catalog = new CatalogEntity(this.TextBoxCatalogName.Text); string res = service.SaveCatalog(new_catalog); if (res != null) { Response.Redirect(PageInfo.PathCatalogAuthorizePage + new_catalog.CatalogName); return; } else { this.LabelPageMessageInfo.Text = PageInfo.MessageInfo_AddCatalogError; return; } } }
public static string BuildTaxTable(List <OrderTax> taxes, float currentCurrencyRate, string currentCurrencyIso3, string message) { var sb = new StringBuilder(); if (!taxes.Any()) { sb.Append("<tr><td style=\"background-color: #FFFFFF; text-align: right\">"); sb.Append(message); sb.Append(" </td><td style=\"background-color: #FFFFFF; width: 150px\">"); sb.Append(CatalogService.GetStringPrice(0, currentCurrencyRate, currentCurrencyIso3)); sb.Append("</td></tr>"); } else { foreach (OrderTax tax in taxes) { sb.Append("<tr><td style=\"background-color: #FFFFFF; text-align: right\">"); sb.Append((tax.TaxShowInPrice ? Resource.Core_TaxServices_Include_Tax : "") + " " + tax.TaxName); sb.Append(": </td><td style=\"background-color: #FFFFFF; width: 150px\">" + (tax.TaxShowInPrice ? "" : "+")); sb.Append(CatalogService.GetStringPrice(tax.TaxSum, currentCurrencyRate, currentCurrencyIso3)); sb.Append("</td></tr>"); } } return(sb.ToString()); }
protected void Page_Load(object sender, EventArgs e) { if (PaginationParamsAreSet()) { var size = Convert.ToInt32(Page.RouteData.Values["size"]); var index = Convert.ToInt32(Page.RouteData.Values["index"]); Model = CatalogService.GetCatalogItemsPaginated(size, index); //_log.Info($"Now loading... /Default.aspx?size={size}&index={index}"); } else { Model = CatalogService.GetCatalogItemsPaginated(DefaultPageSize, DefaultPageIndex); //_log.Info($"Now loading... /Default.aspx?size={DefaultPageSize}&index={DefaultPageIndex}"); } PeopleGrid.DataSource = new List <People>() { new People("Andy", "Wayne", "PG"), new People("Bill", "Johnson", "SD"), new People("Caroline", "Barry", "Manager") }; PeopleGrid.DataBind(); productList.DataSource = Model.Data; productList.DataBind(); ConfigurePagination(); }
public string RenderSelectedOptions(string xml) { if (string.IsNullOrEmpty(xml)) { return(string.Empty); } var res = new StringBuilder("<div class=\"customoptions\" >"); IList <EvaluatedCustomOptions> evlist = CustomOptionsService.DeserializeFromXml(xml); foreach (EvaluatedCustomOptions evco in evlist) { res.Append(evco.CustomOptionTitle); res.Append(": "); res.Append(evco.OptionTitle); res.Append(" "); if (evco.OptionPriceBc > 0) { res.Append("+"); res.Append(CatalogService.GetStringPrice(evco.OptionPriceBc)); } res.Append("<br />"); } res.Append("</div>"); return(res.ToString()); }
private async void save_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(tb_name.Text.Trim())) { MessageBox.Show("目录名称不能为空"); tb_name.Focus(); tb_name.SelectAll(); return; } if (!StringHelper.IsLong(tb_order.Text.Trim())) { MessageBox.Show("目录顺序必须是有效的整数", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); tb_order.Focus(); tb_order.SelectAll(); return; } pb.Visibility = Visibility.Visible; try { this.DoModel.Name = tb_name.Text.Trim(); this.DoModel.Order = Convert.ToInt64(tb_order.Text.Trim()); Catalog catalog = ObjectMapper.Map <CatalogModel, Catalog>(this.DoModel); await CatalogService.Update(catalog); this.ParentUI.DoCatalog = catalog; pb.Visibility = Visibility.Hidden; this.DialogResult = true; } catch (Exception ex) { pb.Visibility = Visibility.Hidden; MessageBox.Show(ex.Message, "提示", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void Return_0_When_Not_Contains_Passed_Catalog() { //Arrange var commonServiceMock = new Mock <ICommonService>(); var categoryServiceMock = new Mock <ICategoryService>(); var ruleMock = new Mock <ICalculatePriceRule>(); var rules = new List <ICalculatePriceRule>() { ruleMock.Object }; var dbCatalog = new DB.Catalog("TEST1", "TEST1", 3, 3); var dbCollection = new List <DB.Catalog>() { dbCatalog }; var myDbMock = new Mock <IMyDB>(); myDbMock.Setup(x => x.Catalogs).Returns(dbCollection); var catalogService = new CatalogService(myDbMock.Object); var store = new Store(commonServiceMock.Object, categoryServiceMock.Object, catalogService, rules); //Act var result = store.Quantity("test4e"); //Assert Assert.AreEqual(0, result); }
public void CatalogServiceTests_GetMergedCatalogList_DifferentSKU_SameProduct() { //Product codes are different, but they are same product. var catalog_A = new List <Catalog>(); catalog_A.Add(new Catalog() { SKU = "1111", Description = "product ABC" }); var catalog_B = new List <Catalog>(); catalog_B.Add(new Catalog() { SKU = "2222", Description = "product XYZ" }); var barcodes_A = new List <SupplierBarcode>(); barcodes_A.Add(new SupplierBarcode() { SupplierID = "1", SKU = "1111", Barcode = "SAME-BAR-CODE" }); var barcodes_B = new List <SupplierBarcode>(); barcodes_B.Add(new SupplierBarcode() { SupplierID = "1", SKU = "2222", Barcode = "SAME-BAR-CODE" }); var catalogService = new CatalogService(); var result = catalogService.GetMergedCatalogList(barcodes_A, barcodes_B, catalog_A, catalog_B); Assert.AreEqual(result.Count(), 1); Assert.AreEqual(result.FirstOrDefault().Source, "A"); }
public void CatalogServiceTests_GetMergedCatalogList_SameSKU_DifferentProducts() { //Product codes might be same, but they are different products. var catalog_A = new List <Catalog>(); catalog_A.Add(new Catalog() { SKU = "1111", Description = "product ABC" }); var catalog_B = new List <Catalog>(); catalog_B.Add(new Catalog() { SKU = "1111", Description = "product XYZ" }); var barcodes_A = new List <SupplierBarcode>(); barcodes_A.Add(new SupplierBarcode() { SupplierID = "1", SKU = "1111", Barcode = "BAR-CODE-ABC" }); var barcodes_B = new List <SupplierBarcode>(); barcodes_B.Add(new SupplierBarcode() { SupplierID = "1", SKU = "1111", Barcode = "BAR-CODE-XYZ" }); var catalogService = new CatalogService(); var result = catalogService.GetMergedCatalogList(barcodes_A, barcodes_B, catalog_A, catalog_B); Assert.AreEqual(result.Count(), 2); Assert.AreEqual(result.FirstOrDefault().SKU, result.LastOrDefault().SKU); Assert.AreEqual(result.FirstOrDefault().Source, "A"); Assert.AreEqual(result.LastOrDefault().Source, "B"); }
private static async Task InitCatalogs() { var kinds = Enum.GetValues(typeof(CatalogKind)); foreach (var kind in kinds) { var catalogKind = (CatalogKind)kind; var catalog = await CatalogService.GetByKind(catalogKind); if (catalog == null) { catalog = await CatalogService.Create(catalogKind); switch (catalogKind) { case CatalogKind.Cargo: { await InitCargoCatalogItems(catalog.Id); break; } case CatalogKind.Vehicle: { await InitVehicleCatalogItems(catalog.Id); break; } } } } }
protected void Page_PreRenderComplete(object sender, EventArgs e) { if (PageData != null && PageData.OrderConfirmationData.ActiveTab != EnActiveTab.FinalTab) { if (PageData.OrderConfirmationData.SelectedShippingItem.Id == 0 || PageData.OrderConfirmationData.SelectedPaymentItem.PaymenMethodtId == 0) { btnConfirm.CssClass += " btn-disabled"; } lblTotalPrice.Text = CatalogService.GetStringPrice(PageData.OrderConfirmationData.Sum); lblBonusPlus.Text = CatalogService.GetStringPrice(PageData.OrderConfirmationData.BonusPlus); bonusplusbottom.Visible = PageData.OrderConfirmationData.BonusPlus > 0; } breadCrumbs.Items = new List <BreadCrumbs> { new BreadCrumbs { Name = Resource.Client_MasterPage_MainPage, Url = UrlService.GetAbsoluteLink("/") }, new BreadCrumbs { Name = Resource.Client_OrderConfirmation_OrderConfirmation, Url = UrlService.GetAbsoluteLink("orderconfirmation.aspx") }, }; ltGaECommerce.Text = StepSuccess.GoogleAnalyticString; }
static void Main(string[] args) { try { ICatalogService service = new CatalogService(); IProviderManager manager = new ProviderManager(); ICrawlerService crawlerService = new CrawlerService(); if (args.Length > 0) { int providerID = 0; if (int.TryParse(args[0], out providerID)) { Data.Provider p = crawlerService.GetProvider(providerID); if (p != null) { IProvider provider = GetProviderImplementation(p, service, crawlerService); if (provider != null) { manager.Add(provider); manager.ExecuteAll(); } } } } else { IEnumerable<CashBack.Data.Provider> providers = crawlerService.GetActiveProviders(); foreach (CashBack.Data.Provider p in providers) { IProvider provider = GetProviderImplementation(p, service, crawlerService); if (provider != null) { if (p.LastRun.HasValue) { TimeSpan ts = DateTime.Now.Subtract(p.LastRun.Value); if (ts.Minutes >= p.RunInterval) manager.Add(provider); } else { manager.Add(provider); } } } //Execute all providers manager.ExecuteAll(); } } catch { } }