コード例 #1
0
        public IActionResult CreateNewBookingDetails([FromBody] BookingFormModel booking)
        {
            if (ModelState.IsValid)
            {
                BookingModel       bookingmodel       = new BookingModel();
                BookingDetailModel bookingDetailModel = new BookingDetailModel();
                Consignee          consignee          = new Consignee();
                Shipper            shipper            = new Shipper();
                bookingmodel.Consignee = consignee;
                bookingmodel.Shipper   = shipper;
                if (_dataAccessProvider.noOfSlotsTaken(booking.BookingTime) > 10)
                {
                    bookingDetailModel.BookingStatus = "Pending";
                    bookingDetailModel.IsActive      = false;
                    bookingmodel.IsActive            = false;
                }
                else
                {
                    bookingDetailModel.BookingStatus = "Approved";
                    bookingDetailModel.IsActive      = true;
                    bookingmodel.IsActive            = true;
                }
                DateTime date         = DateTime.Now;
                Guid     bookingobj   = Guid.NewGuid();
                Guid     consigneeobj = Guid.NewGuid();
                Guid     shipperobj   = Guid.NewGuid();
                bookingDetailModel.CreatedBy       = "Test";
                bookingmodel.CreatedBy             = "Test";
                bookingmodel.Consignee.CreatedBy   = "Test";
                bookingmodel.Shipper.CreatedBy     = "Test";
                bookingDetailModel.BookingDetailId = bookingobj;
                bookingmodel.BookingId             = bookingobj;
                bookingmodel.ClientId = booking.ClientId;
                bookingmodel.Consignee.ConsigneeId         = consigneeobj;
                bookingmodel.Shipper.ShipperId             = shipperobj;
                bookingDetailModel.CreatedDate             = DateTime.Now;
                bookingDetailModel.UpdatedDate             = DateTime.Now;
                bookingmodel.CreatedDate                   = DateTime.Now;
                bookingmodel.UpdatedDate                   = DateTime.Now;
                bookingmodel.Consignee.CreatedDate         = DateTime.Now;
                bookingmodel.Consignee.UpdatedDate         = DateTime.Now;
                bookingmodel.Shipper.CreatedDate           = DateTime.Now;
                bookingmodel.Shipper.UpdatedDate           = DateTime.Now;
                bookingmodel.Shipper.IsActive              = true;
                bookingmodel.Consignee.IsActive            = true;
                bookingDetailModel.BookingDate             = booking.BookingDate;
                bookingDetailModel.BookingTime             = booking.BookingTime;
                bookingDetailModel.BillOfLading            = booking.BillOfLading;
                bookingDetailModel.ExportDeclarationNumber = booking.ExportDeclarationNumber;
                bookingmodel.Shipper.Name                  = booking.ShipperName;
                bookingmodel.Shipper.Address1              = booking.ShipperAddress1;
                bookingmodel.Shipper.Address2              = booking.ShipperAddress2;
                bookingmodel.Shipper.Contact1              = booking.ShipperContactNo;
                bookingmodel.Shipper.Email                 = booking.ShipperEmail;
                bookingmodel.Consignee.Name                = booking.ConsigneeName;
                bookingmodel.Consignee.Address1            = booking.ConsigneeAddress1;
                bookingmodel.Consignee.Address2            = booking.ConsigneeAddress2;
                bookingmodel.Consignee.ContactNumber       = booking.ConsigneeContactNo;
                bookingmodel.Consignee.Email               = booking.ConsigneeEmail;
                bookingDetailModel.BookingType             = booking.BookingType;
                bookingDetailModel.VoyageDetails           = booking.VoyageDetails;
                bookingDetailModel.CountryOrigin           = booking.CountryOrigin;
                bookingDetailModel.CountryFinalDestination = booking.CountryFinalDestination;
                bookingDetailModel.PortLoading             = booking.PortOfLoading;
                bookingDetailModel.PortDischarge           = booking.PortOfDischarge;
                bookingDetailModel.DateDeparture           = booking.DateDeparture;
                bookingDetailModel.FinalDestination        = booking.FinalDestination;
                bookingDetailModel.DeclaredWeight          = booking.Weight;
                bookingDetailModel.DeclaredWidth           = booking.Width;
                bookingDetailModel.DeclaredLength          = booking.Length;
                bookingDetailModel.DeclaredHeight          = booking.Height;

                _dataAccessProvider.AddBookingDetails(bookingmodel.Consignee, bookingmodel.Shipper, bookingmodel, bookingDetailModel);
                SendBookingToWmsModel sendBookingToWMS = new SendBookingToWmsModel();
                sendBookingToWMS = _dataAccessProvider.SendBookingDataToWMS(booking, bookingobj);


                return(Ok(sendBookingToWMS));


                return(Ok(new
                {
                }));
            }
            return(BadRequest(ModelState));
        }