public async Task Test_SaveShipment_Full_Is_Ok()
        {
            ShipmentModel currentShipment = new ShipmentModel();

            currentShipment.ReceiverAvailabilities = new EditableList <AvailabilityEntityModel>();
            currentShipment.SenderAvailabilities   = new EditableList <AvailabilityEntityModel>();
            AvailabilityEntityModel receiver = new AvailabilityEntityModel();

            receiver.AmStop  = "11:30";
            receiver.AmStart = "08:00";
            receiver.PmStart = "15:00";
            receiver.PmStop  = "18:00";
            AvailabilityEntityModel sender = new AvailabilityEntityModel();

            sender.AmStart = "07:00";
            sender.AmStop  = "11:34";
            sender.PmStart = "18:00";
            sender.PmStop  = "20:00";
            currentShipment.ReceiverAvailabilities.Add(receiver);
            currentShipment.SenderAvailabilities.Add(sender);

            currentShipment.Id                    = -1;
            currentShipment.CustomerId            = 1;
            currentShipment.DeliveryDate          = DateTime.Now;
            currentShipment.DateModified          = DateTime.Now;
            currentShipment.DateCreated           = DateTime.Now;
            currentShipment.PickUpDate            = DateTime.Now;
            currentShipment.PoNumber              = "12345678";
            currentShipment.ReceiverAddressId     = 70;
            currentShipment.ReceiverContactPerson = "dan MIhai";
            currentShipment.ReceiverPhone         = "4443333";
            currentShipment.ReceiverRemark        = "Iași Buc";
            currentShipment.Reference             = "aaaa";
            currentShipment.SenderAddressId       = 70;
            currentShipment.SenderContactPerson   = "gicu turcu";
            currentShipment.SenderPhone           = "434343434";
            currentShipment.SenderRemark          = "Iași to see availability";
            currentShipment.ShipmentStatus        = "UAS";
            currentShipment.TotalPrice            = 5554;
            currentShipment.TotalQuatity          = 6666;
            currentShipment.TotalVolume           = 333;
            currentShipment.TotalWeight           = 5454;
            currentShipment.TransporterId         = 1;
            currentShipment.UserIdCreated         = 100000;
            currentShipment.UserIdModified        = 999;
            currentShipment.InvoiceAmount         = 6666;
            currentShipment.InvoiceComment        = "InvoiceComment";
            currentShipment.InvoiceDate           = DateTime.Now.AddDays(4);
            currentShipment.PickUpComment         = "yyyyy";
            currentShipment.DeliveryComment       = "rrrrrr";
            currentShipment.DeliveryPod           = true;
            //we must see with parentdetailid
            ShipmentDetailModel aShipmentDetailModel = new ShipmentDetailModel
            {
                Height           = 1,
                Length           = 10,
                Quantity         = 111,
                PackTypeId       = 1,
                Weight           = 11,
                Width            = 232,
                QuantityDetail   = 666,
                PackTypeDetailId = 2
            };
            ShipmentDetailModel aShipmentDetailModel2 = new ShipmentDetailModel
            {
                Height           = 1,
                Length           = 10,
                Quantity         = 111,
                PackTypeId       = 1,
                Weight           = 11,
                Width            = 232,
                QuantityDetail   = 999,
                PackTypeDetailId = 1
            };
            List <ShipmentDetailModel> extras = new EditableList <ShipmentDetailModel>();

            extras.Add(aShipmentDetailModel2);
            extras.Add(aShipmentDetailModel);
            currentShipment.ShipmentDetails = extras;

            List <FacilityEntityModel> shipmentReceiverFacilities =
                new EditableList <FacilityEntityModel>();
            FacilityEntityModel aShipmentReceiverFacilityModel = new FacilityEntityModel
            {
                Active     = true,
                FacilityId = 1
            };

            shipmentReceiverFacilities.Add(aShipmentReceiverFacilityModel);
            currentShipment.ReceiverFacilities = shipmentReceiverFacilities;

            List <RequirementEntityModel> shipmentReceiverRequirements =
                new EditableList <RequirementEntityModel>();
            RequirementEntityModel aShipmentReceiverRequirementModel = new RequirementEntityModel
            {
                Active          = true,
                AmountInsurance = 11,
                RequirementId   = 11
            };

            shipmentReceiverRequirements.Add(aShipmentReceiverRequirementModel);
            currentShipment.ReceiverRequirements = shipmentReceiverRequirements;

            List <TruckEntityModel> shipmentReceiverTrucks      = new EditableList <TruckEntityModel>();
            TruckEntityModel        aShipmentReceiverTruckModel = new TruckEntityModel
            {
                Active  = true,
                TruckId = 5
            };

            shipmentReceiverTrucks.Add(aShipmentReceiverTruckModel);
            currentShipment.ReceiverTrucks = shipmentReceiverTrucks;

            List <FacilityEntityModel> shipmentSenderFacilities     = new EditableList <FacilityEntityModel>();
            FacilityEntityModel        aShipmentSenderFacilityModel = new FacilityEntityModel
            {
                Active     = true,
                FacilityId = 1
            };

            shipmentSenderFacilities.Add(aShipmentSenderFacilityModel);
            currentShipment.SenderFacilities = shipmentSenderFacilities;

            List <RequirementEntityModel> shipmentSenderRequirements =
                new EditableList <RequirementEntityModel>();
            RequirementEntityModel aShipmentSenderRequirementModel = new RequirementEntityModel
            {
                Active          = true,
                AmountInsurance = 999,
                RequirementId   = 11
            };

            shipmentSenderRequirements.Add(aShipmentSenderRequirementModel);
            currentShipment.SenderRequirements = shipmentSenderRequirements;

            List <TruckEntityModel> shipmentSenderTrucks      = new EditableList <TruckEntityModel>();
            TruckEntityModel        aShipmentSenderTruckModel = new TruckEntityModel
            {
                Active  = true,
                TruckId = 6
            };

            shipmentSenderTrucks.Add(aShipmentSenderTruckModel);
            currentShipment.SenderTrucks = shipmentSenderTrucks;

            List <ShipmentTransporterModel> shipmentTransporters      = new EditableList <ShipmentTransporterModel>();
            ShipmentTransporterModel        aShipmentTransporterModel = new ShipmentTransporterModel
            {
                Accepted      = true,
                AcceptedDate  = DateTime.Now,
                Assigned      = true,
                AssignedDate  = DateTime.Now,
                Declined      = false,
                DeclinedDate  = DateTime.Now,
                DeliveryOn    = 1,
                LoadingOn     = 3,
                Price         = 11000110,
                Selected      = true,
                SelectedDate  = DateTime.Now,
                TransporterId = 1,
                ExpiredDate   = DateTime.Now
            };

            shipmentTransporters.Add(aShipmentTransporterModel);
            currentShipment.Transporters = shipmentTransporters;
            try
            {
                await _shipmentService.SaveShipment(1000, currentShipment);

                if (currentShipment.Id > 0)
                {
                    Assert.IsTrue(true);
                }
                else
                {
                    Assert.IsTrue(false);
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
        public async Task Test_SaveAddress_AddTotal_Is_Ok()
        {
            AddressModel currentAdrress = new AddressModel();

            currentAdrress.Id                 = -1;
            currentAdrress.ContactPerson      = "Test Boco";
            currentAdrress.CustomerId         = 1;
            currentAdrress.DateModified       = DateTime.Now;
            currentAdrress.DateCreated        = DateTime.Now;
            currentAdrress.Email              = "*****@*****.**";
            currentAdrress.Name               = "Test Address1";
            currentAdrress.Phone              = "021311";
            currentAdrress.Remark             = "Saved by Unit Test";
            currentAdrress.UserIdCreated      = 100000;
            currentAdrress.UserIdModified     = 999;
            currentAdrress.CommonAvailability = true;

            //location
            AddressLocationModel location = new AddressLocationModel();

            location.StateCode      = "444";
            location.City           = "Iasi";
            location.CityCode       = "700553";
            location.Country        = "Romania";
            location.CountryCode    = "RO";
            location.Latitude       = Convert.ToDecimal(1111.1111);
            location.Longitude      = Convert.ToDecimal(2222.2222);
            location.State          = "Moldova";
            location.Street         = "Silvestru";
            location.StreetNumber   = "10";
            location.ZipCode        = "555";
            currentAdrress.Location = location;

            //avalability
            List <AvailabilityEntityModel> listAvailabilityModels = new EditableList <AvailabilityEntityModel>();
            AvailabilityEntityModel        availability           = new AvailabilityEntityModel();

            availability.AmStart = "07:00";
            // availability.AmStop = new TimeSpan(12, 00, 00);
            // availability.PmStart = new TimeSpan(15, 00, 00);
            //  availability.PmStop = new TimeSpan(16, 00, 00);
            availability.Day            = 1;
            availability.UserIdCreated  = 100000;
            availability.UserIdModified = 999;
            listAvailabilityModels.Add(availability);
            currentAdrress.Availabilities = listAvailabilityModels;

            //trucks
            List <TruckEntityModel> listAddressTruckModel = new EditableList <TruckEntityModel>();
            TruckEntityModel        truck = new TruckEntityModel();

            truck.Active         = true;
            truck.TruckId        = 5;
            truck.UserIdCreated  = 100000;
            truck.UserIdModified = 999;
            listAddressTruckModel.Add(truck);
            currentAdrress.Trucks = listAddressTruckModel;

            //requirements
            List <RequirementEntityModel> listreRequirementModels = new EditableList <RequirementEntityModel>();
            RequirementEntityModel        requirement             = new RequirementEntityModel();

            requirement.Active         = true;
            requirement.RequirementId  = 9;
            requirement.UserIdCreated  = 100000;
            requirement.UserIdModified = 999;
            listreRequirementModels.Add(requirement);
            RequirementEntityModel requirement2 = new RequirementEntityModel();

            requirement2.Active         = true;
            requirement2.RequirementId  = 9;
            requirement2.UserIdCreated  = 100000;
            requirement2.UserIdModified = 999;
            listreRequirementModels.Add(requirement2);
            currentAdrress.Requirements = listreRequirementModels;

            //facilities
            List <FacilityEntityModel> listfaFacilityModels = new EditableList <FacilityEntityModel>();
            FacilityEntityModel        facility             = new FacilityEntityModel();

            facility.Active         = true;
            facility.FacilityId     = 1;
            facility.UserIdCreated  = 100000;
            facility.UserIdModified = 999;
            listfaFacilityModels.Add(facility);
            currentAdrress.Facilities = listfaFacilityModels;

            try
            {
                await _addressesService.SaveAddress(1000, currentAdrress);
            }
            catch (Exception)
            {
                // ignored
            }
            if (currentAdrress.Id > 0 && listAvailabilityModels[0].Id > 0 &&
                listAddressTruckModel[0].Id > 0 &&
                listreRequirementModels[0].Id > 0 &&
                listfaFacilityModels[0].Id > 0)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }