Exemplo n.º 1
0
 private void PushToFile(BookingRequest request)
 {
     /*
     using (FileStream stream = new FileStream(Path.Combine(ConfigurationManager.AppSettings["BookingQueuePath"], strReservationId + ".txt"), FileMode.CreateNew))
     {
         XmlSerializer serializer = new XmlSerializer(typeof(BookingRequest));
         serializer.Serialize(stream, request);
     }*/
 }
Exemplo n.º 2
0
 public BookingResponse Confirm(BookingRequest request)
 {
     return writer.AddBooking(request);
     // Call DB Access and Confirm
     return new BookingResponse
     {
         BookingStatus = BookingStatus.Confirmed,
         ConfirmationNumber = "1234",
         Guest = request.Guest,
         ReservationId = "3456"
     };
 }
Exemplo n.º 3
0
        public JsonResult Get(AvailabilityRequest itinerary)
        {
            int roomCount = itinerary.RequestedRoomCount;
            itinerary.RequestedRoomCount = 1;
            var response = availability.Get(itinerary);
            var booking = new BookingRequest
            {
                Guest = new Customer { FirstName = "Hello" },
                TravelDetails = new Itinerary { FromDate = itinerary.FromDate, ToDate = itinerary.ToDate, HotelID = itinerary.City }
            };

            var bundle = new object[] { response, booking };
            return Json(bundle);
        }
Exemplo n.º 4
0
        public BookingResponse Push(BookingRequest request)
        {
            string strReservationId = Guid.NewGuid().ToString();
            request.BookingId = strReservationId;
            DbAccess db = new DbAccess();
            using (MemoryStream stream = new MemoryStream())
            {
                XmlSerializer serializer = new XmlSerializer(typeof(BookingRequest));
                serializer.Serialize(stream, request);
                //write to db
            }

            return new BookingResponse()
            {
                BookingStatus = BookingStatus.Booked,
                ReservationId = strReservationId,
                Guest = request.Guest
            };
        }
        public void TestBookingRequest()
        {
            var request = new BookingRequest
            {
                BookingId = "",
                Guest = new Customer { EMailAddress = "*****@*****.**", FirstName = "Mudlappa", LastName = "Narayanappa" },
                RequestedRooms = new List<RoomRequest>
                        {
                            new RoomRequest
                                {
                                    RequestedRoom = new Room {Id = "1", Description = "", Title = "Delux Room"},
                                    RoomCount = 2
                                }
                        },
                TravelDetails = new Itinerary { FromDate = DateTime.Now.Date.AddDays(1), ToDate = DateTime.Now.Date.AddDays(2), HotelID = "" }
            };

            var response = new WorkerRepository().AddBooking(request);

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.ConfirmationNumber);
        }
Exemplo n.º 6
0
 public BookingResponse Book(BookingRequest request)
 {
     return queue.Push(request);
 }
Exemplo n.º 7
0
        public BookingResponse ReadQueue(BookingRequest request)
        {
            var response = new BookingResponse();
            using (var context = new SpartanHotelsEntities())
            {
                var queue = context.Queues.FirstOrDefault(q => (q.ReservationID == request.BookingId));

                if (queue != null)
                {
                    response.ReservationId = queue.ReservationID;
                    response.ReservationId = queue.ReservationID;
                    response.ReservationId = queue.ReservationID;
                }
                else
                {
                    //return.. invalid input, queue doesnt exists
                }
            }

            return response;
        }
Exemplo n.º 8
0
        public bool DeleteQueue(BookingRequest request)
        {
            using (var context = new SpartanHotelsEntities())
            {
                var queue = context.Queues.FirstOrDefault(q => (q.ReservationID == request.BookingId));

                if (queue != null)
                {
                    context.Queues.Remove(queue);
                    context.SaveChanges();
                }
                else
                {
                    return false;
                    //return.. invalid input, queue doesnt exists
                }
            }

            return true;
        }
Exemplo n.º 9
0
        public BookingResponse AddBooking(BookingRequest request)
        {
            var response = new BookingResponse();

            try
            {
                using (var context = new SpartanHotelsEntities())
                {
                    var eHotel = (from hr in context.HotelRooms
                                  join ht in context.Hotels on hr.HotelID equals ht.HotelID
                                  where hr.HotelRoomID.ToString() == request.TravelDetails.HotelID
                                  select new
                                      {
                                          hr.HotelID,
                                          hr.HotelRoomID,
                                          ht.HotelName,
                                          ht.Locality,
                                          ht.City
                                      }).FirstOrDefault();

                    if (eHotel != null)
                    {
                        var availabilityResponse = GetAvailableRoomList(
                            new AvailabilityRequest
                                {
                                    City = eHotel.City,
                                    FromDate = request.TravelDetails.FromDate,
                                    ToDate = request.TravelDetails.ToDate,
                                    RequestedRoomCount = request.RequestedRooms.Count()
                                });

                        var available = false;
                        foreach (var rr in request.RequestedRooms)
                        {
                            if (
                                availabilityResponse.Rooms.FirstOrDefault(
                                    ar => ar.Room.Title == rr.RequestedRoom.Title && ar.AvailableCount >= rr.RoomCount) !=
                                null)
                            {
                                available = true;
                            }
                            else
                            {
                                available = false;
                                break;
                            }
                        }

                        if (available)
                        {
                            var eCustomer = AddCustomer(request.Guest.FirstName, request.Guest.LastName,
                                                        request.Guest.EMailAddress);

                            var eReservation = new Reservation
                                {
                                    BookingNum = request.BookingId,
                                    HotelRoomID = Convert.ToInt32(request.TravelDetails.HotelID),
                                    FromDate = request.TravelDetails.FromDate,
                                    ToDate = request.TravelDetails.ToDate,
                                    ConfirmationNum = context.Reservations.Max(c => c.ConfirmationNum) + 1,
                                    CreatedBy = "",
                                    CreatedDate = DateTime.Now,
                                    ModifiedBy = "",
                                    ModifiedDate = DateTime.Now,
                                    CustomerID = eCustomer.CustomerID,
                                    BookStatusID = (int) BookingStatus.Confirmed,
                                    Remarks = ""
                                };

                            foreach (var rm in request.RequestedRooms)
                            {
                                eReservation.HotelRoomID = Convert.ToInt32(rm.RequestedRoom.Id);

                                context.Reservations.Add(eReservation);
                            }

                            context.SaveChanges();

                            response.ConfirmationNumber = eReservation.ConfirmationNum.ToString();
                            response.BookingStatus = (BookingStatus) eReservation.BookStatusID;
                            response.Guest = new Entities.Customer
                                {
                                    EMailAddress = eCustomer.Email,
                                    FirstName = eCustomer.FirstName,
                                    LastName = eCustomer.LastName
                                };
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return response;
        }
Exemplo n.º 10
0
        public bool AddQueue(BookingRequest request)
        {
            using (var context = new SpartanHotelsEntities())
            {
                if (!context.Queues.Any(q => (q.ReservationID == request.BookingId)))
                {
                    var queue = new Queue {ReservationID = request.BookingId, request = new byte[0], status = false};
                    context.Queues.Add(queue);
                    context.SaveChanges();
                }
                else
                {
                    return false;
                    //return.. already exists
                }
            }

            return true;
        }
Exemplo n.º 11
0
 public JsonResult Confirm(BookingRequest request)
 {
     return Json(bookie.Book(request));
 }
Exemplo n.º 12
0
        public BookingResponse ReadQueue(BookingRequest request)
        {
            var dbAccess = new DbAccess();

            return dbAccess.ReadQueue(request);
        }
Exemplo n.º 13
0
        public bool DeleteQueue(BookingRequest request)
        {
            var dbAccess = new DbAccess();

            return dbAccess.DeleteQueue(request);
        }
Exemplo n.º 14
0
        public bool AddQueue(BookingRequest request)
        {
            var dbAccess = new DbAccess();

            return dbAccess.AddQueue(request);
        }
Exemplo n.º 15
0
        public BookingResponse AddBooking(BookingRequest request)
        {
            var dbAccess = new DbAccess();

            return dbAccess.AddBooking(request);
        }