public virtual ShipmentItem ToModel(ShipmentItem shipmentItem)
        {
            if (shipmentItem == null)
            {
                throw new ArgumentNullException(nameof(shipmentItem));
            }

            shipmentItem.Id           = Id;
            shipmentItem.CreatedDate  = CreatedDate;
            shipmentItem.CreatedBy    = CreatedBy;
            shipmentItem.ModifiedDate = ModifiedDate;
            shipmentItem.ModifiedBy   = ModifiedBy;
            shipmentItem.OuterId      = OuterId;

            shipmentItem.BarCode  = BarCode;
            shipmentItem.Quantity = Quantity;

            shipmentItem.LineItemId = LineItemId;

            if (ModelLineItem != null)
            {
                shipmentItem.LineItem = ModelLineItem;
            }

            return(shipmentItem);
        }
Exemplo n.º 2
0
        public void OnNext(OrderChangeEvent value)
        {
            var origStockOutOperations     = new ShipmentItem[] { };
            var modifiedStockOutOperations = new ShipmentItem[] { };

            if (value.OrigOrder != null)
            {
                origStockOutOperations = value.OrigOrder.Shipments.SelectMany(x => x.Items).ToArray();
            }
            if (value.ModifiedOrder != null)
            {
                modifiedStockOutOperations = value.ModifiedOrder.Shipments.SelectMany(x => x.Items).ToArray();
            }

            var originalPositions = new ObservableCollection <KeyValuePair <string, int> >(origStockOutOperations.GroupBy(x => x.LineItem.ProductId).Select(x => new KeyValuePair <string, int>(x.Key, x.Sum(y => y.Quantity))));
            var modifiedPositions = new ObservableCollection <KeyValuePair <string, int> >(modifiedStockOutOperations.GroupBy(x => x.LineItem.ProductId).Select(x => new KeyValuePair <string, int>(x.Key, x.Sum(y => y.Quantity))));

            var changedInventoryInfos = new List <InventoryInfo>();

            var inventoryInfos = _inventoryService.GetProductsInventoryInfos(originalPositions.Select(x => x.Key).Concat(modifiedPositions.Select(x => x.Key)).Distinct().ToArray());

            var comparer = AnonymousComparer.Create((KeyValuePair <string, int> x) => x.Key);

            modifiedPositions.CompareTo(originalPositions, comparer, (state, source, target) => { AdjustInventory(inventoryInfos, changedInventoryInfos, state, source, target); });

            if (changedInventoryInfos.Any())
            {
                _inventoryService.UpsertInventories(changedInventoryInfos);
            }
        }
Exemplo n.º 3
0
        public async Task <BaseResult> Create(ShipmentItem shipmentItem)
        {
            var rs = new BaseResult()
            {
                Result = Result.Success
            };

            var exists = _shipmentItemRepository.Query().Any(c => c.Id == shipmentItem.Id);

            if (exists)
            {
                rs.Result  = Result.Failed;
                rs.Message = "Tỉnh / thành phố đã tồn tại!";
                return(rs);
            }
            shipmentItem.CreatedTime = DateTime.Now.ToLocalTime();
            try
            {
                await _shipmentItemRepository.InsertAsync(shipmentItem);
            }
            catch (Exception ex)
            {
                rs.Result  = Result.SystemError;
                rs.Message = ex.ToString();
            }
            return(rs);
        }
        private async Task ManageStockByBundleProductsInventory(Product product, Shipment shipment, ShipmentItem shipmentItem)
        {
            foreach (var item in product.BundleProducts)
            {
                var p1 = await _productRepository.GetByIdAsync(item.ProductId);

                if (p1 != null && p1.Id != product.Id &&
                    p1.ManageInventoryMethodId != ManageInventoryMethod.DontManageStock)
                {
                    var _shipmentItem = new ShipmentItem()
                    {
                        Id          = shipmentItem.Id,
                        Attributes  = shipmentItem.Attributes,
                        OrderItemId = shipmentItem.OrderItemId,
                        ProductId   = shipmentItem.ProductId,
                        Quantity    = shipmentItem.Quantity * item.Quantity,
                        WarehouseId = shipmentItem.WarehouseId
                    };
                    if (!await CheckExistsInventoryJournal(p1, _shipmentItem))
                    {
                        await BookReservedInventory(p1, shipment, _shipmentItem);
                    }
                }
            }
        }
Exemplo n.º 5
0
        public async Task <ActionResult <ShipmentItem> > InsertShipmentItems(List <ShipmentItem> shipmentItem)
        //public JsonResult  InsertShipmentItems(List<ShipmentItem> shipmentItem)
        {
            int shipitemId = 0;
            int i          = 0;

            //Loop and insert records.
            foreach (ShipmentItem shipitem in shipmentItem)
            {
                //i = i + 1;
                ShipmentItem shipmentitem = new ShipmentItem
                {
                    Id             = shipitem.Id,
                    Commodity      = shipitem.Commodity,
                    DimensionsL    = shipitem.DimensionsL,
                    DimensionsH    = shipitem.DimensionsH,
                    DimensionsW    = shipitem.DimensionsW,
                    DimensionsUnit = shipitem.DimensionsUnit,
                    Weight         = shipitem.Weight,
                    WeightUnit     = shipitem.WeightUnit
                };

                _context.ShipmentItems.Add(shipmentitem);
                await _context.SaveChangesAsync();

                shipitemId = shipmentitem.ShipmentId;
            }
            //return Json(i);
            return(await PostShipmentItemJson(shipitemId));
        }
Exemplo n.º 6
0
        public async Task <BaseResult> Update(int Id, ShipmentItem shipmentItem)
        {
            var rs = new BaseResult()
            {
                Result = Result.Success
            };
            var shipmentItemForUpdate = _shipmentItemRepository.Query().FirstOrDefault(p => p.Id == shipmentItem.Id);

            if (shipmentItemForUpdate == null || shipmentItem.Id <= 0)
            {
                rs.Result  = Result.Failed;
                rs.Message = "Không tìm thấy đơn vận yêu cầu!";
                return(rs);
            }
            try
            {
                //shipmentItem = shipmentItem.ToShipmentItem(shipmentItemItem);
                shipmentItemForUpdate.ShipmentId  = shipmentItem.ShipmentId;
                shipmentItemForUpdate.Quantity    = shipmentItem.Quantity;
                shipmentItemForUpdate.OrderItemId = shipmentItem.OrderItemId;
                shipmentItemForUpdate.WareHouseId = shipmentItem.WareHouseId;
                await _shipmentItemRepository.UpdateAsync(shipmentItemForUpdate);
            }

            catch (Exception e)
            {
                rs.Result  = Result.SystemError;
                rs.Message = e.ToString();
            }

            return(rs);
        }
Exemplo n.º 7
0
        private async Task ManageStockInventory(Product product, Shipment shipment, ShipmentItem shipmentItem)
        {
            if (product.UseMultipleWarehouses)
            {
                var pwi = product.ProductWarehouseInventory.FirstOrDefault(pi => pi.WarehouseId == shipmentItem.WarehouseId);
                if (pwi == null)
                {
                    return;
                }

                pwi.ReservedQuantity -= shipmentItem.Quantity;
                pwi.StockQuantity    -= shipmentItem.Quantity;

                var builder = Builders <Product> .Filter;
                var filter  = builder.Eq(x => x.Id, product.Id);
                filter &= builder.Where(x => x.ProductWarehouseInventory.Any(y => y.WarehouseId == pwi.WarehouseId));

                var update = Builders <Product> .Update
                             .Set(x => x.ProductWarehouseInventory.ElementAt(-1), pwi)
                             .CurrentDate("UpdatedOnUtc");

                await _productRepository.Collection.UpdateOneAsync(filter, update);

                product.StockQuantity    = product.ProductWarehouseInventory.Sum(x => x.StockQuantity);
                product.ReservedQuantity = product.ProductWarehouseInventory.Sum(x => x.ReservedQuantity);
                await UpdateStockProduct(product);
            }
            else
            {
                product.ReservedQuantity -= shipmentItem.Quantity;
                product.StockQuantity    -= shipmentItem.Quantity;
                await UpdateStockProduct(product);
            }
        }
        private async Task ManageAttributesInventory(Product product, Shipment shipment, ShipmentItem shipmentItem)
        {
            var attributeValues = _productAttributeParser.ParseProductAttributeValues(product, shipmentItem.Attributes);

            foreach (var attributeValue in attributeValues)
            {
                if (attributeValue.AttributeValueTypeId == AttributeValueType.AssociatedToProduct)
                {
                    //associated product
                    var associatedProduct = await _productRepository.GetByIdAsync(attributeValue.AssociatedProductId);

                    if (associatedProduct != null &&
                        associatedProduct.Id != product.Id &&
                        associatedProduct.ManageInventoryMethodId != ManageInventoryMethod.DontManageStock)
                    {
                        if (!await CheckExistsInventoryJournal(associatedProduct, shipmentItem))
                        {
                            var _shipmentItem = new ShipmentItem()
                            {
                                Id          = shipmentItem.Id,
                                Attributes  = shipmentItem.Attributes,
                                OrderItemId = shipmentItem.OrderItemId,
                                ProductId   = shipmentItem.ProductId,
                                Quantity    = shipmentItem.Quantity * attributeValue.Quantity,
                                WarehouseId = shipmentItem.WarehouseId
                            };
                            await BookReservedInventory(associatedProduct, shipment, _shipmentItem);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Reverse booked inventory
        /// </summary>
        /// <param name="shipment">Shipment</param>
        /// <param name="shipmentItem">Shipment item</param>
        /// <returns>Quantity reversed</returns>
        public virtual async Task ReverseBookedInventory(Shipment shipment, ShipmentItem shipmentItem)
        {
            if (shipment == null)
            {
                throw new ArgumentNullException(nameof(shipment));
            }

            if (shipmentItem == null)
            {
                throw new ArgumentNullException(nameof(shipmentItem));
            }

            var inventoryJournals = _inventoryJournalRepository.Table.Where(j => j.PositionId == shipmentItem.Id);

            foreach (var inventoryJournal in inventoryJournals)
            {
                var product = _productRepository.GetById(inventoryJournal.ProductId);
                if (product == null)
                {
                    continue;
                }

                await ReverseBookedInventory(product, inventoryJournal);

                //cache
                await _cacheBase.RemoveByPrefix(string.Format(CacheKey.PRODUCTS_BY_ID_KEY, product.Id));

                //event notification
                await _mediator.EntityUpdated(product);
            }
        }
Exemplo n.º 10
0
        public static int spremi_preko(ShipmentItem d)
        {
            try
            {
                using (var db = new PodaciContext())
                {
                    ShipmentItem temp = db.ShipmentItems.Include("Shipment").FirstOrDefault(x => x.Barcode == d.Barcode);

                    if (temp != null)
                    {
                        d.Id          = temp.Id;
                        d.ShipmentId  = temp.ShipmentId;
                        d.Shipment.Id = temp.Shipment.Id;
                        db.Set <ShipmentItem>().AddOrUpdate(d);
                        db.Set <Shipment>().AddOrUpdate(d.Shipment);
                        //db.Entry(d).State = EntityState.Modified;
                        spremi_dodatno(db);
                        return(1);
                    }
                }
                return(-1);
            }
            catch (Exception ee)
            {
                return(-1);
            }
        }
        public virtual ShipmentItemEntity FromModel(ShipmentItem shipmentItem, PrimaryKeyResolvingMap pkMap)
        {
            if (shipmentItem == null)
                throw new ArgumentNullException(nameof(shipmentItem));

            Id = shipmentItem.Id;
            CreatedDate = shipmentItem.CreatedDate;
            CreatedBy = shipmentItem.CreatedBy;
            ModifiedDate = shipmentItem.ModifiedDate;
            ModifiedBy = shipmentItem.ModifiedBy;
            OuterId = shipmentItem.OuterId;

            BarCode = shipmentItem.BarCode;
            Quantity = shipmentItem.Quantity;

            pkMap.AddPair(shipmentItem, this);
            if (shipmentItem.LineItem != null)
            {
                LineItemId = shipmentItem.LineItem.Id;
                //Store ModelLineItem for future linking with the order line item only for new objects otherwise we will get error when saving
                if (shipmentItem.LineItem.IsTransient())
                {
                    ModelLineItem = shipmentItem.LineItem;
                }
            }

            return this;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Updates the shipment item
        /// </summary>
        /// <param name="shipmentItem">shipment item</param>
        public virtual void UpdateShipmentItem(ShipmentItem shipmentItem)
        {
            if (shipmentItem == null)
            {
                throw new ArgumentNullException("shipmentItem");
            }

            _siRepository.Update(shipmentItem);

            //event notifications
            _eventPublisher.EntityUpdated(shipmentItem);

            if (shipmentItem.Shipment != null && shipmentItem.Shipment.Order != null)
            {
                _eventPublisher.PublishOrderUpdated(shipmentItem.Shipment.Order);
            }
            else
            {
                var shipment = _shipmentRepository.Table
                               .Expand(x => x.Order)
                               .FirstOrDefault(x => x.Id == shipmentItem.ShipmentId);

                if (shipment != null)
                {
                    _eventPublisher.PublishOrderUpdated(shipment.Order);
                }
            }
        }
Exemplo n.º 13
0
        public static void otvori(string reception_number, ShipmentItem d, List <bool> povrat)
        {
            try
            {
                using (var db = new PodaciContext())
                {
                    ShipmentItem temp = db.ShipmentItems.Include("Shipment").FirstOrDefault(x => x.Barcode == reception_number);

                    if (temp != null)  // ovo dole se radi jer funkcija CRUD.otvori briše referencu na ShipmentItem(d)
                    {
                        var props = temp.GetType().GetProperties();

                        foreach (var prop in props)
                        {
                            string s = prop.PropertyType.Name;
                            if (prop.PropertyType.Name != "ObservableCollection`1")
                            {
                                prop.SetValue(d, prop.GetValue(temp, null));
                            }
                        }

                        povrat.Add(true);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Greška kod otvaranja");
            }
        }
        public virtual ShipmentItemEntity FromModel(ShipmentItem shipmentItem, PrimaryKeyResolvingMap pkMap)
        {
            if (shipmentItem == null)
            {
                throw new ArgumentNullException(nameof(shipmentItem));
            }

            Id           = shipmentItem.Id;
            CreatedBy    = shipmentItem.CreatedBy;
            CreatedDate  = shipmentItem.CreatedDate;
            ModifiedBy   = shipmentItem.ModifiedBy;
            ModifiedDate = shipmentItem.ModifiedDate;

            BarCode  = shipmentItem.BarCode;
            Quantity = shipmentItem.Quantity;

            //Preserve link of the  original model LineItem for future references binding LineItems with  ShipmentLineItems
            if (shipmentItem.LineItem != null)
            {
                ModelLineItem = shipmentItem.LineItem;
            }

            pkMap.AddPair(shipmentItem, this);

            return(this);
        }
Exemplo n.º 15
0
        public static ShipmentItemEntity ToDataModel(this ShipmentItem shipmentItem, ShoppingCartEntity cartEntity, PrimaryKeyResolvingMap pkMap)
        {
            if (shipmentItem == null)
            {
                throw new ArgumentNullException("shipmentItem");
            }

            var retVal = new ShipmentItemEntity();

            pkMap.AddPair(shipmentItem, retVal);
            retVal.InjectFrom(shipmentItem);

            //Try to find cart line item by shipment item
            if (!String.IsNullOrEmpty(shipmentItem.LineItemId))
            {
                retVal.LineItem = cartEntity.Items.FirstOrDefault(x => x.Id == shipmentItem.LineItemId);
            }
            if (retVal.LineItem == null && shipmentItem.LineItem != null)
            {
                retVal.LineItem = cartEntity.Items.FirstOrDefault(x => x.Id == shipmentItem.LineItem.Id);
            }
            if (retVal.LineItem == null && shipmentItem.LineItem != null)
            {
                retVal.LineItem = cartEntity.Items.FirstOrDefault(x => x.ProductId == shipmentItem.LineItem.ProductId);
            }
            if (retVal.LineItem != null && !String.IsNullOrEmpty(retVal.LineItem.Id))
            {
                retVal.LineItemId = retVal.LineItem.Id;
                retVal.LineItem   = null;
            }

            return(retVal);
        }
        public void Can_add_collection_item_items()
        {
            var order = TestOrderBuilder.BuildOrder().WithLineItemsCount(1).GetOrder();

            var repository = GetRepository();

            repository.Add(order);
            repository.UnitOfWork.Commit();

            order = repository.Orders.ExpandAll().FirstOrDefault();

            // adding new ShipmentItem
            var item = new ShipmentItem();

            item.Quantity = 1;
            item.LineItem = order.OrderForms[0].LineItems[0];

            // adding new Shipment
            var newShipment = new Shipment();

            newShipment.ShipmentItems.Add(item);
            order.OrderForms[0].Shipments.Add(newShipment);

            repository.UnitOfWork.Commit();
        }
Exemplo n.º 17
0
        public virtual ShipmentItemEntity FromModel(ShipmentItem shipmentItem, PrimaryKeyResolvingMap pkMap)
        {
            if (shipmentItem == null)
            {
                throw new ArgumentNullException(nameof(shipmentItem));
            }

            Id           = shipmentItem.Id;
            CreatedBy    = shipmentItem.CreatedBy;
            CreatedDate  = shipmentItem.CreatedDate;
            ModifiedBy   = shipmentItem.ModifiedBy;
            ModifiedDate = shipmentItem.ModifiedDate;

            BarCode  = shipmentItem.BarCode;
            Quantity = shipmentItem.Quantity;

            pkMap.AddPair(shipmentItem, this);
            if (shipmentItem.LineItem != null)
            {
                LineItemId = shipmentItem.LineItem.Id;
                if (shipmentItem.LineItem.IsTransient())
                {
                    ModelLineItem = shipmentItem.LineItem;
                }
            }

            return(this);
        }
        private void RaiseRemoveLineItemInteractionRequest(ShipmentItem removingItem)
        {
            var itemVM = _lineItemVmFactory.GetViewModelInstance();

            itemVM.Initialize(removingItem);

            CommonShipmentConfirmRequest.Raise(
                new ConditionalConfirmation {
                Title = "Item removal details".Localize(), Content = itemVM
            },
                (x) =>
            {
                if (x.Confirmed)
                {
                    // removing is moving item to fake shipment
                    var fakeShipment = new Shipment {
                        OrderForm = CurrentShipment.OrderForm
                    };
                    _currentOrder.MoveShippingItem(removingItem, itemVM.Quantity, fakeShipment, CurrentShipment);

                    // update LineItem Quantity or remove it completely
                    var lineItem = removingItem.LineItem;
                    if (lineItem.Quantity > itemVM.Quantity)
                    {
                        lineItem.Quantity -= itemVM.Quantity;
                    }
                    else
                    {
                        _currentOrder.OrderForms[0].LineItems.Remove(lineItem);
                    }

                    ParentViewModel.Recalculate();
                }
            });
        }
Exemplo n.º 19
0
        public static bool save_web_db(ShipmentItem d)
        {
            using (SqlConnection conn = sql_conn())
            {
                try
                {
                    conn.Open();
                    SqlCommand myCommand = new SqlCommand();
                    myCommand.Connection  = conn;
                    myCommand.CommandText = "UPDATE [ShipmentItems] SET RealWeightNet = @wt, Heigth = @he, Width = @wi Where Length = @le ";

                    myCommand.Parameters.AddWithValue("@wt", Funkcije.pretvori(d.RealWeightNet));

                    myCommand.Parameters.AddWithValue("@he", Funkcije.pretvori(d.Heigth));
                    myCommand.Parameters.AddWithValue("@wi", Funkcije.pretvori(d.Width));
                    myCommand.Parameters.AddWithValue("@le", Funkcije.pretvori(d.Length));



                    myCommand.ExecuteNonQuery();
                }
                catch (Exception ee)
                {
                    MessageBox.Show("Neuspjelo spajanje na web bazu!!", "Alert", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 20
0
        private async Task ManageStockInventory(Product product, Shipment shipment, ShipmentItem shipmentItem)
        {
            if (product.UseMultipleWarehouses)
            {
                var pwi = product.ProductWarehouseInventory.FirstOrDefault(pi => pi.WarehouseId == shipmentItem.WarehouseId);
                if (pwi == null)
                {
                    return;
                }

                pwi.ReservedQuantity -= shipmentItem.Quantity;
                pwi.StockQuantity    -= shipmentItem.Quantity;
                if (pwi.ReservedQuantity < 0)
                {
                    pwi.ReservedQuantity = 0;
                }

                await _productRepository.UpdateToSet(product.Id, x => x.ProductWarehouseInventory, z => z.Id, pwi.Id, pwi);

                await _productRepository.UpdateField(product.Id, x => x.UpdatedOnUtc, DateTime.UtcNow);

                product.StockQuantity    = product.ProductWarehouseInventory.Sum(x => x.StockQuantity);
                product.ReservedQuantity = product.ProductWarehouseInventory.Sum(x => x.ReservedQuantity);
                await UpdateStockProduct(product);
            }
            else
            {
                product.ReservedQuantity -= shipmentItem.Quantity;
                product.StockQuantity    -= shipmentItem.Quantity;
                await UpdateStockProduct(product);
            }
        }
Exemplo n.º 21
0
        private async Task <bool> CheckExistsInventoryJournal(Product product, ShipmentItem shipmentItem)
        {
            var query = from j in _inventoryJournalRepository.Table
                        where j.ProductId == product.Id && j.PositionId == shipmentItem.Id
                        select j.Id;

            return(await Task.FromResult(query.Any()));
        }
 public MainWindow()
 {
     d          = new ShipmentItem();
     d.Shipment = new Shipment();
     InitializeComponent();
     d.zip_popis    = ZP.zip_popis;
     d.Damage_popis = ZP.damage_popis;
     //update();
     Task.Run(UpdateApp);
 }
Exemplo n.º 23
0
        /// <summary>
        /// Updates the shipment item
        /// </summary>
        /// <param name="shipmentItem">Shipment item</param>
        public virtual void UpdateShipmentItem(ShipmentItem shipmentItem)
        {
            if (shipmentItem == null)
            {
                throw new ArgumentNullException("shipmentItem");
            }

            _siRepository.Update(shipmentItem);
            //_unitOfWork.Commit();
        }
Exemplo n.º 24
0
 public static ShipmentItemDto ToDto(this ShipmentItem shipmentItem)
 => new ShipmentItemDto
 {
     ShipmentItemId     = shipmentItem.ShipmentItemId,
     ShipmentId         = shipmentItem.ShipmentId,
     SalesOrderDetailId = shipmentItem.SalesOrderDetailId,
     BookingDetailId    = shipmentItem.BookingDetailId,
     Quantity           = shipmentItem.Quantity,
     Version            = shipmentItem.Version
 };
Exemplo n.º 25
0
        public async Task <SuperHSShipment> CreateShipment(SuperHSShipment superShipment, string supplierToken)
        {
            ShipmentItem firstShipmentItem = superShipment.ShipmentItems.First();
            string       supplierOrderID   = firstShipmentItem.OrderID;
            string       buyerOrderID      = supplierOrderID.Split("-").First();

            // in the platform, in order to make sure the order has the proper Order.Status, you must
            // create a shipment without a DateShipped and then patch the DateShipped after
            DateTimeOffset?dateShipped = superShipment.Shipment.DateShipped;

            superShipment.Shipment.DateShipped = null;


            await PatchLineItemStatuses(supplierOrderID, superShipment);

            string buyerID = await GetBuyerIDForSupplierOrder(firstShipmentItem.OrderID);

            superShipment.Shipment.BuyerID = buyerID;

            HSShipment ocShipment = await _oc.Shipments.CreateAsync <HSShipment>(superShipment.Shipment, accessToken : supplierToken);

            //  platform issue. Cant save new xp values onto shipment line item. Update order line item to have this value.
            var shipmentItemsWithComment = superShipment.ShipmentItems.Where(s => s.xp?.Comment != null);
            await Throttler.RunAsync(shipmentItemsWithComment, 100, 5, (shipmentItem) =>
            {
                dynamic comments                  = new ExpandoObject();
                var commentsByShipment            = comments as IDictionary <string, object>;
                commentsByShipment[ocShipment.ID] = shipmentItem.xp?.Comment;
                return(_oc.LineItems.PatchAsync(OrderDirection.Incoming, buyerOrderID, shipmentItem.LineItemID,
                                                new PartialLineItem()
                {
                    xp = new
                    {
                        Comments = commentsByShipment
                    }
                }));
            });

            IList <ShipmentItem> shipmentItemResponses = await Throttler.RunAsync(
                superShipment.ShipmentItems,
                100,
                5,
                (shipmentItem) => _oc.Shipments.SaveItemAsync(ocShipment.ID, shipmentItem, accessToken: supplierToken));

            HSShipment ocShipmentWithDateShipped = await _oc.Shipments.PatchAsync <HSShipment>(ocShipment.ID, new PartialShipment()
            {
                DateShipped = dateShipped
            }, accessToken : supplierToken);

            return(new SuperHSShipment()
            {
                Shipment = ocShipmentWithDateShipped,
                ShipmentItems = shipmentItemResponses.ToList()
            });
        }
Exemplo n.º 26
0
        //--------------------------         WEB BAZA         -----------------------------------------------------


        public static void open_web_db(ShipmentItem d)
        {
            using (SqlConnection conn = sql_conn())
            {
                try
                {
                    conn.Open();
                    SqlCommand myCommand = new SqlCommand("SELECT * FROM [ShipmentItems] INNER JOIN [Shipments] ON [ShipmentItems].[ShipmentId] = [Shipments].[Id] where Barcode='" + d.Barcode + "'", conn);


                    SqlDataReader myReader = null;

                    myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        popuni_sve_varijable_u_klasi(d, myReader);

                        //d.pickup_name = (myReader["pickup_name"].ToString());
                        //d.pickup_street = (myReader["pickup_street"].ToString());
                        //d.pickup_house_number = (myReader["pickup_house_number"].ToString());
                        //d.pickup_house_number_suffix = (myReader["pickup_house_number_suffix"].ToString());
                        //d.pickup_zip = (myReader["pickup_zip"].ToString());
                        //d.pickup_city = (myReader["pickup_city"].ToString());
                        //d.damage = Convert.ToInt32(pretvori(myReader["damage"].ToString()));
                        //d.weight = pretvori(myReader["weight"].ToString());
                    }
                    if (!myReader.HasRows)  // ne postoje podaci o pošiljci, provjerava se ID kupca
                    {
                        myReader.Close();
                        myCommand = new SqlCommand("SELECT * FROM [customers] where reception_number='" + d.Barcode + "'", conn);
                        myReader  = null;

                        myReader = myCommand.ExecuteReader();

                        while (myReader.Read())
                        {
                            prazni_sve_varijable_u_klasi(d);
                            d.Shipment.RecipientName = (myReader["RecipientName"].ToString());
                        }
                        if (!myReader.HasRows)
                        {
                            prazni_sve_varijable_u_klasi(d);
                            MessageBox.Show("Ne postoji prijamni broj u bazi!!");
                        }
                    }
                }
                catch (Exception ee)
                {
                    prazni_sve_varijable_u_klasi(d);
                    //Console.WriteLine(ee.ToString());
                    MessageBox.Show("Neuspjelo spajanje na web bazu!!", "Alert", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }
Exemplo n.º 27
0
		public static ShipmentItem ToCoreShipmentItemModel(this cartCoreModel.LineItem lineItem)
		{
			if (lineItem == null)
				throw new ArgumentNullException("lineItem");

			var retVal = new ShipmentItem();
			retVal.InjectFrom(lineItem);

			retVal.LineItem = lineItem.ToCoreModel();
			return retVal;
		}
Exemplo n.º 28
0
		public static ShipmentItem ToOrderCoreModel(this cartCoreModel.ShipmentItem shipmentItem)
		{
			if (shipmentItem == null)
				throw new ArgumentNullException("shipmentItem");

			var retVal = new ShipmentItem();
			retVal.InjectFrom(shipmentItem);

			retVal.LineItem = shipmentItem.LineItem.ToOrderCoreModel();
			return retVal;
		}
        public virtual ShipmentItem ToModel(ShipmentItem shipmentItem)
        {
            if (shipmentItem == null)
            {
                throw new ArgumentNullException(nameof(shipmentItem));
            }

            shipmentItem.InjectFrom(this);

            return(shipmentItem);
        }
Exemplo n.º 30
0
        public SplitShipmentViewModel(IViewModelsFactory <IOrderAddressViewModel> addressVmFactory, IOrderEntityFactory entityFactory, IShippingRepository shippingRepository, Foundation.Orders.Model.Order currentOrder, Shipment sourceShipment, ShipmentItem movingItem)
        {
            _addressVmFactory   = addressVmFactory;
            _shippingRepository = shippingRepository;
            _entityFactory      = entityFactory;
            CurrentOrder        = currentOrder;
            SourceShipment      = sourceShipment;
            MovingShippingItem  = movingItem;

            CreateNewAddressRequest = new InteractionRequest <Confirmation>();
        }
Exemplo n.º 31
0
        public LiquidShipmentItem(ShipmentItem shipmentItem, Shipment shipment, Order order, OrderItem orderItem, Product product, Language language)
        {
            this._shipmentItem = shipmentItem;
            this._language     = language;
            this._shipment     = shipment;
            this._order        = order;
            this._orderItem    = orderItem;
            this._product      = product;

            AdditionalTokens = new Dictionary <string, string>();
        }
Exemplo n.º 32
0
        /// <summary>
        /// Updates the shipment item
        /// </summary>
        /// <param name="shipmentItem">Shipment item</param>
        public virtual void UpdateShipmentItem(ShipmentItem shipmentItem)
        {
            if (shipmentItem == null)
            {
                throw new ArgumentNullException(nameof(shipmentItem));
            }

            _siRepository.Update(shipmentItem);

            //event notification
            _eventPublisher.EntityUpdated(shipmentItem);
        }
Exemplo n.º 33
0
		public static ShipmentItem ToCoreModel(this ShipmentItemEntity entity)
		{
			if (entity == null)
				throw new ArgumentNullException("entity");

			var retVal = new ShipmentItem();
			retVal.InjectFrom(entity);

			if(entity.LineItem != null)
			{
				retVal.LineItem = entity.LineItem.ToCoreModel();
			}
			return retVal;
		}