Example #1
0
        public ActionResult Create(CreateBookingRequestViewModel model)
        {
            try
            {
                var startDate     = Convert.ToDateTime(model.CheckinDate);
                var endDate       = Convert.ToDateTime(model.CheckOutDate);
                var roomTypes     = _roomTypeRepo.FindAll();
                var roomTypeItems = roomTypes.Select(q => new SelectListItem
                {
                    Text  = q.RoomName,
                    Value = q.RoomTypeId.ToString()
                });
                model.RoomType = roomTypeItems;
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                if (DateTime.Compare(startDate, endDate) > 1)
                {
                    ModelState.AddModelError("", "CheckinDate cannot be further than the CheckOutDate");
                    return(View(model));
                }
                var employee      = _userManager.GetUserAsync(User).Result;
                var allocation    = _bookingRepo.GetBookingsByEmployeeAndType(employee.Id, model.RoomTypeId);//id to employee id
                int daysRequested = (int)(startDate - endDate).TotalDays;

                if (daysRequested > allocation.NumberOfDays)
                {
                    ModelState.AddModelError("", "You do not have sufficient days to make this request");
                    return(View(model));
                }

                var bookingRequestModel = new BookingRequestViewModel
                {
                    EmployeeBookingRoomId = employee.Id,
                    CheckinDate           = startDate,
                    CheckOutDate          = endDate,
                    Approved      = null,
                    DateRequested = DateTime.Now,
                    DateActioned  = DateTime.Now,
                    RoomTypeId    = model.RoomTypeId
                };
                var bookingRequest = _mapper.Map <BookingRequest>(bookingRequestModel);
                var isSuccess      = _bookingRequestRepo.Create(bookingRequest);

                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something went wrong WITH SUBMITTING RECORD");
                    return(View(model));
                }
                return(RedirectToAction("MyBooking"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Something went wrong");
                return(View(model));
            }
        }
Example #2
0
        public async Task <BookingResponseViewModel> Get(int inventoryId)
        {
            var bookingInfo = new BookingRequestViewModel()
            {
                InventoryId = inventoryId
            };

            return(await _context.BookInventory(bookingInfo));
        }
        public IActionResult Index(BookingRequestViewModel viewModel)
        {
            if (!string.IsNullOrWhiteSpace(viewModel.ClientMail))
            {
                // Create the task and send it to the bus
                var bookingCommand = new BookingCommand(clientId: viewModel.ClientMail, hotelName: viewModel.HotelName, hotelId: int.Parse(viewModel.HotelId), roomNumber: viewModel.RoomId, checkInDate: viewModel.CheckInDate, checkOutDate: viewModel.CheckOutDate);
                this.bus.Send(bookingCommand);

                viewModel.BookingSucceeded = true;
            }
            else
            {
                viewModel.BookingSucceeded = false;
            }

            return(View(viewModel));
        }
        public async Task <BookingResponseViewModel> BookInventory(BookingRequestViewModel bookingRequestViewModel)
        {
            BookingResponseViewModel model = new BookingResponseViewModel();

            try
            {
                var holdResponse = await HoldUnitAsync(bookingRequestViewModel.InventoryId);

                if (!holdResponse.IsSuccess)
                {
                    model.Message = holdResponse.Message;
                    return(model);
                }

                var hldUpdate = _rsiContext.Holds.FirstOrDefault(x => x.keyid == holdResponse.HoldId);
                if (hldUpdate != null)
                {
                    hldUpdate.isBooking = true;
                    await _rsiContext.SaveChangesAsync();
                }

                string message = "";
                bool?  status  = null;
                var    result  = await _rsiContext.LoadStoredProc("dbo.vipConfirmAHold")
                                 .WithSqlParam("message", message, ParameterDirection.InputOutput)
                                 .WithSqlParam("status", status, ParameterDirection.InputOutput)
                                 .WithSqlParam("holdID", holdResponse.HoldId)
                                 .WithSqlParam("creatorID", holdResponse.HoldUser)
                                 .WithSqlParam("travelerFirstName", bookingRequestViewModel.FirstName)
                                 .WithSqlParam("travelerMiddleInitial", bookingRequestViewModel.MiddleName)
                                 .WithSqlParam("travelerLastName", bookingRequestViewModel.LastName)
                                 .WithSqlParam("travelerAddress", bookingRequestViewModel.Address)
                                 .WithSqlParam("travelerCity", bookingRequestViewModel.City)
                                 .WithSqlParam("travelerStateCode", bookingRequestViewModel.State)
                                 .WithSqlParam("travelerPostalCode", bookingRequestViewModel.Zip)
                                 .WithSqlParam("travelerCountryCode", bookingRequestViewModel.Country)
                                 .WithSqlParam("travelerPhone1", bookingRequestViewModel.Phone1)
                                 .WithSqlParam("travelerPhone2", bookingRequestViewModel.Phone2)
                                 .WithSqlParam("travelerEmail", bookingRequestViewModel.Email)
                                 .WithSqlParam("billingFirstName", bookingRequestViewModel.FirstName)
                                 .WithSqlParam("billingMiddleInitial", bookingRequestViewModel.MiddleName)
                                 .WithSqlParam("billingLastName", bookingRequestViewModel.LastName)
                                 .WithSqlParam("billingAddress", bookingRequestViewModel.Address)
                                 .WithSqlParam("billingCity", bookingRequestViewModel.City)
                                 .WithSqlParam("billingStateCode", bookingRequestViewModel.State)
                                 .WithSqlParam("billingPostalCode", bookingRequestViewModel.Zip)
                                 .WithSqlParam("billingCountryCode", bookingRequestViewModel.Country)
                                 .WithSqlParam("billingPhone1", bookingRequestViewModel.Phone1)
                                 .WithSqlParam("billingPhone2", bookingRequestViewModel.Phone2)
                                 .WithSqlParam("billingEmail", bookingRequestViewModel.Email)
                                 .WithSqlParam("creditCardNumber", string.Empty)
                                 .WithSqlParam("mM", string.Empty)
                                 .WithSqlParam("yYYY", string.Empty)
                                 .WithSqlParam("cVV", string.Empty)
                                 .WithSqlParam("return_value", 0, ParameterDirection.ReturnValue)
                                 .ExecuteStoredProcAsync <int>();

                //these fields don't appear to be used in the old logic
                //message = (string)result.DbParameters["message"].Value;
                //status = (bool?)result.DbParameters["status"].Value;

                if (holdResponse.OwnerId == 100)
                {
                    //TODO: RCI.HoldResponse hr = _rci.ConfirmHold(_userName, _password, hld.inventorytype, hld.refnum);
                }

                //TODO: ? reservationId = vipMoveHoldToResTableDoNotUpdatePoints(hld.keyid, authCode);
                model.BookingId = holdResponse.HoldId;
            }
            catch (Exception ex)
            {
                if (model == null)
                {
                    model = new BookingResponseViewModel();
                }

                model.Message = $"Error: {ex.Message}";
            }

            return(model);
        }
 public IActionResult Index(BookingRequestViewModel bookingRequestViewModel)
 {
     return(View(bookingRequestViewModel));
 }