Example #1
0
        public IActionResult Room(int id, BookingFormModel booking)
        {
            ViewData["RoomId"] = id;

            Room room = _db.Room
                        .Include(r => r.RoomType)
                        .Include(r => r.Reviews)
                        .Include(b => b.Bookings)
                        .Where(
                r => r.RoomId == id
                ).SingleOrDefault();

            var bookings = _db.Bookings.Where(b =>
                                              b.CheckInDate.CompareTo(booking.CheckOut) <= 0 &&
                                              booking.CheckIn.CompareTo(b.CheckOutDate) <= 0 &&
                                              b.RoomId == id);

            RoomViewModel model = new RoomViewModel {
                Room              = room,
                ReviewForm        = new ReviewFormModel(),
                BookingForm       = booking,
                ShowBookingButton = !string.IsNullOrEmpty(booking.CheckIn) && !string.IsNullOrEmpty(booking.CheckOut),
                IsAvailable       = !bookings.Any()
            };

            return(View(model));
        }
Example #2
0
 public IActionResult UpdateBookingForm([FromBody] BookingFormModel booking)
 {
     if (ModelState.IsValid)
     {
         SendBookingToWmsModel sendBackToWMS = new SendBookingToWmsModel();
         sendBackToWMS = _dataAccessProvider.UpdateBookingPage(booking);
         return(Ok(sendBackToWMS));
     }
     return(BadRequest(ModelState));
 }
Example #3
0
        public IActionResult Book(int id, BookingFormModel BookingForm)
        {
            var userid = this.User.Identity.IsAuthenticated ? int.Parse(this.User.FindFirst(ClaimTypes.NameIdentifier).Value) : -1;

            _db.Bookings.Add(new Bookings {
                CheckInDate  = BookingForm.CheckIn,
                CheckOutDate = BookingForm.CheckOut,
                DateCreated  = DateTime.Now,
                RoomId       = id,
                UserId       = userid,
            });
            _db.SaveChanges();

            //return RedirectToAction("Room", "Hotels", new { id });
            return(RedirectToAction("Room", "Hotels", new { id, BookingForm.CheckIn, BookingForm.CheckOut }));
        }
        public async Task <ActionResult> SubmitBooking(BookingFormModel formModel)
        {
            var lab_id  = int.Parse(TempData["LabID"].ToString());
            var user_id = int.Parse(HttpContext.Request.Cookies["userID"]);

            var time_id = formModel.time_am + formModel.time_pm;

            var items = await ItemDB.GetAvailableItems(formModel.book_date);

            items.RemoveAll(item => item.type != formModel.item_type);

            switch (time_id)
            {
            case 1:
                items.RemoveAll(item => item.time_am == false);
                break;

            case 2:
                items.RemoveAll(item => item.time_pm == false);
                break;

            case 3:
                items.RemoveAll(item => item.time_am == false || item.time_pm == false);
                break;

            default:
                break;
            }

            if (items.Count > 0)
            {
                for (var i = 0; i < formModel.quantity; ++i)
                {
                    var temp = TransactionDB.Add(new Transaction(user_id, items[i].uuid, (int)Transaction_type.borrow, time_id, formModel.book_date)).Result;
                    if (temp == 1)
                    {
                        TempData["BookingSucceed"] = false;
                        return(RedirectToAction("Booking", new { labID = lab_id }));
                    }
                }
            }

            return(RedirectToAction("Index", "User"));
        }
Example #5
0
        //Update the booking table and return the json sending to wms
        public SendBookingToWmsModel UpdateBookingPage(BookingFormModel booking)
        {
            Booking getbooking = new Booking();

            getbooking = getAllBookingDetail(booking.BookingId.ToString());
            getbooking.BookingDetail.BookingDate             = booking.BookingDate;
            getbooking.BookingDetail.BookingTime             = booking.BookingTime;
            getbooking.BookingDetail.BillOfLading            = booking.BillOfLading;
            getbooking.BookingDetail.ExportDeclarationNumber = booking.ExportDeclarationNumber;
            getbooking.UpdatedDate                           = DateTime.Now;
            getbooking.Shipper.Name                          = booking.ShipperName;
            getbooking.Shipper.Address1                      = booking.ShipperAddress1;
            getbooking.Shipper.Address2                      = booking.ShipperAddress2;
            getbooking.Shipper.Contact1                      = booking.ShipperContactNo;
            getbooking.Shipper.Email                         = booking.ShipperEmail;
            getbooking.Shipper.UpdatedDate                   = DateTime.Now;
            getbooking.Consignee.Name                        = booking.ConsigneeName;
            getbooking.Consignee.Address1                    = booking.ConsigneeAddress1;
            getbooking.Consignee.Address2                    = booking.ConsigneeAddress2;
            getbooking.Consignee.ContactNumber               = booking.ConsigneeContactNo;
            getbooking.Consignee.Email                       = booking.ConsigneeEmail;
            getbooking.Consignee.UpdatedDate                 = DateTime.Now;
            getbooking.BookingDetail.BookingType             = booking.BookingType;
            getbooking.BookingDetail.VoyageDetails           = booking.VoyageDetails;
            getbooking.BookingDetail.CountryOrigin           = booking.CountryOrigin;
            getbooking.BookingDetail.CountryFinalDestination = booking.CountryFinalDestination;
            getbooking.BookingDetail.PortLoading             = booking.PortOfLoading;
            getbooking.BookingDetail.PortDischarge           = booking.PortOfDischarge;
            getbooking.BookingDetail.DateDeparture           = booking.DateDeparture;
            getbooking.BookingDetail.FinalDestination        = booking.FinalDestination;
            getbooking.BookingDetail.DeclaredWeight          = booking.Weight;
            getbooking.BookingDetail.DeclaredWidth           = booking.Width;
            getbooking.BookingDetail.DeclaredLength          = booking.Length;
            getbooking.BookingDetail.DeclaredHeight          = booking.Height;
            getbooking.BookingDetail.UpdatedDate             = DateTime.Now;

            __context.Update(getbooking);
            __context.SaveChanges();
            SendBookingToWmsModel sendDataToWMSModel = new SendBookingToWmsModel();

            sendDataToWMSModel = SendBookingDataToWMS(booking, booking.BookingId);
            return(sendDataToWMSModel);
        }
Example #6
0
        public IActionResult GetBookingFormById(string id)
        {
            BookingFormModel bookingmodel = new BookingFormModel();

            bookingmodel = _dataAccessProvider.GetBookingFormById(id);
            if (bookingmodel != null)
            {
                List <CargoModel> cargoModel = new List <CargoModel>();
                string            cargoId    = bookingmodel.CargoId.ToString();
                cargoModel = _dataAccessProvider.GetCargoesById(cargoId);
                bookingmodel.cargoItems = cargoModel;
                if (bookingmodel.TransporterCompany != null)
                {
                    bookingmodel.RequiredTransportation = true;
                }
            }


            return(Ok(bookingmodel));
        }
Example #7
0
        //Get the JSON to send to WMS
        public SendBookingToWmsModel SendBookingDataToWMS(BookingFormModel bookingFormModel, Guid bookId)
        {
            SendBookingToWmsModel sendBookingToWMS = new SendBookingToWmsModel();

            sendBookingToWMS.BookingDetailId      = bookId;
            sendBookingToWMS.BookingId            = bookId;
            sendBookingToWMS.ReceivingWareHouseId = bookingFormModel.WarehouseId;
            CargoInfoModel cargoInfo = new CargoInfoModel();

            if (bookingFormModel.BookingType == "Import")
            {
                cargoInfo.isImport = true;
            }
            else
            {
                cargoInfo.isImport = false;
            }
            cargoInfo.CountryOrigin           = bookingFormModel.CountryOrigin;
            cargoInfo.CountryFinalDestination = bookingFormModel.CountryFinalDestination;
            cargoInfo.PortOfLoading           = bookingFormModel.PortOfLoading;
            cargoInfo.PortOfDischarge         = bookingFormModel.PortOfDischarge;
            cargoInfo.DateDeparture           = bookingFormModel.DateDeparture;
            cargoInfo.FinalDestination        = bookingFormModel.FinalDestination;
            cargoInfo.CargoName                   = bookingFormModel.CargoName;
            cargoInfo.MarkAndNumber               = bookingFormModel.MarkAndNumber;
            cargoInfo.Weight                      = bookingFormModel.Weight;
            cargoInfo.PackageType                 = bookingFormModel.PackageTypeId;
            cargoInfo.MeasureLength               = bookingFormModel.Length;
            cargoInfo.MeasureHeight               = bookingFormModel.Height;
            cargoInfo.MeasureWidth                = bookingFormModel.Width;
            cargoInfo.Hazardous                   = bookingFormModel.IsHazard;
            cargoInfo.RequiredTransportation      = bookingFormModel.RequiredTransportation;
            cargoInfo.Transporter                 = bookingFormModel.TransporterId;
            cargoInfo.Remarks                     = bookingFormModel.Remarks;
            sendBookingToWMS.CargoInfo            = cargoInfo;
            sendBookingToWMS.CargoInfo.CargoItems = bookingFormModel.cargoItems;
            return(sendBookingToWMS);
        }
Example #8
0
        public IActionResult DeleteBooking(int id, BookingFormModel BookingForm)
        {
            var userid = this.User.Identity.IsAuthenticated ? int.Parse(this.User.FindFirst(ClaimTypes.NameIdentifier).Value) : -1;

            try {
                var booking = _db.Bookings.FirstOrDefault(b =>
                                                          b.RoomId == id &&
                                                          b.CheckInDate == BookingForm.CheckIn &&
                                                          b.CheckOutDate == BookingForm.CheckOut &&
                                                          b.UserId == userid
                                                          );

                if (booking != null)
                {
                    _db.Bookings.Remove(booking);
                    _db.SaveChanges();
                }
            }
            catch {
                return(RedirectToAction("Room", "Hotels", new { id, BookingForm.CheckIn, BookingForm.CheckOut }));
            }

            return(RedirectToAction("Room", "Hotels", new { id, BookingForm.CheckIn, BookingForm.CheckOut }));
        }
Example #9
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));
        }