Exemple #1
0
        private SpecialPrice[] MapToSpecialPrice(OnSale onSale)
        {
            var specialPrice = new List <SpecialPrice>();

            for (int i = 1; i < 14; i++)
            {
                var size = "";
                if (i < 10)
                {
                    size += "00" + i;
                }
                else
                {
                    size += "0" + i;
                }

                specialPrice.Add(new SpecialPrice()
                {
                    price      = Convert.ToDecimal(onSale.Price),
                    price_from = onSale.End,
                    price_to   = onSale.Start,
                    sku        = onSale.Sku + size,
                    store_id   = onSale.StoreId.Value
                });
            }
            return(specialPrice.ToArray());
        }
Exemple #2
0
    public override int GetHashCode()
    {
        int hashcode = 157;

        unchecked {
            if (__isset.productId)
            {
                hashcode = (hashcode * 397) + ProductId.GetHashCode();
            }
            if (__isset.packageId)
            {
                hashcode = (hashcode * 397) + PackageId.GetHashCode();
            }
            if (__isset.version)
            {
                hashcode = (hashcode * 397) + Version.GetHashCode();
            }
            if (__isset.onSale)
            {
                hashcode = (hashcode * 397) + OnSale.GetHashCode();
            }
            if (__isset.validUntil)
            {
                hashcode = (hashcode * 397) + ValidUntil.GetHashCode();
            }
            if (__isset.stickerIdRanges)
            {
                hashcode = (hashcode * 397) + TCollections.GetHashCode(StickerIdRanges);
            }
            if (__isset.grantedByDefault)
            {
                hashcode = (hashcode * 397) + GrantedByDefault.GetHashCode();
            }
            if (__isset.displayOrder)
            {
                hashcode = (hashcode * 397) + DisplayOrder.GetHashCode();
            }
        }
        return(hashcode);
    }
Exemple #3
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Attributes != null?Attributes.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (CatalogVisibility != null ? CatalogVisibility.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Categories != null ? Categories.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ExternalUrl != null ? ExternalUrl.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Featured.GetHashCode();
                hashCode = (hashCode * 397) ^ Id;
                hashCode = (hashCode * 397) ^ (Images != null ? Images.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ InStock.GetHashCode();
                hashCode = (hashCode * 397) ^ ManageStock.GetHashCode();
                hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ OnSale.GetHashCode();
                hashCode = (hashCode * 397) ^ ParentId;
                hashCode = (hashCode * 397) ^ (Permalink != null ? Permalink.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Price != null ? Price.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (PriceHtml != null ? PriceHtml.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Purchasable.GetHashCode();
                hashCode = (hashCode * 397) ^ (RegularPrice != null ? RegularPrice.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (RelatedIds != null ? RelatedIds.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (SalePrice != null ? SalePrice.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ShortDescription != null ? ShortDescription.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Sku != null ? Sku.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Slug != null ? Slug.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (StockQuantity != null ? StockQuantity.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Tags != null ? Tags.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (TaxClass != null ? TaxClass.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (TaxStatus != null ? TaxStatus.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ TotalSales;
                hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Virtual.GetHashCode();
                return(hashCode);
            }
        }
Exemple #4
0
        public void GenerateCSVAsync(string startDate, string endDate, int stamp, List <DataRow> dataRows, decimal adjustmentPrice = 0, int adjustmentPercentage = 0, decimal euro = 0)
        {
            try
            {
                var     csv            = new StringBuilder();
                var     specailsOrders = new List <SpecailOrders>();
                decimal actualPrice    = 0;
                var     parentSKUs     = new List <string>();

                foreach (DataRow item in dataRows)
                {
                    BuildStockObject(ref specailsOrders, item);
                }
                var count = 0;
                foreach (var o in specailsOrders)
                {
                    if (count == (specailsOrders.Count - 1))
                    {
                        break;
                    }

                    actualPrice = 0;
                    var newLine   = "";
                    var parentSku = o.Ref.Substring(0, 9);
                    //TODO uncomment once API is fixed
                    //if (euro != 0)
                    //{
                    //    actualPrice = GenerateSalesPrice(adjustmentPrice, adjustmentPercentage, GenerateEuroPrice(Convert.ToDecimal(o.Sell), euro));
                    //    if (!parentSKUs.Contains(parentSku))
                    //    {
                    //        newLine = $"{"\"" + parentSku + "\""},{"\"" + Convert.ToInt16(actualPrice) + "\""},{"\"" + (Convert.ToDateTime(startDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\"" + (Convert.ToDateTime(endDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\" \""},{"\" \""},{"\" \""}";
                    //        csv.AppendLine(newLine);
                    //        parentSKUs.Add(parentSku);
                    //    }
                    //    newLine = $"{"\"" + (o).Ref + "\""},{"\"" + Convert.ToInt16(actualPrice) + "\""},{"\"" + (Convert.ToDateTime(startDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\"" + (Convert.ToDateTime(endDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\" \""},{"\" \""},{"\" \""}";
                    //}
                    //else
                    //{
                    //    actualPrice = GenerateSalesPrice(adjustmentPrice, adjustmentPercentage, o.Sell);
                    //    if (!parentSKUs.Contains(parentSku))
                    //    {
                    //        newLine = $"{"\"" + parentSku + "\""},{"\"" + Convert.ToInt16(actualPrice) + "\""},{"\"" + (Convert.ToDateTime(startDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\"" + (Convert.ToDateTime(endDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\" \""},{"\" \""},{"\" \""}";
                    //        csv.AppendLine(newLine);
                    //        parentSKUs.Add(parentSku);
                    //    }
                    //    newLine = $"{"\"" + (o).Ref + "\""},{"\"" + Convert.ToInt16(actualPrice) + "\""},{"\"" + (Convert.ToDateTime(startDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\"" + (Convert.ToDateTime(endDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\" \""},{"\" \""},{"\" \""},{"\"" + GenerateEuroPrice(Convert.ToDecimal(o.Sell), euro) + "\""}";
                    //}

                    actualPrice = GenerateSalesPrice(adjustmentPrice, adjustmentPercentage, o.Sell);
                    if (!parentSKUs.Contains(parentSku))
                    {
                        newLine = $"{"\"" + parentSku + "\""},{"\"" + Convert.ToInt16(actualPrice) + "\""},{"\"" + Convert.ToInt16(GenerateSalesPrice(adjustmentPrice, adjustmentPercentage, GenerateEuroPrice(Convert.ToDecimal(o.Sell), euro))) + "\""},{"\"1\""},{"\"" + (Convert.ToDateTime(startDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\"" + (Convert.ToDateTime(endDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\" \""},{"\" \""},{"\" \""},{"\" \""},{"\" \""},{"\"" + (o).Sell + "\""},{"\"" + GenerateEuroPrice(Convert.ToDecimal(o.Sell), euro) + "\""}";
                        csv.AppendLine(newLine);
                        parentSKUs.Add(parentSku);
                    }
                    newLine = $"{"\"" + (o).Ref + "\""},{"\"" + Convert.ToInt16(actualPrice) + "\""},{"\"" + Convert.ToInt16(GenerateSalesPrice(adjustmentPrice, adjustmentPercentage, GenerateEuroPrice(Convert.ToDecimal(o.Sell), euro))) + "\""},{"\"1\""},{"\"" + (Convert.ToDateTime(startDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\"" + (Convert.ToDateTime(endDate).ToString("yyyy/MM/dd") ?? "") + "\""},{"\" \""},{"\" \""},{"\" \""},{"\" \""},{"\" \""},{"\"" + (o).Sell + "\""},{"\"" + GenerateEuroPrice(Convert.ToDecimal(o.Sell), euro) + "\""}";

                    csv.AppendLine(newLine);
                    count++;
                }
                //if (euro != 0)
                //{
                //    File.AppendAllText(ConfigurationManager.AppSettings["SalesPriceOutput"] + stamp + "-euro.csv", csv.ToString());
                //}
                //else
                //{
                File.AppendAllText(ConfigurationManager.AppSettings["SalesPriceOutput"] + stamp + ".csv", csv.ToString());
                //}
                var repo = new OnSaleRepository();

                //TODO Delete here
                if (euro != 0)
                {
                    var onSale = new OnSale()
                    {
                        StoreId = 2,
                        Sku     = specailsOrders.First().Ref.Substring(0, 9),
                        Price   = Convert.ToDecimal(actualPrice.ToString()).ToString(),
                        Start   = startDate,
                        End     = endDate
                    };
                    new MagentoSpecialPrice().DeleteSpecialPrice(specailsOrders.First().Ref.Substring(0, 9), 2);
                    repo.Insert(onSale);
                }
                else
                {
                    var onSale = new OnSale()
                    {
                        StoreId = 1,
                        Sku     = specailsOrders.First().Ref.Substring(0, 9),
                        Price   = Convert.ToDecimal(actualPrice.ToString()).ToString(),
                        Start   = startDate,
                        End     = endDate
                    };
                    new MagentoSpecialPrice().DeleteSpecialPrice(specailsOrders.First().Ref.Substring(0, 9), 1);
                    repo.Insert(onSale);
                }
                repo.Save();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Exemple #5
0
    public override string ToString()
    {
        var  sb      = new StringBuilder("ProductSimple(");
        bool __first = true;

        if (ProductId != null && __isset.productId)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("ProductId: ");
            ProductId.ToString(sb);
        }
        if (__isset.packageId)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("PackageId: ");
            PackageId.ToString(sb);
        }
        if (__isset.version)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Version: ");
            Version.ToString(sb);
        }
        if (__isset.onSale)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("OnSale: ");
            OnSale.ToString(sb);
        }
        if (__isset.validUntil)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("ValidUntil: ");
            ValidUntil.ToString(sb);
        }
        if (StickerIdRanges != null && __isset.stickerIdRanges)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("StickerIdRanges: ");
            StickerIdRanges.ToString(sb);
        }
        if (__isset.grantedByDefault)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("GrantedByDefault: ");
            GrantedByDefault.ToString(sb);
        }
        if (__isset.displayOrder)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("DisplayOrder: ");
            DisplayOrder.ToString(sb);
        }
        sb.Append(")");
        return(sb.ToString());
    }