public static ShipmentEntity ToDataModel(this Shipment shipment, ShoppingCartEntity cartEntity, PrimaryKeyResolvingMap pkMap)
        {
            if (shipment == null)
            {
                throw new ArgumentNullException("shipment");
            }

            var retVal = new ShipmentEntity();

            pkMap.AddPair(shipment, retVal);

            retVal.InjectFrom(shipment);

            retVal.Currency = shipment.Currency.ToString();

            if (shipment.DeliveryAddress != null)
            {
                retVal.Addresses = new ObservableCollection <AddressEntity>(new AddressEntity[] { shipment.DeliveryAddress.ToDataModel() });
            }
            if (shipment.Items != null)
            {
                retVal.Items = new ObservableCollection <ShipmentItemEntity>(shipment.Items.Select(x => x.ToDataModel(cartEntity, pkMap)));
            }
            if (shipment.TaxDetails != null)
            {
                retVal.TaxDetails = new ObservableCollection <TaxDetailEntity>();
                retVal.TaxDetails.AddRange(shipment.TaxDetails.Select(x => x.ToDataModel()));
            }
            if (shipment.Discounts != null)
            {
                retVal.Discounts = new ObservableCollection <DiscountEntity>();
                retVal.Discounts.AddRange(shipment.Discounts.Select(x => x.ToDataModel(pkMap)));
            }
            return(retVal);
        }
        public static ShipmentEntity ToDataModel(this Shipment shipment, CustomerOrderEntity orderEntity)
        {
            if (shipment == null)
            {
                throw new ArgumentNullException("shipment");
            }

            var retVal = new ShipmentEntity();

            retVal.InjectFrom(shipment);

            retVal.Currency = shipment.Currency.ToString();


            //Allow to empty address
            retVal.Addresses = new ObservableCollection <AddressEntity>();
            if (shipment.DeliveryAddress != null)
            {
                retVal.Addresses = new ObservableCollection <AddressEntity>(new AddressEntity[] { shipment.DeliveryAddress.ToDataModel() });
            }
            if (shipment.Items != null)
            {
                retVal.Items = new ObservableCollection <ShipmentItemEntity>(shipment.Items.Select(x => x.ToDataModel(orderEntity)));
            }
            if (shipment.Packages != null)
            {
                retVal.Packages = new ObservableCollection <ShipmentPackageEntity>(shipment.Packages.Select(x => x.ToDataModel(orderEntity)));
            }
            if (shipment.TaxDetails != null)
            {
                retVal.TaxDetails = new ObservableCollection <TaxDetailEntity>();
                retVal.TaxDetails.AddRange(shipment.TaxDetails.Select(x => x.ToDataModel()));
            }
            return(retVal);
        }
        public static Shipment ToCoreModel(this ShipmentEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            var retVal = new Shipment();

            retVal.InjectFrom(entity);

            retVal.Currency = entity.Currency;
            if (entity.Addresses != null && entity.Addresses.Any())
            {
                retVal.DeliveryAddress = entity.Addresses.First().ToCoreModel();
            }

            if (entity.Items != null)
            {
                retVal.Items = entity.Items.Select(x => x.ToCoreModel()).ToList();
            }
            retVal.TaxDetails = entity.TaxDetails.Select(x => x.ToCoreModel()).ToList();
            retVal.Discounts  = entity.Discounts.Select(x => x.ToCoreModel()).ToList();
            return(retVal);
        }
Esempio n. 4
0
        public override void Patch(ShipmentEntity target)
        {
            base.Patch(target);
            var shipmentExtensionEntity = target as CartShipmentExtensionEntity;

            shipmentExtensionEntity.shipmentDate = this.shipmentDate;
        }
        /// <summary>
        /// Patch CatalogBase type
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        public static void Patch(this ShipmentEntity source, ShipmentEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            var patchInjection = new PatchInjection <ShipmentEntity>(x => x.ShipmentMethodCode, x => x.Total,
                                                                     x => x.ShippingPrice, x => x.DiscountTotal, x => x.TaxTotal,
                                                                     x => x.TaxIncluded, x => x.Currency,
                                                                     x => x.WeightUnit, x => x.WeightValue,
                                                                     x => x.DimensionHeight, x => x.DimensionLength, x => x.DimensionUnit,
                                                                     x => x.DimensionWidth, x => x.TaxType);

            target.InjectFrom(patchInjection, source);


            if (!source.Addresses.IsNullCollection())
            {
                source.Addresses.Patch(target.Addresses, new AddressComparer(), (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress));
            }
            if (source.Items != null)
            {
                source.Items.Patch(target.Items, (sourceItem, targetItem) => sourceItem.Patch(targetItem));
            }
            if (!source.TaxDetails.IsNullCollection())
            {
                var taxDetailComparer = AnonymousComparer.Create((TaxDetailEntity x) => x.Name);
                source.TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
            }
            if (!source.Discounts.IsNullCollection())
            {
                source.Discounts.Patch(target.Discounts, new DiscountComparer(), (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount));
            }
        }
Esempio n. 6
0
        public void ToEntity_WithValidDomain_ShouldMapCorrectly()
        {
            //Arrange
            var shipment = _fixture.Create <Shipment>();

            var expected = new ShipmentEntity
            {
                ShipmentId         = shipment.ShipmentId,
                PackageId          = shipment.PackageId.GetValueOrDefault(),
                IsStoppedInCustoms = shipment.IsStoppedInCustoms,
                Status             = shipment.Status,
                ReceivedDate       = shipment.ReceivedDate,
                CheckPoint         = shipment.CheckPoint.ToEntity(),
                CreatedAt          = shipment.CreatedAt,
                UpdatedAt          = shipment.UpdatedAt
            };

            //Act
            var actualShipmentEntity = shipment.ToEntity();

            //Assert
            actualShipmentEntity
            .Should()
            .BeEquivalentTo(expected);
        }
 public int CreateOrUpdateByQuery(ShipmentEntity shipmentEntity)
 {
     try
     {
         return(_unitOfWork.ShipmentRepository.ExecuteUpdateQuery(string.Format("INSERT [dbo].[ShipmentInfor] ([ShipmentId], [Sender], [Receiver], [TelReceiver], [TotalValue], [Descrition], [BoxId], [Status], [EmployeeId], [WarehouseId], [IsSyncOms], [Weight], [DeclarationNo], [Country], [Address], [Consignee], [Content], [NumberPackage], [DateOfCompletion]) VALUES (N'{0}', N'{1}', N'{2}', N'{3}', N'{4}', N'{5}', {6}, N'{7}', {8}, {9}, N'{10}', N'{11}', N'{12}', N'{13}',N'{14}', N'{15}', N'{16}', {17}, N'{18}')", shipmentEntity.ShipmentId, shipmentEntity.Sender, shipmentEntity.Receiver, shipmentEntity.ReceiverTel, null, shipmentEntity.Description, shipmentEntity.BoxId, null, shipmentEntity.EmployeeId, shipmentEntity.WarehouseId, null, shipmentEntity.Weight, shipmentEntity.DeclarationNo, shipmentEntity.Country, shipmentEntity.Address, shipmentEntity.Consignee, shipmentEntity.Content, shipmentEntity.NumberPackage, shipmentEntity.DateOfCompletion)));
     }
     catch
     {
         return(_unitOfWork.ShipmentRepository.ExecuteUpdateQuery(string.Format("Update [dbo].[ShipmentInfor] set [ShipmentId]=N'{0}', [Sender]=N'{1}', [Receiver]=N'{2}', [TelReceiver]=N'{3}', [TotalValue]={4}, [Descrition]=N'{5}', [BoxId]={6}, [Status]=N'{7}', [EmployeeId]={8}, [WarehouseId]={9}, [IsSyncOms]=N'{10}', [Weight]={11}, [DeclarationNo]=N'{12}', [Country]=N'{13}', [Address]=N'{14}', [Consignee]=N'{15}', [Content]=N'{16}', [NumberPackage]={17}, [DateOfCompletion]=N'{18}' where  Id = {19})", shipmentEntity.ShipmentId, shipmentEntity.Sender, shipmentEntity.Receiver, shipmentEntity.ReceiverTel, null, shipmentEntity.Description, shipmentEntity.BoxId, null, shipmentEntity.EmployeeId, shipmentEntity.WarehouseId, null, shipmentEntity.Weight, shipmentEntity.DeclarationNo, shipmentEntity.Country, shipmentEntity.Address, shipmentEntity.Consignee, shipmentEntity.Content, shipmentEntity.NumberPackage, shipmentEntity.DateOfCompletion, shipmentEntity.Id)));
     }
 }
Esempio n. 8
0
 public int Create(ShipmentEntity shipmentEntity)
 {
     using (var scope = new TransactionScope())
     {
         Mapper.CreateMap <ShipmentEntity, ShipmentInforTemp>();
         var shipmentDataModel = Mapper.Map <ShipmentEntity, ShipmentInforTemp>(shipmentEntity);
         _unitOfWork.ShipmentTempRepository.Insert(shipmentDataModel);
         _unitOfWork.SaveWinform();
         scope.Complete();
         return(shipmentDataModel.Id);
     }
 }
Esempio n. 9
0
        public async Task AutoUpdate(string id, bool toggle)
        {
            try
            {
                await ShipmentEntity.ValidateId(id);

                await ShipmentDAO.Methods.UpdateSet.AutoUpdate(id, toggle);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 10
0
        public async Task <Shipment> ById(string id)
        {
            try
            {
                await ShipmentEntity.ValidateId(id);

                return(await ShipmentDAO.Methods.GetBy.Id(id));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 11
0
        private void SaveShipmentOut(object position, ShipmentOutEntity shipmentOut)
        {
            int rowIndex = (int)position;

            if (grvShipmentListOut != null && grvShipmentListOut.Rows.Count > 0)
            {
                string shipmentId = Convert.ToString(grvShipmentListOut[SHIPMENT_NO, 0].Value);
                if (nhapMoiKhongCanXacNhan)
                {
                    ShipmentEntity shipment = new ShipmentEntity();
                    shipment.ShipmentId  = shipmentId;
                    shipment.BoxId       = currentBoxOut.Id;
                    shipment.DateCreated = DateTime.Now;
                    shipment.WarehouseId = FormLogin.mWarehouse.Id;
                    shipment.EmployeeId  = currentEmployee.Id;
                    string package = Convert.ToString(grvShipmentListOut[PACKAGE, 0].Value);
                    if (string.IsNullOrEmpty(package))
                    {
                        shipment.NumberPackage = 1;
                    }
                    else
                    {
                        shipment.NumberPackage = Int32.Parse(Convert.ToString(grvShipmentListOut[PACKAGE, 0].Value));
                    }
                    shipment.Sender        = Convert.ToString(grvShipmentListOut[COMPANYNAME, 0].Value);
                    shipment.DeclarationNo = Convert.ToString(grvShipmentListOut[DECLARATIONNO, 0].Value);
                    shipment.Address       = Convert.ToString(grvShipmentListOut[ADDRESS, 0].Value);
                    shipment.Content       = Convert.ToString(grvShipmentListOut[CONTENT, 0].Value);
                    shipment.Destination   = Convert.ToString(grvShipmentListOut[CONSIGNEE, 0].Value);
                    shipment.Consignee     = Convert.ToString(grvShipmentListOut[CONSIGNEE, 0].Value);
                    shipment.Receiver      = Convert.ToString(grvShipmentListOut[CONTACTNAME, 0].Value);
                    string weight = Convert.ToString(grvShipmentListOut[WEIGHT, 0].Value);
                    if (string.IsNullOrEmpty(weight))
                    {
                        shipment.Weight = 0d;
                    }
                    else
                    {
                        shipment.Weight = Double.Parse(Convert.ToString(grvShipmentListOut[WEIGHT, 0].Value));
                    }
                    shipment.Country          = Convert.ToString(grvShipmentListOut[COUNTRY, 0].Value);
                    shipment.DateOfCompletion = null;
                    if (grvShipmentListOut[DATEOFCOMPLETION, 0].Value != null)
                    {
                        shipment.DateOfCompletion = Convert.ToDateTime(grvShipmentListOut[DATEOFCOMPLETION, rowIndex - 10].Value);
                    }
                    _shipmentServices.CreateOrUpdateByQuery(shipment);
                }
                _shipmentOutServices.CreateOrUpdateByQuery(shipmentOut);
            }
        }
Esempio n. 12
0
        private ShipmentModifierSetter GetBeingTransportedSetter()
        {
            var hasAtLeastOneEvent = Shipment.ForwardingEvents.Count > 0;

            if (hasAtLeastOneEvent)
            {
                var length = Shipment.ForwardingEvents.Count;
                return(Shipment.ForwardingEvents[length].GetModifiers().BeignTransportedSetter);
            }
            else
            {
                return(ShipmentEntity.GetEmpityModifier().BeignTransportedSetter);
            }
        }
Esempio n. 13
0
 public static Shipment ToDomain(this ShipmentEntity shipment)
 {
     return(shipment == null
                         ? null
                         : new Shipment(
                shipmentId: shipment.ShipmentId,
                packageId: shipment.PackageId,
                isStoppedInCustom: shipment.IsStoppedInCustoms,
                status: shipment.Status,
                receivedDate: shipment.ReceivedDate,
                checkPoint: shipment.CheckPoint.ToDomain(),
                createdAt: shipment.CreatedAt,
                updatedAt: shipment.UpdatedAt));
 }
Esempio n. 14
0
        public async Task PackageId(string id, string packageId)
        {
            try
            {
                await PackageEntity.ValidatePackageId(packageId);

                await ShipmentEntity.ValidateId(id);

                await ShipmentDAO.Methods.UpdateSet.PackageId(id, packageId);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 15
0
        public static async Task RunAutoUpdateById(string id)
        {
            try
            {
                await ShipmentEntity.ValidateId(id);

                var shipment = await ShipmentUseCases.Get.ById(id);

                await ShipmentUseCases.UpdateShipmentWithBoundry(shipment);
            }
            catch (Exception e)
            {
                throw;
            }
        }
Esempio n. 16
0
 public ShipmentGoodEntity(ShipmentGoods shipmentGood, params object[] args)
 {
     this.Id         = shipmentGood.Id;
     this.ShipmentId = shipmentGood.ShipmentId;
     this.GoodsId    = shipmentGood.GoodsId;
     foreach (var arg in args)
     {
         if (arg is Shipment)
         {
             this.Shipment = shipmentGood.Shipment == null ? null : new ShipmentEntity(arg as Shipment);
         }
         if (arg is Goods)
         {
             this.Goods = shipmentGood.Goods == null ? null : new GoodsEntity(arg as Goods);
         }
     }
 }
Esempio n. 17
0
        public static Shipment ToCoreModel(this ShipmentEntity entity, IEnumerable <ShippingMethod> shippingMethods, IEnumerable <PaymentMethod> paymentMethods)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            var retVal = new Shipment();

            retVal.InjectFrom(entity);
            retVal.Currency = entity.Currency;

            if (entity.Addresses != null && entity.Addresses.Any())
            {
                retVal.DeliveryAddress = entity.Addresses.First().ToCoreModel();
            }
            if (entity.Discounts != null && entity.Discounts.Any())
            {
                retVal.Discount = entity.Discounts.First().ToCoreModel();
            }
            if (entity.Items != null)
            {
                retVal.Items = entity.Items.Select(x => x.ToCoreModel()).ToList();
            }
            if (entity.InPayments != null)
            {
                retVal.InPayments = entity.InPayments.Select(x => x.ToCoreModel(paymentMethods)).ToList();
            }
            if (entity.Packages != null)
            {
                retVal.Packages = entity.Packages.Select(x => x.ToCoreModel()).ToList();
            }
            retVal.TaxDetails = entity.TaxDetails.Select(x => x.ToCoreModel()).ToList();

            //Set shipment method for shipment by code
            if (shippingMethods != null)
            {
                retVal.ShippingMethod = shippingMethods.FirstOrDefault(x => String.Equals(x.Code, entity.ShipmentMethodCode, StringComparison.InvariantCultureIgnoreCase));
            }


            return(retVal);
        }
Esempio n. 18
0
        private void button1_Click(object sender, EventArgs e)
        {
            ShipmentEntity    shipment    = new ShipmentEntity();
            ShipmentOutEntity shipmentout = new ShipmentOutEntity();

            if (String.IsNullOrWhiteSpace(txtShipment.Text) || String.IsNullOrWhiteSpace(txtShipment.Text))
            {
                MessageBox.Show("Bạn phải nhập mã đơn hàng để tìm kiếm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            try
            {
                string input = txtShipment.Text.Trim().ToUpper();
                lblTitle.Text = input;
                // Shipment out
                shipmentout = _shipmentOutServices.GetByShipmentId(input);
                if (shipmentout != null)
                {
                    lblShipment.Text = "Thông tin xuất kho: " + shipmentout.MasterBillIdString + System.Environment.NewLine + shipmentout.BoxIdString + "(" + shipmentout.DateOut.ToString("d MMM yyyy") + ")";
                }
                // Shipment in
                shipment = _repositoryShipment.GetShipment(input);
                if (shipment != null)
                {
                    lblDelivery.Text = "Thông tin đơn hàng: " + shipment.Receiver + " - " + shipment.ReceiverTel + System.Environment.NewLine + "Địa chỉ: " + shipment.Address;
                }
                // Ecuss
                if (_shipmentOutServices.GetStatusCompletion(input))
                {
                    lblEcus.ForeColor = Color.Green;
                    lblEcus.Text      = "Đã thông quan.";
                }
                else
                {
                    lblEcus.ForeColor = Color.OrangeRed;
                    lblEcus.Text      = "Chưa thông quan.";
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Patch CatalogBase type
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        public static void Patch(this ShipmentEntity source, ShipmentEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }


            target.ShipmentMethodCode = source.ShipmentMethodCode;
            target.Total                = source.Total;
            target.ShippingPrice        = source.ShippingPrice;
            target.DiscountTotal        = source.DiscountTotal;
            target.TaxTotal             = source.TaxTotal;
            target.TaxIncluded          = source.TaxIncluded;
            target.Currency             = source.Currency;
            target.WeightUnit           = source.WeightUnit;
            target.WeightValue          = source.WeightValue;
            target.DimensionHeight      = source.DimensionHeight;
            target.DimensionLength      = source.DimensionLength;
            target.DimensionUnit        = source.DimensionUnit;
            target.DimensionWidth       = source.DimensionWidth;
            target.TaxType              = source.TaxType;
            target.ShipmentMethodOption = source.ShipmentMethodOption;

            if (!source.Addresses.IsNullCollection())
            {
                source.Addresses.Patch(target.Addresses, new AddressComparer(), (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress));
            }
            if (source.Items != null)
            {
                source.Items.Patch(target.Items, (sourceItem, targetItem) => sourceItem.Patch(targetItem));
            }
            if (!source.TaxDetails.IsNullCollection())
            {
                var taxDetailComparer = AnonymousComparer.Create((TaxDetailEntity x) => x.Name);
                source.TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
            }
            if (!source.Discounts.IsNullCollection())
            {
                source.Discounts.Patch(target.Discounts, new DiscountComparer(), (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount));
            }
        }
Esempio n. 20
0
        private ShipmentEntity convertFromManifest(ManifestEntity manifest)
        {
            ShipmentEntity shipment = new ShipmentEntity();

            shipment.ShipmentId    = manifest.ShipmentNo;
            shipment.BoxId         = currentBoxIdInt;
            shipment.DateCreated   = DateTime.Now;
            shipment.WarehouseId   = FormLogin.mWarehouse.Id;
            shipment.EmployeeId    = currentEmployee.Id;
            shipment.NumberPackage = manifest.Quantity;
            shipment.Sender        = manifest.CompanyName;
            shipment.Address       = manifest.Address;
            shipment.Content       = manifest.Content;
            shipment.Destination   = manifest.Destination;
            shipment.Consignee     = manifest.Destination;
            shipment.Receiver      = manifest.ContactName;
            shipment.Weight        = manifest.Weight;
            shipment.Country       = manifest.Country;
            return(shipment);
        }
Esempio n. 21
0
        private void txtShipmentId_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (String.IsNullOrEmpty(txtShipmentId.Text) || String.IsNullOrWhiteSpace(txtShipmentId.Text))
            {
                return;
            }

            if (e.KeyChar == (char)Keys.Enter || e.KeyChar == (char)Keys.Tab)
            {
                if (IsExistsOnTheGridView(grvShipments, txtShipmentId.Text))
                {
                    MessageBox.Show("Tìm thấy đơn hàng vừa nhập đã có trên lưới", "Đơn hàng trùng lặp");
                    txtShipmentId.Text = String.Empty;
                    return;
                }

                if (_shipmentServices.GetByShipmentId(txtShipmentId.Text) != null)
                {
                    MessageBox.Show("Mã đơn hàng vừa nhập đã có trong kho nên không thể nhập kho", "Đơn hàng đã tồn tại", MessageBoxButtons.OK);
                    txtShipmentId.Text = String.Empty;
                    return;
                }

                // Thêm shipment vào lưới để nhập kho
                string dateOfCreation = _shipmentServices.GetDateOfCompletion(txtShipmentId.Text);//_shipmentServices.GetDeclarationNo(txtShipmentId.Text)
                grvShipments.Rows.Add(grvShipments.Rows.Count + 1, cbbMasterBill.Text, 0, txtShipmentId.Text, null, null
                                      , null, null, null, null, null, 1, null, dateOfCreation);
                ShipmentEntity item = new ShipmentEntity();
                item.BoxId       = currentBoxIdInt;
                item.BoxIdString = currentBoxId;
                item.ShipmentId  = txtShipmentId.Text;
                item.Mawb        = cbbMasterBill.Text;

                _shipmentServices.CreateOrUpdate(item);
                grvShipments.ClearSelection();
                grvShipments.Rows[grvShipments.Rows.Count - 1].Selected = true;
                grvShipments.FirstDisplayedScrollingRowIndex            = grvShipments.Rows.Count - 1;
                UpdateValueOverviewNhapKho();
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Patch CatalogBase type
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        public static void Patch(this ShipmentEntity source, ShipmentEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            source.Patch((OperationEntity)target);

            var patchInjectionPolicy = new PatchInjection <ShipmentEntity>(x => x.FulfillmentCenterId, x => x.OrganizationId, x => x.EmployeeId, x => x.Height, x => x.Length,
                                                                           x => x.Width, x => x.MeasureUnit, x => x.WeightUnit, x => x.Weight, x => x.TaxType, x => x.DiscountAmount);

            target.InjectFrom(patchInjectionPolicy, source);

            if (!source.InPayments.IsNullCollection())
            {
                source.InPayments.Patch(target.InPayments, (sourcePayment, targetPayment) => sourcePayment.Patch(targetPayment));
            }
            if (!source.Items.IsNullCollection())
            {
                source.Items.Patch(target.Items, (sourceItem, targetItem) => sourceItem.Patch(targetItem));
            }
            if (!source.Discounts.IsNullCollection())
            {
                source.Discounts.Patch(target.Discounts, new DiscountComparer(), (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount));
            }
            if (!source.Addresses.IsNullCollection())
            {
                source.Addresses.Patch(target.Addresses, new AddressComparer(), (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress));
            }
            if (!source.Packages.IsNullCollection())
            {
                source.Packages.Patch(target.Packages, (sourcePackage, targetPackage) => sourcePackage.Patch(targetPackage));
            }
            if (!source.TaxDetails.IsNullCollection())
            {
                var taxDetailComparer = AnonymousComparer.Create((TaxDetailEntity x) => x.Name);
                source.TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
            }
        }
        public int CreateOrUpdate(ShipmentEntity shipmentEntity)
        {
            using (var scope = new TransactionScope())
            {
                Mapper.CreateMap <ShipmentEntity, ShipmentInfor>();
                var shipmentDataModel = Mapper.Map <ShipmentEntity, ShipmentInfor>(shipmentEntity);
                var original          = _unitOfWork.ShipmentRepository.Get(t => t.ShipmentId == shipmentDataModel.ShipmentId);
                if (original != null)
                {
                    shipmentDataModel.Id          = original.Id;
                    shipmentDataModel.DateCreated = original.DateCreated;
                    _unitOfWork.ShipmentRepository.Update(original, shipmentDataModel);
                }
                else
                {
                    _unitOfWork.ShipmentRepository.Insert(shipmentDataModel);
                }

                _unitOfWork.SaveWinform();
                scope.Complete();
                return(shipmentDataModel.Id);
            }
        }
Esempio n. 24
0
        public static async Task CreateNewShipment(NewShipmentRequest request)
        {
            try
            {
                var package = PackageFactory.CreatePackage(request.PackageData);
                await PackageEntity.ValidateNew(package);

                var shipment = ShipmentFactory.CreateShipment(request);
                await ShipmentEntity.ValidateNew(shipment);

                await PackageUseCases.RegisterPackage.Execute(package);

                await ShipmentUseCases.RegisterShipment.Execute(shipment);

                await ShipmentUseCases.Set.PackageId(shipment.Id.ToString(), package.Id.ToString());

                await ShipmentUseCases.UpdateShipmentWithBoundry(shipment);
            }
            catch (Exception e)
            {
                throw;
            }
        }
        public ActionResult Create([FromBody] ShipmentViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var shipmentEntity = new ShipmentEntity
                    {
                        Title     = model.Title,
                        IdService = model.IdService
                    };

                    var createdEntity = _shipmentService.CreateShipment(shipmentEntity);

                    ViewBag.RegisteredUser = true;
                    return(RedirectToAction("Details", new { id = createdEntity.IdShipment }));
                }
            }
            catch
            {
                ModelState.AddModelError("", "Nepavyko sukurti vartotojo!");
            }
            return(View(model));
        }
Esempio n. 26
0
        private void txtShipmentIdOut_KeyDown(object sender, KeyEventArgs e)
        {
            string         shipmentinput = txtShipmentIdOut.Text.Trim().ToUpper();
            ShipmentEntity shipment      = new ShipmentEntity();

            try
            {
                if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Enter)
                {
                    if (String.IsNullOrEmpty(shipmentinput) || String.IsNullOrWhiteSpace(txtShipmentIdOut.Text))
                    {
                        return;
                    }
                    if (startProcessing)
                    {
                        return;
                    }
                    startProcessing = true;
                    #region Kiểm tra trùng trên lưới nhập
                    if (IsExistsOnTheGridView(grvShipmentListOut, shipmentinput))
                    {
                        beep7.Play();
                        txtShipmentIdOut.Enabled = false;
                        int             rowIndex = -1;
                        DataGridViewRow row      = grvShipmentListOut.Rows
                                                   .Cast <DataGridViewRow>()
                                                   .Where(r => r.Cells[0].Value.ToString().Equals(shipmentinput))
                                                   .First();
                        rowIndex = row.Index;
                        grvShipmentListOut.Rows[rowIndex].Selected = true;
                        MessageBox.Show("TRÙNG DỮ LIỆU TRÊN LƯỚI !!!\nBạn hãy kiểm tra dữ liệu vừa nhập!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        txtShipmentIdOut.Enabled = true;
                        txtShipmentIdOut.Text    = String.Empty;
                        txtShipmentNo.Text       = "";
                        txtShipmentIdOut.Focus();
                        startProcessing = false;
                        return;
                    }
                    #endregion
                    #region Kiểm tra trùng trên thùng đã xuất
                    if (_repositoryShipment.ShipmentOutExist(shipmentinput))
                    {
                        beep7.Play();
                        txtShipmentIdOut.Enabled = false;
                        MessageBox.Show("TRÙNG DỮ LIỆU TRÊN THÙNG ĐÃ XUẤT KHO !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtShipmentIdOut.Enabled = true;
                        txtShipmentIdOut.Text    = String.Empty;
                        txtShipmentNo.Text       = "";
                        txtShipmentIdOut.Focus();
                        startProcessing = false;
                        return;
                    }
                    #endregion
                    #region Kiểm tra vị trí thùng
                    if (_repositoryShipment.ShipmentExist(shipmentinput))
                    {
                        beep7.Play();
                        manifestnew = new ManifestEntity();
                        manifestnew = _repositoryShipment.GetManifestByShipmentNo(shipmentinput);
                        if (manifestnew.BoxID != cbbBoxIdOut.Text.Trim())
                        {
                            txtShipmentIdOut.Enabled = false;
                            if (MessageBox.Show("LẠC HƯỚNG THÙNG !!! \nDữ liệu bạn nhập có thể nằm ở thùng: " + manifestnew.BoxID + "(" + manifestnew.MasterAirWayBill + ")\nBạn có muốn tiếp tục không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                            {
                                txtShipmentIdOut.Enabled = true;
                                txtShipmentIdOut.Text    = String.Empty;
                                txtShipmentNo.Text       = "";
                                startProcessing          = false;
                                return;
                            }
                        }
                    }
                    #endregion
                    #region Kiểm tra hàng thông quan
                    if (!_shipmentOutServices.GetStatusCompletion(shipmentinput))
                    {
                        beep.Play();
                        txtShipmentIdOut.BackColor = Color.Tomato;
                        if (MessageBox.Show("Hàng chưa được phép thông quan. \nBạn có muốn tiếp tục không ?", "Hàng chưa được phép thông quan", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                        {
                            txtShipmentIdOut.Enabled = true;
                            startProcessing          = false;
                            txtShipmentIdOut.Text    = "";
                            txtShipmentIdOut.Focus();
                            txtShipmentNo.Text         = "";
                            txtShipmentIdOut.BackColor = Color.LightYellow;
                            return;
                        }
                        else
                        {
                            txtShipmentIdOut.BackColor = Color.LightYellow;
                        }
                    }
                    #endregion
                    try
                    {
                        //grvShipmentListOut.Rows.Add(grvShipmentListOut.Rows.Count + 1, shipmentinput, DateTime.Now, Math.Round(manifestnew.Weight, 3));
                        grvShipmentListOut.Rows.Insert(0, shipmentinput, DateTime.Now, Math.Round(manifestnew.Weight, 3));
                        // grvShipmentListOut.FirstDisplayedScrollingRowIndex = grvShipmentListOut.RowCount - 1;
                        grvShipmentListOut.FirstDisplayedScrollingRowIndex = 0;
                        lblShipmentScanedOut.Text = "" + grvShipmentListOut.Rows.Count;
                        numberShipmentOut++;
                        grvShipmentListOut.ClearSelection();
                        grvShipmentListOut.Rows[0].Selected = true;
                        //  grvShipmentListOut.Rows[grvShipmentListOut.Rows.Count - 1].Selected = true;
                        //  AddOneShipmentToGridView(grvShipmentListOut.Rows.Count + 1, shipmentexport, grvShipmentListOut);
                    }
                    catch
                    {
                        startProcessing = false;
                    }
                    ShipmentOutEntity shipmentOut = new ShipmentOutEntity();
                    shipmentOut.ShipmentId         = shipmentinput;
                    shipmentOut.BoxIdRef           = currentBoxOut.Id;
                    shipmentOut.BoxIdString        = currentBoxOut.BoxId;
                    shipmentOut.MasterBillId       = currentMasterOut.Id;
                    shipmentOut.MasterBillIdString = currentMasterOut.MasterAirwayBill;
                    shipmentOut.DateOut            = dtpNgayXuat.Value;
                    shipmentOut.DateCreated        = DateTime.Now;
                    shipmentOut.DateInt            = _repositoryShipment.DateToInt(DateTime.Now);
                    shipmentOut.EmployeeId         = currentEmployee.Id;
                    shipmentOut.WarehouseId        = FormLogin.mWarehouse.Id;
                    shipmentOut.Weight             = Math.Round(Convert.ToDouble(manifestnew.Weight), 3);
                    shipmentOut.DeclarationNo      = _shipmentOutServices.GetDeclarationNo(shipmentinput);
                    shipmentOut.DateOfCompletion   = _shipmentOutServices.GetDateOfCompletion(shipmentinput);
                    shipmentOut.Tel         = manifestnew.Tel;
                    shipmentOut.Address     = manifestnew.Address;
                    shipmentOut.ContactName = manifestnew.ContactName;
                    shipmentOut.CompanyName = manifestnew.CompanyName;
                    shipmentOut.Content     = manifestnew.Content;
                    shipmentOut.Country     = manifestnew.Country;
                    shipmentOut.Destination = manifestnew.Destination;
                    shipmentOut.Original    = manifestnew.Original;
                    shipmentOut.Quantity    = manifestnew.Quantity;
                    shipmentOut.TotalValue  = manifestnew.TotalValue;
                    _repositoryShipment.CreateShipmentOut(shipmentOut);
                    // SaveShipmentOut(grvShipmentListOut.Rows.Count, shipmentOut);
                    ding.Play();
                    txtShipmentIdOut.Text = String.Empty;
                    startProcessing       = false;
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                Ultilities.FileHelper.WriteLog(Ultilities.ExceptionLevel.Function, "txtShipmentIdOut_KeyDown", ex);
                return;
            }
        }
Esempio n. 27
0
        public async Task ForwardingEventList(string id, List <ForwardingEvent> list)
        {
            await ShipmentEntity.ValidateId(id);

            await ShipmentDAO.Methods.UpdateSet.SetForwardingEventList(id, list);
        }
Esempio n. 28
0
 private async Task ValdiateId(string id)
 {
     await ShipmentEntity.ValidateId(id);
 }
Esempio n. 29
0
        public static CustomerOrderEntity GetResetedOrder()
        {
            var orderId = "orderId";

            var order = new CustomerOrderEntity
            {
                Id                   = orderId,
                CustomerId           = "customerId",
                StoreId              = "storeId",
                Number               = "number",
                Currency             = "usd",
                PaymentTotal         = 1,
                PaymentTotalWithTax  = 1,
                ShippingTotalWithTax = 1,
                DiscountAmount       = 1,
                DiscountTotal        = 1,
                DiscountTotalWithTax = 1,
                HandlingTotal        = 1,
                HandlingTotalWithTax = 1,
                ShippingTotal        = 1,
                SubTotal             = 1,
                SubTotalWithTax      = 1,
                Sum                  = 1,
                TaxPercentRate       = 1,
                TaxTotal             = 1,
                Total                = 1
            };

            var item = new LineItemEntity
            {
                CustomerOrderId = orderId,
                Id                    = "itemId",
                Currency              = "usd",
                ProductId             = "productId",
                CatalogId             = "catalogId",
                Sku                   = "sku",
                Name                  = "itemName",
                Price                 = 1,
                DiscountAmount        = 1,
                TaxPercentRate        = 1,
                TaxTotal              = 1,
                DiscountAmountWithTax = 1,
                PriceWithTax          = 1,
            };

            var payment = new PaymentInEntity
            {
                CustomerOrderId = orderId,
                Id                    = "paymentId",
                CustomerId            = "customerId",
                Number                = "number",
                Currency              = "usd",
                Price                 = 1,
                DiscountAmount        = 1,
                DiscountAmountWithTax = 1,
                PriceWithTax          = 1,
                TaxPercentRate        = 1,
                TaxTotal              = 1,
                Total                 = 1,
                Sum                   = 1,
                TotalWithTax          = 1,
            };

            var shipment = new ShipmentEntity
            {
                CustomerOrderId = orderId,
                Id                    = "shipmentId",
                Number                = "number",
                Currency              = "usd",
                Price                 = 1,
                DiscountAmount        = 1,
                DiscountAmountWithTax = 1,
                PriceWithTax          = 1,
                Sum                   = 1,
                TaxPercentRate        = 1,
                TaxTotal              = 1,
                Total                 = 1,
                TotalWithTax          = 1,
            };

            order.ResetPrices();
            item.ResetPrices();
            payment.ResetPrices();
            shipment.ResetPrices();

            order.Items = new ObservableCollection <LineItemEntity> {
                item
            };
            order.InPayments = new ObservableCollection <PaymentInEntity> {
                payment
            };
            order.Shipments = new ObservableCollection <ShipmentEntity> {
                shipment
            };

            return(order);
        }
        private void SaveShipment(string masterBill)
        {
            int countTotal = 0;
            List <BoxIdEntity> listBoxid = repositoryShipment.GetBoxIdByAirwaybill(masterBill);

            if (listBoxid.Count > 0)
            {
                foreach (var box in listBoxid)
                {
                    int            countBox  = 0;
                    BoxInforEntity boxEntity = _boxInforServices.GetByBoxId(box.BoxId);
                    if (boxEntity == null)
                    {
                        boxEntity                  = new BoxInforEntity();
                        boxEntity.BoxId            = box.BoxId;
                        boxEntity.DateCreated      = DateTime.Now;
                        boxEntity.EmployeeId       = currentEmployee.Id;
                        boxEntity.ShipmentQuantity = 0;
                        boxEntity.MasterBillId     = currentMasterBillId;
                        currentBoxIdInt            = _boxInforServices.CreateBoxInfor(boxEntity);
                        boxEntity.Id               = currentBoxIdInt;
                        currentBoxId               = boxEntity.BoxId;
                    }
                    else
                    {
                        currentBoxIdInt = boxEntity.Id;
                        currentBoxId    = boxEntity.BoxId;
                    }
                    List <ManifestEntity> listManifest = new List <ManifestEntity>();
                    listManifest = repositoryShipment.GetManifestByBoxId(box.BoxId);
                    listManifest = listManifest.GroupBy(t => t.ShipmentNo).Select(p => p.First()).ToList();
                    if (listManifest != null && listManifest.Count > 0)
                    {
                        List <ShipmentEntity> listShipment = new List <ShipmentEntity>();
                        foreach (var item in listManifest)
                        {
                            ShipmentEntity shipment = new ShipmentEntity();
                            shipment.Mawb        = item.MasterAirWayBill;
                            shipment.ShipmentId  = item.ShipmentNo;
                            shipment.BoxId       = currentBoxIdInt;
                            shipment.DateCreated = DateTime.Now;
                            shipment.EmployeeId  = currentEmployee.Id;
                            shipment.WarehouseId = FormLogin.mWarehouse.Id;
                            shipment.Address     = item.Address;
                            shipment.BoxIdString = item.BoxID;
                            if (_shipmentOutServices.GetStatusCompletion(item.ShipmentNo))
                            {
                                shipment.Status = "Clearance";
                            }
                            else
                            {
                                shipment.Status = "Check";
                            }
                            shipment.Content       = item.Content;
                            shipment.Country       = item.Country;
                            shipment.DeclarationNo = item.DeclarationNo;
                            shipment.Destination   = item.Destination;
                            shipment.NumberPackage = 1;
                            shipment.TotalValue    = item.TotalValue;
                            shipment.Sender        = item.CompanyName;
                            shipment.Consignee     = item.Destination;
                            shipment.Receiver      = item.ContactName;
                            shipment.Weight        = Math.Round(item.Weight, 3);
                            shipment.ReceiverTel   = item.Tel;
                            listShipment.Add(shipment);
                        }
                        countBox = repositoryShipment.CreateShipment(listShipment);
                        if (countBox > 0)
                        {
                            countTotal += countBox;
                            _boxInforServices.CreateOrUpdateByQuery(countBox, boxEntity.Id);
                        }
                    }
                }
                MessageBox.Show("Đã xác nhận đến thành công!\nTổng số đơn hàng là " + countTotal, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }