Exemple #1
0
        public static ShippingConfirmation ConvertToShippingConfirmation(ShippingDetailInfo detail)
        {
            ShippingConfirmation result = new ShippingConfirmation();

            result.Id          = detail.Id;
            result.DCity       = detail.DestinationAddress.City;
            result.DName       = detail.DestinationAddress.Name;
            result.DStreet     = detail.DestinationAddress.Street;
            result.DPostalCode = detail.DestinationAddress.PostalCode;
            result.DState      = detail.DestinationAddress.State;

            result.OName       = detail.OriginAddress.Name;
            result.OStreet     = detail.OriginAddress.Street;
            result.OCity       = detail.OriginAddress.City;
            result.OState      = detail.OriginAddress.State;
            result.OPostalCode = detail.OriginAddress.PostalCode;

            result.DeliveryTime = detail.DeliveryTime;
            result.DeliveryType = detail.DeliveryMethod.ToString();

            result.Width  = detail.PackageInfo.BoxInfo.Width;
            result.Depth  = detail.PackageInfo.BoxInfo.Depth;
            result.Height = detail.PackageInfo.BoxInfo.Height;

            result.IsInsured     = detail.IsInsured;
            result.LetterType    = detail.PackageInfo.LetterInfo.LetterProofType.ToString();
            result.PackageType   = detail.PackageInfo.PackageType.ToString();
            result.PackageWeight = detail.PackageInfo.Weight;
            result.ShippingCost  = detail.Cost;

            result.DeliveryStatus = "Unknown";

            return(result);
        }
Exemple #2
0
        public static ShippingDetailInfo GetAirLetterPlainShippingDetailInstance()
        {
            ShippingDetailInfo instance = new ShippingDetailInfo();

            instance.DeliveryMethod     = DeliveryMethodEnum.Air;
            instance.PackageInfo        = PackageInfoFactory.GetLetterPackageInstance("Plain");
            instance.DestinationAddress = address1;
            instance.OriginAddress      = address2;

            return(instance);
        }
Exemple #3
0
        public static ShippingDetailInfo GetGroundBoxShippingDetailInstance()
        {
            ShippingDetailInfo instance = new ShippingDetailInfo();

            instance.DeliveryMethod     = DeliveryMethodEnum.Ground;
            instance.PackageInfo        = PackageInfoFactory.GetBoxPackageInstance(10, 10, 10);
            instance.DestinationAddress = address1;
            instance.OriginAddress      = address2;

            return(instance);
        }
        public void ProcessTest()
        {
            DeliveryTimeCommand target   = new DeliveryTimeCommand();
            ShippingDetailInfo  input    = TestShippingDetailFactory.GetAirBoxShippingDetailInstance();
            ShippingDetailInfo  expected = TestShippingDetailFactory.GetAirBoxShippingDetailInstance();

            expected.DeliveryTime = 0.25;
            ShippingDetailInfo actual;

            actual = target.Execute(input);
            Assert.AreEqual(expected.DeliveryTime, actual.DeliveryTime);
        }
        public void ProcessFailPostCodeTest()
        {
            JustInTimeShippingFacade target = JustInTimeShippingFacade.GetInstance();
            ShippingDetailInfo       detail = new ShippingDetailInfo();

            detail.PackageInfo        = PackageInfoFactory.GetLetterPackageInstance("Plain");
            detail.DeliveryMethod     = DeliveryMethodEnum.Ground;
            detail.OriginAddress      = new AddressInfo("John Doe", "Happy Street", "KL", "Selangor", "5600011");
            detail.DestinationAddress = new AddressInfo("Jane Doe", "Sad Street", "KL", "Selangor", "5600110");

            IResult result = target.Execute(detail);

            Assert.IsFalse(result.IsSuccess);
            Assert.IsTrue(result.Message.Length > 0);
        }
        public void ProcessGroundPackageTest()
        {
            ShippingDetailInfo input = new ShippingDetailInfo();

            input.PackageInfo        = PackageInfoFactory.GetLetterPackageInstance("Plain");
            input.PackageInfo.Weight = 20;
            input.DeliveryMethod     = DeliveryMethodEnum.Ground;
            input.OriginAddress      = new AddressInfo("John Doe", "Happy Street", "KL", "Selangor", "56000");
            input.DestinationAddress = new AddressInfo("Jane Doe", "Sad Street", "KL", "Selangor", "56000");


            ShippingCostCommand target = new ShippingCostCommand();

            ShippingDetailInfo actual;

            actual = target.Execute(input);

            Assert.IsTrue(input.Cost == 1.25);
        }
        public void ProcessTest()
        {
            ShippingDetailInfo input = new ShippingDetailInfo();

            input.PackageInfo        = PackageInfoFactory.GetLetterPackageInstance("Plain");
            input.DeliveryMethod     = DeliveryMethodEnum.Ground;
            input.OriginAddress      = new AddressInfo("John Doe", "Happy Street", "KL", "Selangor", "56000");
            input.DestinationAddress = new AddressInfo("Jane Doe", "Sad Street", "KL", "Selangor", "56000");

            SamWeightAdapter target = new SamWeightAdapter();

            double actual;

            Assert.IsTrue(input.PackageInfo.Weight == 0);

            actual = target.GetWeight();

            Assert.IsTrue(actual > 0);
        }
        public void ProcessRailBoxInsuredPackageTest()
        {
            ShippingDetailInfo input = new ShippingDetailInfo();

            input.IsInsured          = true;
            input.PackageInfo        = PackageInfoFactory.GetBoxPackageInstance(10, 10, 10);
            input.PackageInfo.Weight = 20;
            input.DeliveryMethod     = DeliveryMethodEnum.Rail;
            input.OriginAddress      = new AddressInfo("John Doe", "Happy Street", "KL", "Selangor", "16000");
            input.DestinationAddress = new AddressInfo("Jane Doe", "Sad Street", "KL", "Selangor", "46000");


            ShippingCostCommand target = new ShippingCostCommand();

            ShippingDetailInfo actual;

            actual = target.Execute(input);

            Assert.IsTrue(input.Cost == 1.275);
        }
        public void ProcessTest()
        {
            XmlPersistantCommand target = new XmlPersistantCommand(); // TODO: Initialize to an appropriate value
            ShippingDetailInfo   input  = TestShippingDetailFactory.GetGroundBoxShippingDetailInstance();


            string  expected = String.Format("C:\\TEMP\\ShippingDetails-{0}.xml", input.Id); // TODO: Initialize to an appropriate value
            IResult actual;

            actual = target.Execute(input);
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(File.Exists(actual.Message));
            Assert.IsTrue(File.ReadAllBytes(actual.Message).Length > 0);

            StreamReader reader     = new StreamReader(actual.Message);
            string       strcontent = reader.ReadToEnd();

            Console.WriteLine(strcontent);
            reader.Close();
        }
        private void btnProcess_Click(object sender, EventArgs e)
        {
            detail = new ShippingDetailInfo();

            detail.OriginAddress = new AddressInfo(txtSender.Text.Trim(),
                                                   txtSenderStreet.Text.Trim(),
                                                   txtSenderCity.Text.Trim(),
                                                   cbSenderStates.SelectedItem.ToString(),
                                                   txtSenderPostal.Text.Trim());
            detail.DestinationAddress = new AddressInfo(txtReceipient.Text.Trim(),
                                                        txtReceipientStreet.Text.Trim(),
                                                        txtReceipientCity.Text.Trim(),
                                                        cbReceipientStates.SelectedItem.ToString(),
                                                        txtReceipientPostal.Text.Trim());

            detail.IsInsured = chkInsurance.Checked;

            // Capture the PackageInfo
            detail.PackageInfo = GetPackageInfo();


            // Populate package information
            detail.PackageInfo.Weight = weight;

            // Capture Delivery Type
            detail.DeliveryMethod = GetDeliveryMethod();


            IResult processStatus = controller.Execute(detail);

            if (processStatus.IsSuccess)
            {
                //display all info in message box , message returned as object of IResult with property message
                MessageBox.Show(processStatus.Message, "Click OK to Accept or Cancel to decline", MessageBoxButtons.OKCancel);
            }
            else
            {
                MessageBox.Show(processStatus.Message, "Fail");
            }
        }
        public ActionResult Submit(CreateShippingRequestViewModel request, string packageType, string deliveryType)
        {
            IResult result;

            ShippingDetailInfo       detail  = ViewModelHelper.ConvertToShippingDetail(request);
            JustInTimeShippingFacade handler = JustInTimeShippingFacade.GetInstance();

            result = handler.Execute(detail);

            if (!result.IsSuccess)
            {
                PopulateDropDowns(request);

                request.Message = result.Message;

                return(View("Main", request));
            }
            else
            {
                return(View("Review", ViewModelHelper.ConvertToShippingConfirmation(detail)));
            }
        }
Exemple #12
0
        public static ShippingDetailInfo ConvertToShippingDetail(CreateShippingRequestViewModel model)
        {
            ShippingDetailInfo result = new ShippingDetailInfo();

            result.OriginAddress      = new AddressInfo(model.OName, model.OStreet, model.OCity, model.OStreet, model.OPostalCode);
            result.DestinationAddress = new AddressInfo(model.DName, model.DStreet, model.DCity, model.DState, model.DPostalCode);
            result.Id          = model.Id;
            result.IsInsured   = model.IsInsured;
            result.PackageInfo = new PackageInfo()    //  Car c=new Car() {type"sedan" , wheels=4, color="red"};
            {
                BoxInfo = new BoxInfo()
                {
                    Height = model.Height,
                    Width  = model.Width,
                    Depth  = model.Depth
                },
                LetterInfo  = new LetterInfo(model.LetterType),
                PackageType = ConvertPackageType(model.PackageType)
            };

            result.DeliveryMethod = ConvertDeliveryType(model.DeliveryType);
            return(result);
        }