public static bool ValidateBookRequest(CustomerInfo customer, BookingShipper shipper, BookingReceiver receiver, BookingPickUpInfo shipment, BookingResponse response) { //if (customer == null) //{ // response.ErrorMessage.ErrorCode = "003"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_NO_CUSTOMER; // return false; //} //else //{ // if (string.IsNullOrEmpty(customer.CustomerNumber)) // { // response.ErrorMessage.ErrorCode = "004"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_CUSTOMER_NUMBER_EMPTY; // return false; // } // if (string.IsNullOrEmpty(customer.Password)) // { // response.ErrorMessage.ErrorCode = "005"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_PASSWORD_EMPTY; // return false; // } // if (string.IsNullOrEmpty(shipper.DestinationCountry)) // { // response.ErrorMessage.ErrorCode = "006"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_RECEIVER_COUNTRY_EMPTY; // return false; // } // if (string.IsNullOrEmpty(shipper.Country)) // { // response.ErrorMessage.ErrorCode = "008"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_SHIPPER_COUNTRY_EMPTY; // return false; // } // else if ((shipper.Country.Trim() == "US" || shipper.Country.Trim() == "CA") && string.IsNullOrEmpty(shipper.State.Trim())) // { // response.ErrorMessage.ErrorCode = "009"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_SHIPPER_STATE_EMPTY; // return false; // } // if (shipper.Address == null || shipper.Address.Count < 1) // { // response.ErrorMessage.ErrorCode = "025"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_INVALID_ADDRESS; // return false; // } // if (string.IsNullOrEmpty(shipper.City)) // { // response.ErrorMessage.ErrorCode = "026"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_PICKUP_CITY_EMPTY; // return false; // } // if (string.IsNullOrEmpty(shipper.BookerName)) // { // response.ErrorMessage.ErrorCode = "027"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_BOOKER_NAME_EMPTY; // return false; // } // if (string.IsNullOrEmpty(shipper.BookerPhone)) // { // response.ErrorMessage.ErrorCode = "028"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_BOOKER_PHONE_EMPTY; // return false; // } // if (string.IsNullOrEmpty(shipper.ContactName)) // { // response.ErrorMessage.ErrorCode = "022"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_CONTACT_NAME_EMPTY; // return false; // } // if (string.IsNullOrEmpty(shipper.ContactPhone)) // { // response.ErrorMessage.ErrorCode = "023"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_CONTACT_PHONE_EMPTY; // return false; // } // if (shipment.PackageCount <= 0) // { // response.ErrorMessage.ErrorCode = "020"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_INVALID_PACKAGE_COUNT; // return false; // } // if (shipment.TotalWeight <= 0) // { // response.ErrorMessage.ErrorCode = "021"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_INVALID_TOTAL_WEIGHT; // return false; // } // DateTime dt; // if (!DateTime.TryParseExact(shipment.PickUpDate, "yyyy-MM-dd", null, System.Globalization.DateTimeStyles.None, out dt)) // { // response.ErrorMessage.ErrorCode = "024"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_PICKUP_DATE_INVALID; // return false; // } // if (!DateTime.TryParseExact(shipment.ReadyTime, "HH:mm", null, System.Globalization.DateTimeStyles.None, out dt)) // { // response.ErrorMessage.ErrorCode = "029"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_INVALID_READY_TIME; // return false; // } // if (!DateTime.TryParseExact(shipment.CloseTime, "HH:mm", null, System.Globalization.DateTimeStyles.None, out dt)) // { // response.ErrorMessage.ErrorCode = "030"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_INVALID_CLOSE_TIME; // return false; // } // if (shipment.LocationType != LocationType.Residence && string.IsNullOrEmpty(shipper.CompanyName)) // { // response.ErrorMessage.ErrorCode = "033"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_COMPANY_NAME_EMPTY; // return false; // } // if (shipper.Country == "US" && shipper.DestinationCountry == "US") // { // if (shipment.DomSettings == null) // { // response.ErrorMessage.ErrorCode = "034"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_DOMESTIC_SETTINGS_EMPTY; // return false; // } // if (shipment.DomSettings.ReceiverAddress == null || shipment.DomSettings.ReceiverAddress.Count < 1) // { // response.ErrorMessage.ErrorCode = "035"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_DOMESTIC_RECEIVER_ADDRESS; // return false; // } // if (string.IsNullOrEmpty(shipment.DomSettings.ReceiverCity)) // { // response.ErrorMessage.ErrorCode = "036"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_DOMESTIC_RECEIVER_CITY; // return false; // } // if (string.IsNullOrEmpty(shipment.DomSettings.ReceiverState)) // { // response.ErrorMessage.ErrorCode = "037"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_DOMESTIC_RECEIVER_STATE; // return false; // } // if (string.IsNullOrEmpty(shipment.DomSettings.ReceiverZipcode)) // { // response.ErrorMessage.ErrorCode = "038"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_DOMESTIC_RECEIVER_ZIP; // return false; // } // if (string.IsNullOrEmpty(shipment.DomSettings.ReceiverName)) // { // response.ErrorMessage.ErrorCode = "039"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_DOMESTIC_RECEIVER_NAME; // return false; // } // if (string.IsNullOrEmpty(shipment.DomSettings.ReceiverCompanyName)) // { // response.ErrorMessage.ErrorCode = "040"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_DOMESTIC_RECEIVER_COMPANY_NAME; // return false; // } // if (string.IsNullOrEmpty(shipment.DomSettings.ReceiverPhone)) // { // response.ErrorMessage.ErrorCode = "041"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_DOMESTIC_RECEIVER_PHONE; // return false; // } // if (string.IsNullOrEmpty(shipment.DomSettings.DeliveryDate)) // { // response.ErrorMessage.ErrorCode = "042"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_DOMESTIC_DELIVERY_DATE; // return false; // } // if (shipment.Packages != null && shipment.Packages.Count > 0) // { // foreach (Package package in shipment.Packages) // { // if (package.Weight == 0 || package.Height == 0 || package.Width == 0 || package.Length == 0) // { // response.ErrorMessage.ErrorCode = "019"; // response.ErrorMessage.ErrorMessage = CommonMessages.ERROR_SHIPMENT_INVALID_PACKAGE_DIMENSION; // return false; // } // } // } // } //} return(true); }
public string CreateOrder(BookingShipper shipper, BookingReceiver receiver, BookingPickUpInfo shipment, int bookUserId, BookingResponse bookingResponse) { string hawb = ""; //try //{ // User bookUser = BOUser.GetUserById(bookUserId); // Order order = new Order(); // order.DomOrInt = true; // order.UserId = bookUser; // //Shipper // order.Shipper = new BusinessLogic.Shipper(); // order.Shipper.User = bookUser; // order.Shipper.Address = new Address(); // order.Shipper.Address.City = shipper.City; // order.Shipper.Address.States = BOStates.GetStateByShortName(shipper.State); // order.Shipper.Address.CountryName = "USA"; // order.Shipper.Address.Street = shipper.Address[0]; // if (shipper.Address.Count > 1) // order.Shipper.Address.Street2 = shipper.Address[1]; // order.Shipper.Address.Zip = shipper.PostalCode; // order.Shipper.Address.Phone = shipper.BookerPhone; // order.Shipper.Name = shipper.BookerName; // order.Shipper.Company = shipper.CompanyName; // //Consignee // order.Consignee = new BusinessLogic.Consignee(); // order.Consignee.User = bookUser; // order.Consignee.Address = new Address(); // order.Consignee.Address.City = shipment.DomSettings.ReceiverCity; // order.Consignee.Address.States = BOStates.GetStateByShortName(shipment.DomSettings.ReceiverState); // order.Consignee.Address.CountryName = "USA"; // order.Consignee.Address.Street = shipment.DomSettings.ReceiverAddress[0]; // if (shipper.Address.Count > 1) // order.Consignee.Address.Street2 = shipment.DomSettings.ReceiverAddress[1]; // order.Consignee.Address.Zip = shipment.DomSettings.ReceiverZipcode; // order.Consignee.Address.Phone = shipment.DomSettings.ReceiverPhone; // order.Consignee.Name = shipment.DomSettings.ReceiverName; // order.Consignee.Company = shipment.DomSettings.ReceiverCompanyName; // //Bill To // order.ThirdParty = new ThirdParty(); // order.ThirdParty.User = bookUser; // order.ThirdParty.CustomerNo = bookUser.BillToNumber; // order.ThirdParty.RefNo = bookUser.BillToNumber; // order.ThirdParty.Company = bookUser.BillToName; // order.ThirdParty.Contact = bookUser.BillToContact; // if (bookUser.BillToAddress != null) // { // order.ThirdParty.Address = bookUser.BillToAddress; // } // // Fill Order Info: // order.ShipDate = DateTime.ParseExact(shipment.PickUpDate, "yyyy-MM-dd", null); // order.ReqDelDate = DateTime.ParseExact(shipment.DomSettings.DeliveryDate, "yyyy-MM-dd", null); // order.Service = BOService.GetServiceByID((int)shipment.DomSettings.Service); // order.ReadyTime = shipment.ReadyTime; // order.CloseTime = shipment.CloseTime; // order.InternalReferenceNumber = shipment.DomSettings.ReferenceNumber; // if (shipment.Insurance > 0) // { // order.Insurance = shipment.Insurance; // } // order.BillTo = BOBillTo.GetBillTo("3rd Party"); // order.SpecialInstructions = shipment.SpecialInstruction ?? ""; // order.IsLTLShipment = shipment.DomSettings.Service == ServiceLevel.LTL; // order.ShipperCodType = BOShipper.LoadShipperCOD(1); // //order.EmailStatusNotification = ShipmentEmailStatusNotification.Text.Trim(); // List<Freight> dimensions = new List<Freight>(); // Freight freight = new Freight(); // freight.Qty = shipment.PackageCount; // freight.Weight = shipment.TotalWeight; // freight.Description = ""; // dimensions.Add(freight); // order.Freight = dimensions; // order.SpecialServices = new SpecialServices(); // order.SpecialServices.AfterHourspud = false; // order.SpecialServices.Amdelivery = false; // order.SpecialServices.Hazardous = false; // order.SpecialServices.Holidaypud = false; // order.SpecialServices.InsideDelivery = false; // order.SpecialServices.Liftgatepud = false; // order.SpecialServices.MallConventionpud = false; // order.SpecialServices.Residentialpud = false; // order.SpecialServices.Saturdaypud = false; // order.SpecialServices.Sundaypud = false; // order.SpecialServices.WhiteGloveDelivery = false; // var oDao = new OrderDao(); // order = oDao.CreateOrder(order); // Utils.PutOrderInQueue(order, 1); // hawb = order.HblNumber; // BOOrder.SendOrderCreationNotifications(order.OrderId, new List<string>()); //} //catch (Exception ex) //{ // bookingResponse.ErrorMessage.ErrorCode = "511"; // bookingResponse.ErrorMessage.ErrorMessage = CommonMessages.ERROR_PROCESSING_REQUEST; // ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // m_log.Error(ex.ToString()); //} return(hawb); }