internal static ICatalogInventory ToCatalogInventory(this CatalogInventoryDisplay catalogInventoryDisplay, ICatalogInventory destination)
        {
            destination.Count = catalogInventoryDisplay.Count;
            destination.LowCount = catalogInventoryDisplay.LowCount;

            return destination;
        }
        private void UpdateCatalogInventory(ICatalogInventory inv)
        {
            inv.UpdateDate = DateTime.Now;
            var dto = new CatalogInventoryDto()
            {
                CatalogKey        = inv.CatalogKey,
                ProductVariantKey = inv.ProductVariantKey,
                Count             = inv.Count,
                LowCount          = inv.LowCount,
                CreateDate        = inv.CreateDate,
                UpdateDate        = inv.UpdateDate
            };

            //Database.Update(dto);

            Database.Execute(
                "UPDATE merchCatalogInventory SET Count = @invCount, LowCount = @invLowCount, UpdateDate = @invUpdateDate WHERE catalogKey = @catalogKey AND productVariantKey = @productVariantKey",
                new
            {
                invCount          = inv.Count,
                invLowCount       = inv.LowCount,
                invUpdateDate     = inv.UpdateDate,
                catalogKey        = inv.CatalogKey,
                productVariantKey = inv.ProductVariantKey
            });
        }
        /// <summary>
        /// Updates SQLCE database where bulk update is not available.
        /// </summary>
        /// <param name="inv">
        /// The inventory.
        /// </param>
        private void SqlCeUpdateCatalogInventory(ICatalogInventory inv)
        {
            var sql =
                new Sql(
                    "UPDATE merchCatalogInventory SET Count = @ct, LowCount = @lct, Location = @loc, UpdateDate = @ud WHERE catalogKey = @ck AND productVariantKey = @pvk",
                    new
            {
                @ct  = inv.Count,
                @lct = inv.LowCount,
                @loc = inv.Location,
                @ud  = DateTime.Now,
                @ck  = inv.CatalogKey,
                @pvk = inv.ProductVariantKey
            });

            Database.Execute(sql);
        }
        /// <summary>
        /// Updates catalog inventory.
        /// </summary>
        /// <param name="inv">
        /// The <see cref="ICatalogInventory"/>.
        /// </param>
        private void UpdateCatalogInventory(ICatalogInventory inv)
        {
            inv.UpdateDate = DateTime.Now;


            Database.Execute(
                "UPDATE merchCatalogInventory SET Count = @invCount, LowCount = @invLowCount, Location = @invLocation, UpdateDate = @invUpdateDate WHERE catalogKey = @catalogKey AND productVariantKey = @productVariantKey",
                new
            {
                invCount          = inv.Count,
                invLowCount       = inv.LowCount,
                invLocation       = inv.Location,
                invUpdateDate     = inv.UpdateDate,
                catalogKey        = inv.CatalogKey,
                productVariantKey = inv.ProductVariantKey
            });
        }
        private void AddCatalogInventory(ICatalogInventory inv)
        {
            inv.CreateDate = DateTime.Now;
            inv.UpdateDate = DateTime.Now;

            var dto = new CatalogInventoryDto()
            {
                CatalogKey        = inv.CatalogKey,
                ProductVariantKey = inv.ProductVariantKey,
                Count             = inv.Count,
                LowCount          = inv.LowCount,
                CreateDate        = inv.CreateDate,
                UpdateDate        = inv.UpdateDate
            };

            Database.Insert(dto);
        }
 /// <summary>
 /// The add to catalog inventory.
 /// </summary>
 /// <param name="productVariant">
 /// The <see cref="IProductVariant"/>
 /// </param>
 /// <param name="catalogInventory">
 /// The <see cref="ICatalogInventory"/> to be added
 /// </param>
 public static void AddToCatalogInventory(this IProductVariant productVariant, ICatalogInventory catalogInventory)
 {
     ((CatalogInventoryCollection)productVariant.CatalogInventories).Add(catalogInventory);
 }
 internal static CatalogInventoryDisplay ToCatalogInventoryDisplay(this ICatalogInventory catalogInventory)
 {
     return(AutoMapper.Mapper.Map <CatalogInventoryDisplay>(catalogInventory));
 }
示例#8
0
 /// <summary>
 /// The add to catalog inventory.
 /// </summary>
 /// <param name="productVariant">
 /// The <see cref="IProductVariant"/>
 /// </param>
 /// <param name="catalogInventory">
 /// The <see cref="ICatalogInventory"/> to be added
 /// </param>
 public static void AddToCatalogInventory(this IProductVariant productVariant, ICatalogInventory catalogInventory)
 {
     ((CatalogInventoryCollection)productVariant.CatalogInventories).Add(catalogInventory);
 }
        /// <summary>
        /// Maps <see cref="CatalogInventoryDisplay"/> to <see cref="ICatalogInventory"/>.
        /// </summary>
        /// <param name="catalogInventoryDisplay">
        /// The catalog inventory display.
        /// </param>
        /// <param name="destination">
        /// The destination.
        /// </param>
        /// <returns>
        /// The <see cref="ICatalogInventory"/>.
        /// </returns>
        internal static ICatalogInventory ToCatalogInventory(this CatalogInventoryDisplay catalogInventoryDisplay, ICatalogInventory destination)
        {
            destination.Count    = catalogInventoryDisplay.Count;
            destination.LowCount = catalogInventoryDisplay.LowCount;

            return(destination);
        }