Exemplo n.º 1
0
        public static DSS1_RetailerDriverStockOptimisation.BO.Response ImportImplementation(System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.PastSales> pastSales)
        {
            string message = "";

            foreach (var pastSale in pastSales ?? Enumerable.Empty <DSS1_RetailerDriverStockOptimisation.BO.PastSales>())
            {
                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "API", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Warehouse: " + (pastSale?.Warehouse?.Code ?? ""));
                if ((pastSale?.Item == null || pastSale?.Warehouse == null))
                {
                    message = message + (pastSale?.Id ?? 0) + " ,";
                    continue;
                }
                var _var0 = pastSale?.Item?.SKU;
                DSS1_RetailerDriverStockOptimisation.BO.Item existingItem = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetAsQueryable <DSS1_RetailerDriverStockOptimisation.BO.Item>((s) => s.SKU == _var0)?.FirstOrDefault();
                var _var1 = pastSale?.Warehouse?.Code;
                DSS1_RetailerDriverStockOptimisation.BO.Warehouse existingWarehouse = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetAsQueryable <DSS1_RetailerDriverStockOptimisation.BO.Warehouse>((a) => a.Code == _var1)?.FirstOrDefault();
                if ((existingItem == null || existingWarehouse == null))
                {
                    message = message + (pastSale?.Id ?? 0) + " ,";
                    continue;
                }
                DSS1_RetailerDriverStockOptimisation.BO.PastSales newSalesForecast = new DSS1_RetailerDriverStockOptimisation.BO.PastSales();
                newSalesForecast.Warehouse    = existingWarehouse;
                newSalesForecast.Item         = existingItem;
                newSalesForecast.ForecastDate = (pastSale?.ForecastDate ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value);
                newSalesForecast.Units        = (pastSale?.Units ?? 0);
                new DSS1_RetailerDriverStockOptimisation.DAL.Repository().Save <DSS1_RetailerDriverStockOptimisation.BO.PastSales>(newSalesForecast);
            }
            if (((((message == null || message == "")) == false)))
            {
                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "API", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Error message: " + message);
                return(DSS1_RetailerDriverStockOptimisation.BO.ResponseExtensions.GenerateResponse("Failed", "Failed to import the entries with Ids " + message, "", "-1"));
            }
            return(DSS1_RetailerDriverStockOptimisation.BO.ResponseExtensions.GenerateResponse("Succeed", "All entries imported successfully.", "", "1"));
        }
Exemplo n.º 2
0
/// <summary>
/// Copies the current object to a new instance
/// </summary>
/// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param>
/// <param name="copiedObjects">Objects that should be reused</param>
/// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param>
/// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param>
/// <param name="copy">Optional - An existing [PastSales] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual PastSales Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, PastSales copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((PastSales)copiedObjects[this]);
            }
            copy = copy ?? new PastSales();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
            }
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            base.Copy(deep, copiedObjects, asNew, reuseNestedObjects, copy);
            return(copy);
        }