public void TestSave() { using (var lifetime = IocConfig.Container.BeginLifetimeScope()) { var unitOfWork = lifetime.Resolve <IUnitOfWork>(); var upcRepository = lifetime.Resolve <IRepository <Upc> >(); var model = new Upc { CreatedId = 818, CreatedTime = DateTime.Now, ModifiedId = 825, ModifiedTime = DateTime.Now, Active = 0, LastSerialNumber = 1, UpcValue = "789456123000", Gtin = "789456123000" }; var id = upcRepository.Save(model); //unitOfWork.Commit(); Assert.IsNotNull(id, "create upc failed."); Assert.AreEqual(id, model.Id); } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is CatalogItemVariation other && ((ItemId == null && other.ItemId == null) || (ItemId?.Equals(other.ItemId) == true)) && ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) && ((Sku == null && other.Sku == null) || (Sku?.Equals(other.Sku) == true)) && ((Upc == null && other.Upc == null) || (Upc?.Equals(other.Upc) == true)) && ((Ordinal == null && other.Ordinal == null) || (Ordinal?.Equals(other.Ordinal) == true)) && ((PricingType == null && other.PricingType == null) || (PricingType?.Equals(other.PricingType) == true)) && ((PriceMoney == null && other.PriceMoney == null) || (PriceMoney?.Equals(other.PriceMoney) == true)) && ((LocationOverrides == null && other.LocationOverrides == null) || (LocationOverrides?.Equals(other.LocationOverrides) == true)) && ((TrackInventory == null && other.TrackInventory == null) || (TrackInventory?.Equals(other.TrackInventory) == true)) && ((InventoryAlertType == null && other.InventoryAlertType == null) || (InventoryAlertType?.Equals(other.InventoryAlertType) == true)) && ((InventoryAlertThreshold == null && other.InventoryAlertThreshold == null) || (InventoryAlertThreshold?.Equals(other.InventoryAlertThreshold) == true)) && ((UserData == null && other.UserData == null) || (UserData?.Equals(other.UserData) == true)) && ((ServiceDuration == null && other.ServiceDuration == null) || (ServiceDuration?.Equals(other.ServiceDuration) == true)) && ((AvailableForBooking == null && other.AvailableForBooking == null) || (AvailableForBooking?.Equals(other.AvailableForBooking) == true)) && ((ItemOptionValues == null && other.ItemOptionValues == null) || (ItemOptionValues?.Equals(other.ItemOptionValues) == true)) && ((MeasurementUnitId == null && other.MeasurementUnitId == null) || (MeasurementUnitId?.Equals(other.MeasurementUnitId) == true)) && ((TeamMemberIds == null && other.TeamMemberIds == null) || (TeamMemberIds?.Equals(other.TeamMemberIds) == true))); }
public IActionResult Update(string id, Upc upcIn) { var upc = _upcService.Get(id); if (upc == null) { return(NotFound()); } _upcService.Update(id, upcIn); return(NoContent()); }
public void Should_be_able_to_get_an_object_by_property() { var upc = new Upc("1234567890"); var product = new Product { Id = Guid.NewGuid(), Upc = upc }; using (var session = documentStore.OpenSession()) { session.Store(product); session.SaveChanges(); } var result = productStore.GetByUpc(upc); Assert.That(result, Is.Not.Null); }
public void Should_be_able_to_delete_an_object_by_property() { var upc = new Upc("1234567890"); var product = new Product { Id = Guid.NewGuid(), Upc = upc }; using (var session = documentStore.OpenSession()) { session.Store(product); session.SaveChanges(); } productStore.DeleteByUpc(upc); using (var session = documentStore.OpenSession()) { var result = session.Load<Product>("products/" + product.Id); Assert.That(result, Is.Null); } }
public void Should_be_able_to_get_an_object_by_property_from_approximately_one_thousand_objects() { const int count = 1024; var random = new Random(); var upc = new Upc("100000000"); var product = new Product { Id = Guid.NewGuid(), Upc = upc }; var upcs = new List<Upc> { upc }; using (var session = documentStore.OpenSession()) { session.Store(product); session.SaveChanges(); } for (int i = 0; i < count; i++) { using (var session = documentStore.OpenSession()) { Upc randomUpc; do { randomUpc = new Upc(random.Next(100000000, 999999999).ToString(CultureInfo.InvariantCulture)); } while (upcs.Contains(randomUpc)); upcs.Add(randomUpc); session.Store(new Product { Id = Guid.NewGuid(), Upc = randomUpc }); session.SaveChanges(); } } var stopwatch = new Stopwatch(); stopwatch.Start(); var result = productStore.GetByUpc(upc); stopwatch.Stop(); Console.WriteLine("Elapsed milliseconds: " + stopwatch.ElapsedMilliseconds); Assert.That(result, Is.Not.Null); Assert.That(stopwatch.ElapsedMilliseconds, Is.LessThan(100)); }
public ActionResult <Upc> Create(Upc upc) { _upcService.Create(upc); return(CreatedAtRoute("GetUpc", new { id = upc.Id.ToString() }, upc)); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Upc != null) { hashCode = hashCode * 59 + Upc.GetHashCode(); } if (Ean != null) { hashCode = hashCode * 59 + Ean.GetHashCode(); } if (Isbn != null) { hashCode = hashCode * 59 + Isbn.GetHashCode(); } if (Asin != null) { hashCode = hashCode * 59 + Asin.GetHashCode(); } if (Title != null) { hashCode = hashCode * 59 + Title.GetHashCode(); } if (Sku != null) { hashCode = hashCode * 59 + Sku.GetHashCode(); } if (Mpn != null) { hashCode = hashCode * 59 + Mpn.GetHashCode(); } if (PartNumber != null) { hashCode = hashCode * 59 + PartNumber.GetHashCode(); } if (Upcs != null) { hashCode = hashCode * 59 + Upcs.GetHashCode(); } if (Description != null) { hashCode = hashCode * 59 + Description.GetHashCode(); } if (Brand != null) { hashCode = hashCode * 59 + Brand.GetHashCode(); } if (Manufacturer != null) { hashCode = hashCode * 59 + Manufacturer.GetHashCode(); } if (Color != null) { hashCode = hashCode * 59 + Color.GetHashCode(); } hashCode = hashCode * 59 + NewPrice.GetHashCode(); hashCode = hashCode * 59 + UsedPrice.GetHashCode(); if (CurrencyCode != null) { hashCode = hashCode * 59 + CurrencyCode.GetHashCode(); } if (Url != null) { hashCode = hashCode * 59 + Url.GetHashCode(); } if (Features != null) { hashCode = hashCode * 59 + Features.GetHashCode(); } if (Dimensions != null) { hashCode = hashCode * 59 + Dimensions.GetHashCode(); } if (Images != null) { hashCode = hashCode * 59 + Images.GetHashCode(); } if (MatchedItems != null) { hashCode = hashCode * 59 + MatchedItems.GetHashCode(); } if (IsoCountryCodes != null) { hashCode = hashCode * 59 + IsoCountryCodes.GetHashCode(); } if (CompanyName != null) { hashCode = hashCode * 59 + CompanyName.GetHashCode(); } if (CompanyAddress != null) { hashCode = hashCode * 59 + CompanyAddress.GetHashCode(); } if (Categories != null) { hashCode = hashCode * 59 + Categories.GetHashCode(); } if (CategoryHierarchies != null) { hashCode = hashCode * 59 + CategoryHierarchies.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if Item instances are equal /// </summary> /// <param name="other">Instance of Item to be compared</param> /// <returns>Boolean</returns> public bool Equals(Item other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Upc == other.Upc || Upc != null && Upc.Equals(other.Upc) ) && ( Ean == other.Ean || Ean != null && Ean.Equals(other.Ean) ) && ( Isbn == other.Isbn || Isbn != null && Isbn.Equals(other.Isbn) ) && ( Asin == other.Asin || Asin != null && Asin.Equals(other.Asin) ) && ( Title == other.Title || Title != null && Title.Equals(other.Title) ) && ( Sku == other.Sku || Sku != null && Sku.Equals(other.Sku) ) && ( Mpn == other.Mpn || Mpn != null && Mpn.Equals(other.Mpn) ) && ( PartNumber == other.PartNumber || PartNumber != null && PartNumber.Equals(other.PartNumber) ) && ( Upcs == other.Upcs || Upcs != null && other.Upcs != null && Upcs.SequenceEqual(other.Upcs) ) && ( Description == other.Description || Description != null && Description.Equals(other.Description) ) && ( Brand == other.Brand || Brand != null && Brand.Equals(other.Brand) ) && ( Manufacturer == other.Manufacturer || Manufacturer != null && Manufacturer.Equals(other.Manufacturer) ) && ( Color == other.Color || Color != null && Color.Equals(other.Color) ) && ( NewPrice == other.NewPrice || NewPrice.Equals(other.NewPrice) ) && ( UsedPrice == other.UsedPrice || UsedPrice.Equals(other.UsedPrice) ) && ( CurrencyCode == other.CurrencyCode || CurrencyCode != null && CurrencyCode.Equals(other.CurrencyCode) ) && ( Url == other.Url || Url != null && Url.Equals(other.Url) ) && ( Features == other.Features || Features != null && other.Features != null && Features.SequenceEqual(other.Features) ) && ( Dimensions == other.Dimensions || Dimensions != null && other.Dimensions != null && Dimensions.SequenceEqual(other.Dimensions) ) && ( Images == other.Images || Images != null && other.Images != null && Images.SequenceEqual(other.Images) ) && ( MatchedItems == other.MatchedItems || MatchedItems != null && other.MatchedItems != null && MatchedItems.SequenceEqual(other.MatchedItems) ) && ( IsoCountryCodes == other.IsoCountryCodes || IsoCountryCodes != null && other.IsoCountryCodes != null && IsoCountryCodes.SequenceEqual(other.IsoCountryCodes) ) && ( CompanyName == other.CompanyName || CompanyName != null && CompanyName.Equals(other.CompanyName) ) && ( CompanyAddress == other.CompanyAddress || CompanyAddress != null && CompanyAddress.Equals(other.CompanyAddress) ) && ( Categories == other.Categories || Categories != null && other.Categories != null && Categories.SequenceEqual(other.Categories) ) && ( CategoryHierarchies == other.CategoryHierarchies || CategoryHierarchies != null && other.CategoryHierarchies != null && CategoryHierarchies.SequenceEqual(other.CategoryHierarchies) )); }
public Product(ProductName name, Upc upc, Price price) { _name = name; _upc = upc; _price = price; }
public override int GetHashCode() { int hashCode = -1155387790; if (ItemId != null) { hashCode += ItemId.GetHashCode(); } if (Name != null) { hashCode += Name.GetHashCode(); } if (Sku != null) { hashCode += Sku.GetHashCode(); } if (Upc != null) { hashCode += Upc.GetHashCode(); } if (Ordinal != null) { hashCode += Ordinal.GetHashCode(); } if (PricingType != null) { hashCode += PricingType.GetHashCode(); } if (PriceMoney != null) { hashCode += PriceMoney.GetHashCode(); } if (LocationOverrides != null) { hashCode += LocationOverrides.GetHashCode(); } if (TrackInventory != null) { hashCode += TrackInventory.GetHashCode(); } if (InventoryAlertType != null) { hashCode += InventoryAlertType.GetHashCode(); } if (InventoryAlertThreshold != null) { hashCode += InventoryAlertThreshold.GetHashCode(); } if (UserData != null) { hashCode += UserData.GetHashCode(); } if (ServiceDuration != null) { hashCode += ServiceDuration.GetHashCode(); } if (AvailableForBooking != null) { hashCode += AvailableForBooking.GetHashCode(); } if (ItemOptionValues != null) { hashCode += ItemOptionValues.GetHashCode(); } if (MeasurementUnitId != null) { hashCode += MeasurementUnitId.GetHashCode(); } if (TeamMemberIds != null) { hashCode += TeamMemberIds.GetHashCode(); } return(hashCode); }
private void backgroundWorkerImagePath_DoWork(object sender, DoWorkEventArgs e) { // simulate progress 1% ~ 10% for (int i = 1; i <= 10; i++) { Thread.Sleep(25); backgroundWorkerImagePath.ReportProgress(i); } // get the sku text and initilize sku field sku = skuCodeTextbox.Text; // search images and generate uri that assign to image fields int index = 0; string[] imageCopy = ImageSearch.GetImageUri(sku); foreach (string uri in imageCopy) { if (index > 9) { break; } image[index] = uri; index++; } // add the missing value for (int i = index; i < 10; i++) { image[i] = string.Empty; } index = 0; string[] groupCopy = ImageSearch.GetGroupUri(sku); foreach (string uri in groupCopy) // get the value that exist { if (index > 4) { break; } group[index] = uri; index++; } // add the missing value for (int i = index; i < 5; i++) { group[i] = string.Empty; } index = 0; string[] modelCopy = ImageSearch.GetModelUri(sku); foreach (string uri in modelCopy) // get the value that exist { if (index > 4) { break; } model[index] = uri; index++; } // add the missing value for (int i = index; i < 5; i++) { model[i] = string.Empty; } index = 0; string[] templateCopy = ImageSearch.GetTemplateUri(sku); foreach (string uri in templateCopy) // get the value that exist { if (index > 1) { break; } template[index] = uri; index++; } // add the missing value for (int i = index; i < 2; i++) { template[i] = string.Empty; } // simulate progress 10% ~ 20% for (int i = 10; i <= 20; i++) { Thread.Sleep(25); backgroundWorkerImagePath.ReportProgress(i); } // addition fields for adding upc image upcCode9 = Upc.GetUpc(); upcCode10 = Upc.GetUpc10(upcCode9); // adding upc image ImageReplace imageReplace = new ImageReplace(); imageReplace.AddUpc(sku, upcCode9); imageReplace.AddUpc(sku, upcCode10); // assign textboxes to textbox holders imageTextbox[0] = image1Textbox; imageTextbox[1] = image2Textbox; imageTextbox[2] = image3Textbox; imageTextbox[3] = image4Textbox; imageTextbox[4] = image5Textbox; imageTextbox[5] = image6Textbox; imageTextbox[6] = image7Textbox; imageTextbox[7] = image8Textbox; imageTextbox[8] = image9Textbox; imageTextbox[9] = image10Textbox; groupTextbox[0] = group1Textbox; groupTextbox[1] = group2Textbox; groupTextbox[2] = group3Textbox; groupTextbox[3] = group4Textbox; groupTextbox[4] = group5Textbox; modelTextbox[0] = model1Textbox; modelTextbox[1] = model2Textbox; modelTextbox[2] = model3Textbox; modelTextbox[3] = model4Textbox; modelTextbox[4] = model5Textbox; templateTextbox[0] = template1Textbox; templateTextbox[1] = template2Textbox; // simulate progress 20% ~ 30% for (int i = 20; i <= 30; i++) { Thread.Sleep(25); backgroundWorkerImagePath.ReportProgress(i); } }
public void Remove(Upc upcIn) => _upcs.DeleteOne(upc => upc.Id == upcIn.Id);
public void Update(string id, Upc upcIn) => _upcs.ReplaceOne(upc => upc.Id == id, upcIn);
public Upc Create(Upc upc) { _upcs.InsertOne(upc); return(upc); }
private TradeData CreateTradeDataElement(TradeExportData data) { if (string.IsNullOrWhiteSpace(data.StyleNo)) { throw new Exception("data has empty StyleNo"); } TradeData output = new TradeData(); Item item = new Item(); Upc upc = new Upc(); var pricing = _pricingEngine.CalculatePrices(data.StyleNo, data.SubClass1 ?? string.Empty, data.BasePrice); output.StyleNo = data.StyleNo; output.Description1 = data.Description1 ?? string.Empty; output.Description2 = data.Description2 ?? string.Empty; output.Description4 = data.Description4 ?? string.Empty; output.PrimaryVendor = data.PrimaryVendor ?? string.Empty; output.SeasonName = data.SeasonName ?? string.Empty; output.TaxGroupCode = data.TaxGroupCode ?? string.Empty; output.TaxCategory = data.TaxCategory ?? string.Empty; output.BrandName = data.BrandName ?? string.Empty; output.Replenishment = true; output.CountryOfOrigin = data.CountryOfOrigin ?? string.Empty; output.CustomLongText1 = data.CustomLongText1 ?? string.Empty; output.CustomLongText2 = data.CustomLongText2 ?? string.Empty; output.CustomLongText3 = data.CustomLongText3 ?? string.Empty; output.CustomLongText4 = data.CustomLongText4 ?? string.Empty; output.CustomLongText5 = data.CustomLongText5 ?? string.Empty; output.CustomLongText6 = data.CustomLongText6 ?? string.Empty; output.CustomLongText7 = string.Empty; output.CustomLongText8 = string.Empty; output.CustomLongText9 = string.Empty; output.CustomLongText10 = string.Empty; output.CustomLongText11 = string.Empty; output.CustomLongText12 = string.Empty; output.Manufacturer = string.Empty; output.Department = string.IsNullOrEmpty(data.SubClass1) ? string.Empty : data.SubClass1.Substring(0, 1); output.OrderCost = data.OrderCost; item.WeeksOfSupply = 6; item.Eid = data.EID; item.Clu = data.CLU; upc.Value = data.UPCValue; upc.IsDefault = true; item.UPCs.Add(upc); item.Attribute1 = data.Attribute1 ?? string.Empty; item.Attribute2 = data.Attribute2 ?? string.Empty; if (data.Height.HasValue) { item.Height = data.Height.Value; } if (data.Weight.HasValue) { item.Weight = data.Weight.Value; } if (data.Width.HasValue) { item.Width = data.Width.Value; } if (data.Length.HasValue) { item.Length = data.Length.Value; } item.BasePrice = data.BasePrice; foreach (var outputPrice in _pricingEngine.CalculatePrices(data.StyleNo, data.SubClass1, data.BasePrice)) { Price price = new Price { PriceLevel = outputPrice.TWRLevel, PricePrice = outputPrice.Price }; item.Prices.Add(price); } if (data.ReleaseDate.HasValue) { item.ReleaseDate = data.ReleaseDate.Value; } item.NotTrackOh = false; item.TradeDiscount = true; item.MemberDiscount = true; item.Inactive = false; item.RequireDiscountAuthorizationCode = true; item.AcceptToken = true; item.AutoPromptToPayWithTokens = true; item.EligibleForLoyaltyRewards2 = true; item.LoyaltyRewards2Ratio = 1; if (data.ItemCost.HasValue) { item.OrderCost = data.ItemCost.Value; } if (data.CustomDate1.HasValue) { item.CustomDate1 = data.CustomDate1.Value; } item.CustomFlag3 = false; item.CustomFlag4 = false; item.CustomFlag5 = false; item.CustomFlag6 = false; item.CustomFlag7 = false; item.CustomNumber3 = 0; item.CustomNumber4 = 0; item.CustomNumber5 = 0; item.CustomNumber6 = 0; item.CustomNumber7 = 0; item.CustomNumber8 = 0; item.CustomNumber9 = 0; item.CustomText1 = data.CustomText1 ?? string.Empty; item.CustomText2 = data.CustomText2 ?? string.Empty; item.CustomText3 = string.Empty; item.CustomText4 = string.Empty; item.CustomText5 = data.CustomText5 ?? string.Empty; item.CustomText6 = string.Empty; item.CustomText7 = string.Empty; item.CustomText8 = string.Empty; item.CustomText9 = data.CustomText9 ?? string.Empty; item.CustomText10 = string.Empty; item.CustomText11 = string.Empty; item.CustomText12 = string.Empty; item.SubClass1 = data.SubClass1 ?? string.Empty; item.Subclass2 = data.SubClass2 ?? string.Empty; if (!string.IsNullOrWhiteSpace(item.SubClass1)) { if (item.SubClass1.Length == 6) { string elementClass = item.SubClass1.Substring(3, 3); switch (item.SubClass1.Substring(0, 3).ToLowerInvariant()) { case "p10": elementClass = "1" + elementClass; break; case "m10": elementClass = "2" + elementClass; break; case "g10": elementClass = "3" + elementClass; break; case "f10": elementClass = "6" + elementClass; break; } item.Class = elementClass; } } output.Items.Add(item); return(output); }