public IActionResult ConfirmBooking([FromBody] BookingRequest model)
        {
            if (model == null)
            {
                return(BadRequest("invalid object"));
            }
            string          email  = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            ApplicationUser user   = context.ApplicationUsers.FirstOrDefault(c => c.Email.Equals(email));
            string          result = IDriverService.ConfirmBooking(user, model);

            if (result == "Ok")
            {
                string text;
                if (model.Accepted == true)
                {
                    text = "Ride Requested Accepted";
                }
                else
                {
                    text = "Ride Request Rejected";
                }
                return(Ok(new
                {
                    status = 200,
                    message = text
                }));
            }
            return(BadRequest(new
            {
                error = result
            }));
        }
        public JsonResult RejectBooking(int?Id)
        {
            BookingRequest br = db.BookingRequests.Find(Id);

            if (br != null)
            {
                br.Status = 2;
                db.SaveChanges();

                string TourTitle = "";
                if (br.Tour.FromId == br.Tour.DestinationId)
                {
                    TourTitle = br.Tour.City.CityName + " Tour";
                }
                else
                {
                    TourTitle = br.Tour.City.CityName + " - " + br.Tour.City1.CityName + " Tour";
                }

                Notification noti = new Notification
                {
                    UserId             = br.UserId,
                    Text               = "Booking request for " + TourTitle + " rejected. Please, choose another dates.",
                    Date               = DateTime.Now,
                    NotificationTypeId = 7,
                    Link               = "#",
                    Status             = 0,
                };

                return(Json(1, JsonRequestBehavior.AllowGet));
            }
            return(Json(0, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        // GET: ManageBooking/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BookingRequest bookingRequest = db.BookingRequests.Find(id);

            if (bookingRequest == null)
            {
                return(HttpNotFound());
            }

            //Find available table
            string query = "SELECT * FROM dbo.BranchTables WHERE " +
                           "dbo.BranchTables.Id NOT IN (SELECT dbo.BookingRequests.BranchTableId FROM dbo.BookingRequests " +
                           "WHERE " +
                           "dbo.BookingRequests.Date = '" + bookingRequest.Date.ToString("yyyy-MM-dd") +
                           "' AND dbo.BookingRequests.RealTimeStart <=" + bookingRequest.Time +
                           " AND dbo.BookingRequests.RealTimeEnd >" + bookingRequest.Time +
                           " AND dbo.BookingRequests.BranchId =" + bookingRequest.BranchId +
                           " AND dbo.BookingRequests.BookingStatus = 1)" +
                           " AND dbo.BranchTables.BranchId = " + bookingRequest.BranchId;

            var availTable = db.Database.SqlQuery <BranchTable>(query).ToList();

            ViewBag.AvailTable = availTable;
            return(View(bookingRequest));
        }
Exemplo n.º 4
0
        public BookingValidation ValidateBooking(BookingRequest bookingRequest, IEnumerable <Agent> allAgents, IEnumerable <Property> allProperties)
        {
            if (isNameInvalid(bookingRequest))
            {
                return(new BookingValidation
                {
                    IsValid = false,
                    ErrorMessage = "You must provide a name."
                });
            }

            if (isEmailInvalid(bookingRequest))
            {
                return(new BookingValidation
                {
                    IsValid = false,
                    ErrorMessage = "You must provide an email address."
                });
            }

            if (isPhoneNumberInvalid(bookingRequest))
            {
                return(new BookingValidation
                {
                    IsValid = false,
                    ErrorMessage = "You must provide a phone number."
                });
            }

            return(new BookingValidation
            {
                IsValid = true,
                ErrorMessage = ""
            });
        }
Exemplo n.º 5
0
        public async Task <Booking> RequestBikeBooking(Station fromStation, Station toStation)
        {
            CheckBikesAvailability(fromStation);

            var userId        = _authenticationService.GetCurrentUserId();
            var fromStationId = fromStation.Id;

            UriBuilder builder = new UriBuilder(GlobalSettings.RidesEndpoint);

            builder.Path = $"api/stations/{fromStationId}/checkout";

            string uri = builder.ToString();

            BookingRequest request = new BookingRequest
            {
                EndStationId = toStation.Id,
                UserId       = userId
            };

            int bookingId = await _requestProvider.PutAsync <BookingRequest, int>(uri, request);

            Booking booking = await GetBooking(bookingId);

            Settings.CurrentBookingId = booking.Id;

            return(booking);
        }
Exemplo n.º 6
0
        public void DeleteBooking(BookingRequest request)
        {
            if (request.LicenseKey != "secret")
            {
                throw new WebFaultException <string>("Wrong licese key", HttpStatusCode.Forbidden);
            }
            else
            {
                string cs = ConfigurationManager.ConnectionStrings["CRCS"].ConnectionString;

                using (SqlConnection con = new SqlConnection(cs))
                {
                    SqlCommand cmd = new SqlCommand("spDeleteBooking", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlParameter parameterId = new SqlParameter();
                    parameterId.ParameterName = "@Id";
                    parameterId.Value         = request.BookingId;

                    cmd.Parameters.Add(parameterId);

                    con.Open();
                    cmd.ExecuteNonQuery();
                }
            }
        }
Exemplo n.º 7
0
        private Response BookTicket(BookingRequest request, CheckAvalibilityResponse avalibiltyResponse)
        {
            Response response = new Response();

            switch ((SeatingClass)Enum.Parse(typeof(SeatingClass), request.Class, true))
            {
            case SeatingClass.SliverClass:
            {
                response = ValidateAndBookTicket(avalibiltyResponse.SliverClass, request, avalibiltyResponse);
            }
            break;

            case SeatingClass.GoldClass:
            {
                response = ValidateAndBookTicket(avalibiltyResponse.GoldClass, request, avalibiltyResponse);
            }
            break;

            case SeatingClass.PlatinumClass:
            {
                response = ValidateAndBookTicket(avalibiltyResponse.PlatinumClass, request, avalibiltyResponse);
            }
            break;

            case SeatingClass.VIP:
            {
                response = ValidateAndBookTicket(avalibiltyResponse.VIP, request, avalibiltyResponse);
            }
            break;
            }
            return(response);
        }
        private async Task <string> PostMaintenanceServiceRequestForTheUser()
        {
            var userFilledFormValues = this.ConversationData.ServiceBookingForm;

            var userRequestedDelivaryDate = new System.DateTime(
                userFilledFormValues.Year.Value,
                userFilledFormValues.Month.Value,
                userFilledFormValues.Day.Value,
                userFilledFormValues.DayOrNight == "PM" ? userFilledFormValues.Hour.Value + 12 : userFilledFormValues.Hour.Value,
                userFilledFormValues.Minutes.Value,
                0);

            var conversationChannelData = new ConversationChannelData(
                this.UserProfile.Id,
                this.UserProfile.Name,
                this.ConversationData.BotId,
                this.ConversationData.BotName,
                this.UserProfile.ChannelId,
                this.ConversationData.ConversationId,
                this.ConversationData.ServiceUrl);

            var serviceBookingRequest = new BookingRequest(
                userFilledFormValues.RequestedService.Value,
                userFilledFormValues.RequiredServiceDescription,
                userFilledFormValues.DeliveryLocation,
                userRequestedDelivaryDate,
                conversationChannelData,
                this.UserProfile.PreferredLanguage.Value);

            var stringContent = new StringContent(JsonConvert.SerializeObject(serviceBookingRequest), Encoding.UTF8, "application/json");
            var response      = await httpClient.PostAsync("http://localhost:2614/api/MaintenanceServicesRequests/AddRequest/", stringContent);

            return(await response.Content.ReadAsAsync <string>());
        }
Exemplo n.º 9
0
        public async Task <bool> ProcessAsync(BookingRequest request)
        {
            var hotel = await _hotelService.GetHotelAsync(request.HotelId);

            if (hotel == null)
            {
                new BookingException(BookingExceptionCode.HotelNotFound, $"Hotel with {request.HotelId} not found");
            }

            int totalCapacity = hotel.Rooms.Sum(room => room.Capacity);
            int totalGuests   = request.Adults + request.Kids + request.Babies;

            if (totalCapacity < totalGuests)
            {
                throw new BookingException(BookingExceptionCode.GuestsRoomsMissmatch, "Number of guests doesn't match selected rooms capacity");
            }

            int totalPrice = 0;

            for (int i = 0; i < request.Rooms.Count(); i++)
            {
                var roomRequest = request.Rooms.ElementAt(i);
                CalculatePrice(out var price, hotel, roomRequest);
                totalPrice += price;
            }

            if (request.Price != totalPrice)
            {
                throw new BookingException(BookingExceptionCode.InvalidPrice, "Invalid price");
            }

            return(await _bookingService.RequestBookingAsync(request));
        }
Exemplo n.º 10
0
        [TestCase(4, 11, false, "There is an existing booking")]  // Should fail - booking encompasses an existing booking
        public void DoctorCannotBeDoubleBooked(
            int requestStartOffset,
            int requestEndOffset,
            bool pass,
            string expectedError = default)
        {
            var requestStartTime = Now.AddTicks(requestStartOffset);
            var requestEndTime   = Now.AddTicks(requestEndOffset);

            var validator = new BookingRequestValidator(_context, _dateProvider);

            var bookingRequest = new BookingRequest
            {
                StartTime = requestStartTime,
                EndTime   = requestEndTime,
                DoctorId  = _doctorId
            };

            var result = validator.ValidateRequest(bookingRequest);

            Assert.That(result.PassedValidation, Is.EqualTo(pass));

            if (pass)
            {
                Assert.That(result.Errors, Is.Empty);
            }
            else
            {
                Assert.That(result.Errors.Single(), Is.EqualTo(expectedError));
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,StudentId,TutorId,BookingDate")] BookingRequest bookingRequest)
        {
            if (id != bookingRequest.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bookingRequest);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookingRequestExists(bookingRequest.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["TutorId"] = new SelectList(_context.Set <Tutor>(), "Id", "Name", bookingRequest.TutorId);
            return(View(bookingRequest));
        }
Exemplo n.º 12
0
        public void BookingsCannotBeInThePast(int startOffset, int endOffset, bool pass, string expectedError = null)
        {
            var requestStartTime = Now.AddTicks(startOffset);
            var requestEndTime   = Now.AddTicks(endOffset);

            var validator = new BookingRequestValidator(_context, _dateProvider);

            var bookingRequest = new BookingRequest
            {
                StartTime = requestStartTime,
                EndTime   = requestEndTime
            };

            var result = validator.ValidateRequest(bookingRequest);

            Assert.That(result.PassedValidation, Is.EqualTo(pass));
            if (pass)
            {
                Assert.That(result.Errors, Is.Empty);
            }
            else
            {
                Assert.That(result.Errors.Single(), Is.EqualTo(expectedError));
            }
        }
Exemplo n.º 13
0
        public void MakeBooking(BookingRequest bookingRequest)
        {
            var validationResult = _bookingRequestValidator.ValidateRequest(bookingRequest);

            if (!validationResult.PassedValidation)
            {
                throw new ArgumentException(validationResult.Errors.First());
            }

            var bookingId          = new Guid();
            var bookingStartTime   = bookingRequest.StartTime;
            var bookingEndTime     = bookingRequest.EndTime;
            var bookingPatientId   = bookingRequest.PatientId;
            var bookingPatient     = _context.Patient.FirstOrDefault(x => x.Id == bookingRequest.PatientId);
            var bookingDoctorId    = bookingRequest.DoctorId;
            var bookingDoctor      = _context.Doctor.FirstOrDefault(x => x.Id == bookingRequest.DoctorId);
            var bookingSurgeryType = _context.Patient.FirstOrDefault(x => x.Id == bookingPatientId).Clinic.SurgeryType;

            var myBooking = new Order
            {
                Id          = bookingId,
                StartTime   = bookingStartTime.DateTime,
                EndTime     = bookingEndTime.DateTime,
                PatientId   = bookingPatientId,
                DoctorId    = bookingDoctorId,
                Patient     = bookingPatient,
                Doctor      = bookingDoctor,
                SurgeryType = (int)bookingSurgeryType
            };

            _context.Order.AddRange(new List <Order> {
                myBooking
            });
            _context.SaveChanges();
        }
        private bool IsSlotAlreadyBooked(BookingRequest request, ref PdrValidationResult result)
        {
            if (!_context.Order.Any())
            {
                return(false);
            }


            if (_context.Order.Any(x =>
                                   (x.PatientId == request.PatientId) &&
                                   ((x.StartTime <= request.StartTime && x.EndTime >= request.StartTime) || (x.StartTime <= request.EndTime && x.EndTime >= request.EndTime))
                                   )
                )
            {
                result.PassedValidation = false;
                result.Errors.Add("There is already an appointment scheduled for the patient at the selected time");
                return(true);
            }

            if (_context.Order.Any(x =>
                                   (x.DoctorId == request.DoctorId) &&
                                   ((x.StartTime <= request.StartTime && x.EndTime >= request.StartTime) || (x.StartTime <= request.EndTime && x.EndTime >= request.EndTime))
                                   )
                )
            {
                result.PassedValidation = false;
                result.Errors.Add("There is already an appointment scheduled for the doctor at the selected time");
                return(true);
            }

            return(false);
        }
Exemplo n.º 15
0
        public bool AddBooking(BookingRequest bookingRequest)
        {
            var requestMeeting = bookingRequest.Meeting;

            foreach (var existingBookingRequest in _bookingRequests)
            {
                if (existingBookingRequest.SubmissionTime == bookingRequest.SubmissionTime)
                {
                    return(false);
                }

                // Todo - Replace the meeting equality condition in if block
                // can be replaced with .Equals() after overriding Equals()
                // GetHashCode() methods in Meeting class
                if (existingBookingRequest.Meeting.StartTime == requestMeeting.StartTime &&
                    existingBookingRequest.Meeting.FinishTime == requestMeeting.FinishTime)
                {
                    var index = _bookingRequests.IndexOf(existingBookingRequest);
                    _bookingRequests[index] = bookingRequest;
                    return(true);
                }
            }

            if (IsMeetingWithinOfficeHours(bookingRequest.Office, bookingRequest.Meeting) &&
                !MeetingOverlaps(bookingRequest.Meeting))
            {
                _bookingRequests.Add(bookingRequest);
                return(true);
            }

            return(false);
        }
Exemplo n.º 16
0
        public async Task <ActionResult <Car> > PostBooking([FromBody] BookingRequest bookingRequest)
        {
            //
            // Check if request object is valid
            //
            if (!bookingRequest.IsValid())
            {
                return(BadRequest("Invalid request object."));
            }

            //
            // Check if car exists
            //
            if (!_context.Cars.Any(car => car.CarId == bookingRequest.CarId))
            {
                return(BadRequest("Invalid car id."));
            }

            //
            // Create new booking
            //
            _context.Bookings.Add(new Booking
            {
                CarId      = bookingRequest.CarId,
                BookedDate = bookingRequest.BookingDate.Date
            });


            await _context.SaveChangesAsync();

            return(Ok());
        }
 public override Task <BookingResponse> Book(BookingRequest request, ServerCallContext context)
 {
     return(Task.FromResult(new BookingResponse()
     {
         Message = "Hello " + request.Name
     }));
 }
Exemplo n.º 18
0
        public ActionResult Details(int Id, int Time, int table)
        {
            BookingRequest bookingRequest = db.BookingRequests.Find(Id);

            if (ModelState.IsValid)
            {
                bookingRequest.RealTimeStart = Time;
                bookingRequest.RealTimeEnd   = Time + 200;
                bookingRequest.BookingStatus = 1;
                bookingRequest.BranchTableId = table;
                db.SaveChanges();

                var branch = db.Branches.Find(bookingRequest.BranchId);

                string subject  = "Your booking request has been scheduled";
                string contents = "Booking confirmation: <br /> " +
                                  "Branch: " + branch.Name + " (" + branch.Address + ", tel: " + branch.Telephone + ")<br />" +
                                  "Schedule: " + bookingRequest.Date.ToString("dd/MM/yyyy") + ", " + bookingRequest.RealTimeStart +
                                  " - " + bookingRequest.RealTimeEnd + "<br/>" +
                                  "We are looking forward to your arrival";

                EmailSender es = new EmailSender();
                es.Send(bookingRequest.Email, subject, contents);

                return(RedirectToAction("Index"));
            }
            return(View(bookingRequest));
        }
Exemplo n.º 19
0
        private async Task <bool> UpdateUserWithNewRequestStatusAsync(BookingRequest userRequest)
        {
            if (userRequest != null)
            {
                var endpointToHitInBot = botUserUpdatingEndPointUrl;
                if (userRequest.Status == RequestStatuses.ApprovedAndWaitingDelivery)
                {
                    endpointToHitInBot += "RequestApproved";
                }
                else if (userRequest.Status == RequestStatuses.Delivered)
                {
                    endpointToHitInBot += "RequestDelivered";
                }
                else
                {
                    return(true);
                }

                var requestAsStringContent = new StringContent(JsonConvert.SerializeObject(userRequest), Encoding.UTF8, "application/json");
                var response = await httpClient.PostAsync(endpointToHitInBot, requestAsStringContent);

                return(response.StatusCode == HttpStatusCode.OK);
            }

            return(false);
        }
Exemplo n.º 20
0
        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.º 21
0
        public async Task <ActionResult> Post([FromBody] BookingRequest bookingRequest)
        {
            try
            {
                var result = await _bookingService.RequestBookingAsync(bookingRequest);

                _logger.LogInformation($"Endpoint placeReservation: new booking with the id {result.BookingId} was created");
                return(StatusCode(StatusCodes.Status201Created, result));
            }
            catch (BookingException ex)
            {
                var statusCode = ex.Code switch
                {
                    BookingExceptionCode.Unknown => StatusCodes.Status500InternalServerError,
                    BookingExceptionCode.RoomNotAvailable => StatusCodes.Status404NotFound,
                    BookingExceptionCode.BadRequest => StatusCodes.Status400BadRequest,
                    _ => StatusCodes.Status500InternalServerError,
                };
                _logger.LogError($"Endpoint placeReservation: {ex.Code} {ex.Message}");
                return(StatusCode(statusCode, new { ex.Message }));
            }
            catch (Exception ex)
            {
                _logger.LogCritical($"Endpoint placeReservation: {ex.Message}");
                return(StatusCode(StatusCodes.Status500InternalServerError, new { Error = ex.Message }));
            }
        }
Exemplo n.º 22
0
        public BookingValidation ValidateBooking(BookingRequest bookingRequest, IEnumerable <Agent> allAgents, IEnumerable <Property> allProperties)
        {
            if (string.IsNullOrEmpty(bookingRequest.Name))
            {
                return(BookingValidation.InValid("You must provide a name"));
            }

            if (string.IsNullOrEmpty(bookingRequest.EmailAddress))
            {
                return(BookingValidation.InValid("You must provide an email address"));
            }

            var agent = FindAgentForBooking(bookingRequest, allAgents);

            if (agent == null)
            {
                return(BookingValidation.InValid("Sorry - we couldn't find a matching agent."));
            }

            var property = FindPropertyForBooking(bookingRequest, allProperties);

            if (property == null)
            {
                return(BookingValidation.InValid("Sorry - we couldn't find a matching property."));
            }

            return(BookingValidation.Valid());
        }
        public async Task <ApiResponse> Create(BookingRequest model)
        {
            // Check if activity exist
            var activity = await _bookingDbContext.Activities.FindAsync(model.ActivityId);

            if (activity == null)
            {
                return(new ApiResponse(400, "Activity does not exist"));
            }

            // Check if booking is within open hours
            if (model.Start.Hour < activity.Open || model.Start.Hour >= activity.Close)
            {
                return(new ApiResponse(400, "Booking cannot be made outside of open hours"));
            }

            // Get current user
            var user = await _userManager.GetUserAsync(model.UserPrincipal);

            var userRoles = await _userManager.GetRolesAsync(user);

            if (!userRoles.Contains(UserRoles.Admin))
            {
                // Check if bookings is to long
                var diff = model.End - model.Start;
                if (diff.TotalMinutes > 60)
                {
                    return(new ApiResponse(400, "Booking time is to long"));
                }
                // Check if user already have a booking that day
                var from   = new DateTime(model.Start.Year, model.Start.Month, model.Start.Day);
                var to     = GetNextDay(from);
                var result = await _bookingDbContext.Bookings.AnyAsync(b =>
                                                                       b.ActivityId == model.ActivityId && b.UserId == user.Id && b.Start >= from && b.Start < to);

                if (result)
                {
                    return(new ApiResponse(400, "Cannot make more than one booking per day and activity"));
                }
            }

            // Check if there is already a booking at that time
            var exist = await _bookingDbContext.Bookings.AnyAsync(b =>
                                                                  b.ActivityId == model.ActivityId && b.Start < model.End && model.Start < b.End);

            if (exist)
            {
                return(new ApiResponse(400, "A booking already exist in time period"));
            }

            var booking = new Booking
            {
                Start = model.Start, End = model.End, ActivityId = model.ActivityId, UserId = user.Id
            };
            await _bookingDbContext.Bookings.AddAsync(booking);

            await _bookingDbContext.SaveChangesAsync();

            return(new ApiResponse(true, 201));
        }
Exemplo n.º 24
0
        public async Task <int> ConfirmBooking(BookingRequest bookingRequest)
        {
            var tourGuests = bookingRequest.Participants.Select(participant => new TourGuest()
            {
                ExistingUserId   = participant.Id,
                FirstName        = participant.FirstName,
                LastName         = participant.LastName,
                Email            = participant.Email,
                Phone            = participant.Phone,
                Address          = participant.Address,
                EmergencyContact = participant.EmergencyContact
            }).ToList();

            var firstOrDefault = tourGuests.FirstOrDefault();

            if (firstOrDefault != null)
            {
                firstOrDefault.IsPrimary = true;
            }

            var booking = new Booking
            {
                ListingId   = bookingRequest.ListingId,
                BookingDate = bookingRequest.BookingDate,
                StartTime   = bookingRequest.Time,
            };

            return(await _bookingRepository.ConfirmBooking(booking, tourGuests));
        }
Exemplo n.º 25
0
 private Expression <Func <Order, bool> > IsDoubleBooked(BookingRequest request)
 {
     return(order => order.DoctorId == request.DoctorId &&
            ((order.StartTime <= request.StartTime && order.EndTime >= request.EndTime) ||
             (order.StartTime >= request.StartTime && order.StartTime <= request.EndTime) ||
             (order.EndTime >= request.StartTime && order.EndTime <= request.EndTime)));
 }
        private bool IsValid(BookingRequest req)
        {
            var targetFlights = _dbCtx.Flights.Where(flight => flight.FlightNo == req.FlightNumber);

            if (!targetFlights.Any())
            {
                throw new HttpException(400, "Flight number not found");
            }
            if (req.TravelDay < DateTime.Now)
            {
                throw new HttpException(400, "Can't book earlier than today");
            }

            var flights = _flightRep.ListAvailability(new FlightAvailabiltyRequest()
            {
                CityFrom  = _dbCtx.Cities.FirstOrDefault(x => x.Id == targetFlights.FirstOrDefault().DepartingCityId).CityName,
                CityTo    = _dbCtx.Cities.FirstOrDefault(x => x.Id == targetFlights.FirstOrDefault().ArrivalCityId).CityName,
                StartDate = req.TravelDay,
                EndDate   = req.TravelDay
            });

            if (flights.Any(x => x.AvailableSeats < 1))
            {
                throw new HttpException(400, "No seats are available");
            }

            return(true);
        }
Exemplo n.º 27
0
        public ActionResult Index([Bind(Include = "Id,Date,Time,Note,Persons,Email,FullName,Telephone,WaitingList,BranchId")] BookingRequest bookingRequest)
        {
            if (ModelState.IsValid)
            {
                bookingRequest.TransactionDate = DateTime.Now;
                db.BookingRequests.Add(bookingRequest);
                db.SaveChanges();

                var branch = db.Branches.Find(bookingRequest.BranchId);

                string subject  = "Your booking request will be arranged";
                string contents = "Booking confirmation: <br /> " +
                                  "Branch: " + branch.Name + " (" + branch.Address + ", tel: " + branch.Telephone + ")<br />" +
                                  "Schedule: " + bookingRequest.Date.ToString("dd/MM/yyyy") + ", " + bookingRequest.Time + "<br/>" +
                                  "We are arranging your request. We will send you a confirmation email soon as possible.";

                EmailSender es = new EmailSender();
                es.Send(bookingRequest.Email, subject, contents);

                return(RedirectToAction("Index", new { message = 1 }));
            }
            var branches = db.Branches.ToList();

            ViewBag.Branches = branches;

            var menus = db.Menus.ToList();

            ViewBag.Menus = menus;
            return(View(bookingRequest));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            BookingRequest bookingRequest = db.BookingRequests.Find(id);

            db.BookingRequests.Remove(bookingRequest);
            db.SaveChanges();
            return(RedirectToAction("List"));
        }
Exemplo n.º 29
0
        public async Task Reserve_ShouldReturn_Guid()
        {
            var request = new BookingRequest();

            var result = await _bookingProvider.Reserve(request);

            Assert.IsType <Guid>(result);
        }
Exemplo n.º 30
0
 public BookingValidation ValidateBooking(BookingRequest bookingRequest, IEnumerable <Agent> allAgents, IEnumerable <Property> allProperties)
 {
     return(new BookingValidation
     {
         IsValid = true,
         ErrorMessage = ""
     });
 }