public ActionResult SavePassenger(Models.Booking booking)
        {
            Passenger pxFromDb = CheckIfPassengerIsAlreadyInDb(booking.Passenger);

            if (pxFromDb == null)
            {
                SqlConnection cn = new SqlConnection();
                cn.ConnectionString = ConfigurationManager.ConnectionStrings["ReservationSystem"].ConnectionString; // Configuration.GetConnectionString();

                string     query     = @"INSERT INTO [dbo].[Passenger]
           ([FirstName]
           ,[LastName]
           ,[Identification]
           ,[Email])
     VALUES
            (@firstName,@lastName,@identification,@email)";
                SqlCommand myCommand = new SqlCommand();
                myCommand.Connection  = cn;
                myCommand.CommandText = query;
                myCommand.Parameters.AddWithValue("@firstName", booking.Passenger.FirstName);
                myCommand.Parameters.AddWithValue("@lastName", booking.Passenger.LastName);
                myCommand.Parameters.AddWithValue("@identification", booking.Passenger.Identification);
                myCommand.Parameters.AddWithValue("@Email", booking.Passenger.Email);

                cn.Open();
                var id = myCommand.ExecuteNonQuery();
                cn.Close();
                booking.Seats        = (List <Seat>)Session["seats"];
                booking.Passenger.Id = id.ToString();
                return(View("Booking", booking));
            }
            booking.Seats     = (List <Seat>)Session["seats"];
            booking.Passenger = pxFromDb;
            return(View("Booking", booking));
        }
Exemple #2
0
        public async Task <ActionResult> Create(Models.Booking booking)
        {
            if (ModelState.IsValid)
            {
                //Sms sms = new Sms();
                //HttpCookie myCookie = new HttpCookie("MyCookie");
                //myCookie = Request.Cookies["MyCookie"];
                //int Id = Convert.ToInt16(myCookie);

                //try
                //{
                //	sms.Send_SMS(booking.PhoneNumber, "Hi, your booking has been successfully captured. Please consistantly check your status");
                //}
                //catch
                //{
                //	ViewBag.Error = "Invalid network";
                //}

                booking.DateTimeStamp = DateTime.Now;
                booking.Id            = Guid.NewGuid();
                booking.CustomerId    = User.Identity.GetUserId();
                booking.Status        = "Pending";
                await _booking.CreateBooking(booking);

                return(RedirectToAction("Index"));
            }
            ViewBag.CarMakes = new SelectList(await _make.GetMakes(), "Name", "Name");
            ViewBag.Services = new SelectList(await _booking.GetServiceTypes(), "Type", "Type");
            return(View(booking));
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateBookingRequest"/> class.
 /// </summary>
 /// <param name="booking">booking.</param>
 /// <param name="idempotencyKey">idempotency_key.</param>
 public CreateBookingRequest(
     Models.Booking booking,
     string idempotencyKey = null)
 {
     this.IdempotencyKey = idempotencyKey;
     this.Booking        = booking;
 }
        public IActionResult Edit(int id, [Bind("StartDate,EndDate,IsActive,CustomerId,RoomId")] Models.Booking booking)
        {
            if (id != booking.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    bookingRepository.Edit(booking);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (bookingRepository.Get(booking.Id) == null)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(customerRepository.GetAll(), "Id", "Name", booking.CustomerId);
            ViewData["RoomId"]     = new SelectList(roomRepository.GetAll(), "Id", "Description", booking.RoomId);
            return(View(booking));
        }
        public Models.Booking CheckAndInsertIfBookingIsAvailable(Models.Booking booking)
        {
            var queryBookingModel = new Queries.Models.Booking()
            {
                Name        = booking.Name,
                Email       = booking.Email,
                Address     = booking.Address,
                SeatId      = booking.SeatId,
                MeetingWeek = booking.MeetingWeek
            };

            var result = _bookingService.CheckBookingExists(queryBookingModel);

            if (result == false)
            {
                var insertedBookingModel = new Repository.Booking()
                {
                    Name        = queryBookingModel.Name,
                    Email       = queryBookingModel.Email,
                    Address     = queryBookingModel.Address,
                    SeatId      = queryBookingModel.SeatId,
                    MeetingWeek = queryBookingModel.MeetingWeek
                };

                var insertBooking = _bookingService.InsertBooking(insertedBookingModel);

                return(booking);
            }
            else
            {
                //More than 4 seats or Booking already exists for seat!
                return(null);
            }
        }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CancelBookingResponse"/> class.
 /// </summary>
 /// <param name="booking">booking.</param>
 /// <param name="errors">errors.</param>
 public CancelBookingResponse(
     Models.Booking booking      = null,
     IList <Models.Error> errors = null)
 {
     this.Booking = booking;
     this.Errors  = errors;
 }
Exemple #7
0
        // GET: BookingsController/Create
        public ActionResult Create(Models.Flight f)
        {
            Models.Booking b = new Models.Booking();

            b.FlightNo = f.FlightNo;
            b.Price    = f.SeatPrice;

            return(View(b));
        }
        public async Task <ActionResult <Models.BookingError> > PostBooking(Models.Booking bM)
        {
            Console.WriteLine(bM);

            Flight f = _context.FlightSet.Find(bM.FlightNo);

            if (f == null)
            {
                return(new Models.BookingError(404, "The flight was not find, please try again"));
            }
            Models.Flight fM = f.ConvertToFlightM();
            if (fM.AvailableSeats <= 0)
            {
                return(new Models.BookingError(99, "The selected flight is already full"));
            }
            if (fM.Date < DateTime.Now)
            {
                return(new Models.BookingError(36, "The selected flight is not available"));
            }
            var calculatedPrice = fM.GetPrice();

            Console.WriteLine(calculatedPrice);
            if (!fM.GetPrice().Equals(bM.Price))
            {
                return(new Models.BookingError(103, "The selected price does not match. Please retry the booking"));
            }

            Passenger p = new Passenger {
                Surname = bM.Surname, GivenName = bM.GivenName, Weight = bM.Weight
            };

            _context.PassengerSet.Add(p);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                throw;
            }

            Booking b = new Booking {
                FlightNo = bM.FlightNo, PassengerID = p.PersonID, PricePaid = bM.Price
            };

            _context.BookingSet.Add(b);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                throw;
            }

            return(new Models.BookingError(500, "The booking was successfully registered"));
        }
Exemple #9
0
        public Task <Models.Booking> CreateBookingAsync(Models.Booking booking, string token = "")
        {
            var builder = new UriBuilder(AppSettings.BookingEndpoint);

            builder.AppendToPath("Bookings");

            var uri = builder.ToString();

            return(_requestService.PostAsync <Models.Booking>(uri, booking, token));
        }
Exemple #10
0
        public static Models.Booking ConvertToBookingM(this EFCoreApp2020E.Booking b)
        {
            Models.Booking bM = new Models.Booking();
            bM.Surname   = b.Passenger.Surname;
            bM.GivenName = b.Passenger.GivenName;
            bM.Weight    = b.Passenger.Weight;
            bM.FlightNo  = b.FlightNo;
            bM.Price     = b.PricePaid;

            return(bM);
        }
        private async Task BookingAsync()
        {
            try
            {
                var authenticatedUser = _authenticationService.AuthenticatedUser;

                var booking = await DialogService.ShowConfirmAsync(
                    string.Format(Resources.DialogBookingMessage, Hotel.Name),
                    Resources.DialogBookingTitle,
                    Resources.DialogYes,
                    Resources.DialogNo);

                if (booking)
                {
                    var user = _authenticationService.AuthenticatedUser;

                    var newBooking = new Models.Booking
                    {
                        UserId  = user.Email,
                        HotelId = Hotel.Id,
                        Adults  = 1,
                        Babies  = 0,
                        Kids    = 0,
                        Price   = Hotel.PricePerNight,
                        Rooms   = new List <Models.Room>
                        {
                            new Models.Room {
                                Quantity = 1, RoomType = 0
                            }
                        },
                        From = _from,
                        To   = _until
                    };

                    await _bookingService.CreateBookingAsync(newBooking, authenticatedUser.Token);

                    AppSettings.HasBooking = true;

                    await NavigationService.NavigateToAsync <MainViewModel>();

                    MessagingCenter.Send(newBooking, MessengerKeys.BookingRequested);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"[Booking] Error: {ex}");

                await DialogService.ShowAlertAsync(
                    Resources.ExceptionMessage,
                    Resources.ExceptionTitle,
                    Resources.DialogOk);
            }
        }
        public async Task <Models.Booking> CreateBookingAsync(Models.Booking booking, string token = "")
        {
            await Task.Delay(500);

            Bookings.Add(new Models.BookingSummary
            {
                HotelId = booking.HotelId,
                UserId  = booking.UserId,
                From    = booking.From,
                To      = booking.To
            });

            return(booking);
        }
        // GET: Bookings/Details/5
        public IActionResult Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Models.Booking booking = bookingRepository.Get(id.Value);
            if (booking == null)
            {
                return(NotFound());
            }

            return(View(booking));
        }
Exemple #14
0
        public bool UpdateBookDate(int id, Models.Booking booking)
        {
            var result = context.Bookings.FirstOrDefault(x => x.roomID == id);

            if (result != null)
            {
                result.BookingDate = booking.BookingDate;
                context.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #15
0
        public bool UpdateStatus(int id, Models.Booking booking)
        {
            var result = context.Bookings.FirstOrDefault(x => x.Id == id);

            if (result != null)
            {
                result.bookingStatus = booking.bookingStatus;
                context.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public ActionResult Booking(Models.Booking booking)
 {
     try
     {
         booking.BookingID = rep.AddBooking(Mapper.Map <Models.Booking, bookMySeat.Booking>(booking));
         if (booking.BookingID == "")
         {
             return(View("Error"));
         }
         return(View("BookingDetails", booking));
     }
     catch (Exception ex)
     {
         return(View("Error"));
     }
 }
        // GET: Bookings/Edit/5
        public IActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Models.Booking booking = bookingRepository.Get(id.Value);
            if (booking == null)
            {
                return(NotFound());
            }
            ViewData["CustomerId"] = new SelectList(customerRepository.GetAll(), "Id", "Name", booking.CustomerId);
            ViewData["RoomId"]     = new SelectList(roomRepository.GetAll(), "Id", "Description", booking.RoomId);
            return(View(booking));
        }
 public ActionResult Delete(int id)
 {
     using (var Db = new DB())
     {
         try
         {
             Models.Booking DeleteBooking = Db.Booking.SingleOrDefault(k => k.Id == id);
             Db.Booking.Remove(DeleteBooking);
             Db.SaveChanges();
         }
         catch (Exception e)
         {
             Console.WriteLine("Feil under sletting av ordre. Lær deg hvordan du håndterer exceptions" + e.Message);
         }
     }
     return(RedirectToAction("Orders"));
 }
Exemple #19
0
 public async Task CreateBooking(Models.Booking booking)
 {
     try
     {
         using (ApplicationDbContext context = new ApplicationDbContext())
         {
             var findVehicleId = context.Vehicles.Where(v => v.RegistrationNumber
                                                        == booking.Reference).FirstOrDefault();
             var data = context.BookedVehicles.Where(b => b.VehilcleId == findVehicleId.Id).FirstOrDefault();
             booking.Reference        = data.Reference;
             findVehicleId.CustomerId = booking.CustomerId;
             context.Bookings.Add(booking);
             await context.SaveChangesAsync();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ActionResult confirmBooking(string fname, string lname, string phone, string email)
        {
            Models.Booking book     = (Models.Booking)Session["book"];
            Customer       customer = new Customer();

            customer.firstName = fname;
            customer.lastName  = lname;
            customer.emailId   = email;
            customer.phone     = phone;
            customer.carId     = book.carId;
            customer.rentTotal = "";
            customer.feesTaxes = "";
            customer.addedBy   = "";
            CarController c = new CarController();

            c.addBooking(book, customer);
            return(RedirectToAction("Confirmation", "Home"));

            return(View());
        }
Exemple #21
0
        public async Task BookingReminder(Models.Booking booking)
        {
            using (ApplicationDbContext context = new ApplicationDbContext())
            {
                var customer  = context.Customer.Where(c => c.UserId == booking.CustomerId)?.FirstOrDefault();
                var vehicleId = context.BookedVehicles.Where(v => v.Reference == booking.Reference)
                                .FirstOrDefault().VehilcleId;
                var vehicle = context.Vehicles.Find(vehicleId);
                using (StreamReader reader = new StreamReader(Path.Combine(HttpRuntime.AppDomainAppPath, "EmailTemplate/UpcomingBooking.html")))
                {
                    Body = reader.ReadToEnd();
                }
                Body = Body.Replace("{Header}", $"Booking Reminder : #{booking.Reference}");
                Body = Body.Replace("{Customer}", $"Dear {customer.FirstName} {customer.LastName}");
                Body = Body.Replace("{Message}", $"This is a friendly reminder that vehicle {vehicle.RegistrationNumber}" +
                                    $" is booked for {booking.ServiceType} Service at {booking.Mileage} Km's the service is tomorrow.");

                await SendEmail(Body, new MailAddress(customer.Email), "Booking Reminder");
            }
        }
        public ActionResult ConfirmBooking(Models.Booking booking)
        {
            booking.Seats = (List <Seat>)Session["seats"];
            SqlConnection cn = new SqlConnection();

            cn.ConnectionString = ConfigurationManager.ConnectionStrings["ReservationSystem"].ConnectionString; // Configuration.GetConnectionString();

            string seatNumbers = "(numbers)";

            string seats = "";

            foreach (var s in booking.Seats)
            {
                seats += s.SeatNumber + ",";
            }

            seats       = seats.Remove(seats.Length - 1, 1);
            seatNumbers = seatNumbers.Replace("numbers", seats);
            string query = @"UPDATE [dbo].[Seats]
   SET [PassengerId] = @passengerId
      ,[IsTaken] = 1
 WHERE RouteId = @routeId
and SeatNumber in @seatNumbers";

            query = query.Replace("@seatNumbers", seatNumbers);
            SqlCommand myCommand = new SqlCommand();

            myCommand.Connection  = cn;
            myCommand.CommandText = query;
            myCommand.Parameters.AddWithValue("@passengerId", booking.Passenger.Identification);
            myCommand.Parameters.AddWithValue("@routeId", booking.Route.Id);



            cn.Open();
            var id = myCommand.ExecuteNonQuery();

            cn.Close();
            booking.Passenger.Id = id.ToString();
            return(View("Summary", booking));
        }
Exemple #23
0
 public IHttpActionResult PostSaveTickets(Models.Booking book)
 {
     try
     {
         bool IsSave = false;
         var  guid   = Guid.NewGuid();
         book.Id = guid;
         this.unit._bookingRepository.Save(book);
         IsSave = this.unit.Commit() > 0 ? true : false;
         var pubDetails = this.unit._PubRepository.SelectAll().Where(x => x.Id == book.PubId).FirstOrDefault();
         pubDetails.Total = pubDetails.Total != 0 ? pubDetails.Total - 1 : pubDetails.Total;
         this.unit._PubRepository.Update(pubDetails);
         this.unit.Commit();
         return(Ok(IsSave));
     }
     catch (Exception ex)
     {
         ErrorLog.Log(ex);
         return(InternalServerError(ex));
     }
 }
Exemple #24
0
        public void InsertExistingBooking()
        {
            var booking = new Models.Booking()
            {
                Name        = "James Blackburn",
                Email       = "*****@*****.**",
                Address     = "108 Cranbourne Park",
                SeatId      = "A1",
                MeetingWeek = "1"
            };

            var bookingQueryModel = new Queries.Models.Booking()
            {
                Name        = "James Blackburn",
                Email       = "*****@*****.**",
                Address     = "108 Cranbourne Park",
                SeatId      = "A1",
                MeetingWeek = "1"
            };

            var bookingRepositoryModel = new Repository.Booking()
            {
                Name        = "James Blackburn",
                Email       = "*****@*****.**",
                Address     = "108 Cranbourne Park",
                SeatId      = "J10",
                MeetingWeek = "1"
            };

            //TODO Mock result is not being passed correctly still receiving 'false'
            bookingService.Setup(check => check.CheckBookingExists(bookingQueryModel)).Returns(true);

            bookingService.Setup(insert => insert.InsertBooking(bookingRepositoryModel)).Returns(bookingRepositoryModel);

            var controller = new BookingController(bookingService.Object);

            var result = controller.CheckAndInsertIfBookingIsAvailable(booking);

            Assert.IsNull(result);
        }
Exemple #25
0
        public void InsertNonExistingBooking()
        {
            var booking = new Models.Booking()
            {
                Name        = "James Blackburn",
                Email       = "*****@*****.**",
                Address     = "108 Cranbourne Park",
                SeatId      = "J10",
                MeetingWeek = "8"
            };

            var bookingQueryModel = new Queries.Models.Booking()
            {
                Name        = "James Blackburn",
                Email       = "*****@*****.**",
                Address     = "108 Cranbourne Park",
                SeatId      = "J10",
                MeetingWeek = "8"
            };

            var bookingRepositoryModel = new Repository.Booking()
            {
                Name        = "James Blackburn",
                Email       = "*****@*****.**",
                Address     = "108 Cranbourne Park",
                SeatId      = "J10",
                MeetingWeek = "8"
            };

            bookingService.Setup(check => check.CheckBookingExists(bookingQueryModel)).Returns(false);

            bookingService.Setup(insert => insert.InsertBooking(bookingRepositoryModel)).Returns(bookingRepositoryModel);

            var controller = new BookingController(bookingService.Object);

            var result = controller.CheckAndInsertIfBookingIsAvailable(booking);

            Assert.AreEqual(result.Name, booking.Name);
        }
Exemple #26
0
        public async Task <ActionResult> Create(Models.Booking b)
        {
            Models.Message      m             = new Models.Message();
            string              bookingJson   = JsonConvert.SerializeObject(b);
            HttpContent         stringContent = new StringContent(bookingJson, Encoding.UTF8, "application/json");
            HttpResponseMessage response      = await _httpClient.PostAsync(("api/Bookings"), stringContent);

            try
            {
                response.EnsureSuccessStatusCode();

                m.Content = "Réservation effectué";

                return(View("ShowMessage", m));
            }
            catch
            {
                m.Content = await response.Content.ReadAsStringAsync();

                return(View("ShowMessage", m));
            }
        }
        public ActionResult Vehicle(string location, string startDate, string endDate, string categoryId)
        {
            CarController c = new CarController();

            Models.Booking book = new Models.Booking();
            book.location   = location;
            book.categoryId = categoryId;
            string[] sdate = startDate.Split(' ');
            book.pickUpDate = sdate[1];
            string[] edate = endDate.Split(' ');
            book.returnDate = edate[1];
            DataTable dt = c.getAvailableCars(book);

            foreach (DataRow dr in dt.Rows)
            {
                book.carId      = dr["carId"].ToString();
                Session["book"] = book;
                string path = VirtualPathUtility.ToAbsolute("~/Image/" + dr["ImageName"].ToString());
                ViewBag.carString += @"<div class='col-lg-6 col-md-6'>
                        <div class='single-car-wrap'><div class='car-list-thumb car-thumb-2' style='background-image: url(" + path + ");'></div><div class='car-list-info without-bar'><h2><a href='#'>" + dr["carName"] + "</a></h2><h5>" + dr["rentalCharge"] + "$ Rent /per a day</h5><ul class='car-info-list'><li>" + dr["carType"] + "</li><li>" + dr["carSeats"] + " Seater</li><li>" + dr["carType"].ToString() + "</li></ul><a href='Book?carid=" + dr["carId"].ToString() + "' class='rent-btn'>Book It</a></div></div></div>";
            }
            return(View());
        }
Exemple #28
0
        public async Task SendEmailAsync(Models.Booking Client, string Email)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress("Новый клиент", "*****@*****.**"));//TODO: Change address
            emailMessage.To.Add(new MailboxAddress("", Email));
            emailMessage.Subject = Client.Name;
            emailMessage.Body    = new TextPart(MimeKit.Text.TextFormat.Html)
            {
                Text = Client.Phone
            };

            using (var client = new SmtpClient())
            {
                await client.ConnectAsync("smtp.gmail.com", 587, false);

                await client.AuthenticateAsync("*****@*****.**", "pidorsksisa");//TODO: Add mail

                await client.SendAsync(emailMessage);

                await client.DisconnectAsync(true);
            }
        }
Exemple #29
0
        // POST Booked the room of hotel for particular date

        public string Book(Models.Booking booking)
        {
            Database.Booking model = new Database.Booking();
            model.BookingDate   = booking.BookingDate;
            model.bookingStatus = booking.bookingStatus;
            model.roomID        = booking.roomID;
            if (context.Bookings.Any(x => x.roomID == model.roomID))
            {
                if (context.Bookings.Any(x => x.roomID == model.roomID && x.BookingDate == model.BookingDate && x.bookingStatus == "definitive "))
                {
                    return("Room is alrady booked");
                }
                else
                {
                    var result = context.Bookings.Add(model);
                    context.SaveChanges();
                    return("Your room booked successfully");
                }
            }
            else
            {
                return("none");
            }
        }
        public ActionResult book()
        {
            Models.Booking book = (Models.Booking)Session["book"];
            CarController  c    = new CarController();

            Models.Car car = new Models.Car();
            car.carId = book.carId;
            DataTable dt   = c.GetCarDetails(car);
            int       rent = 0;

            foreach (DataRow dr in dt.Rows)
            {
                rent = Convert.ToInt32(dr["rentalCharge"]);
            }

            double days  = (Convert.ToDateTime(book.returnDate) - Convert.ToDateTime(book.pickUpDate)).TotalDays;
            double total = rent * days;

            foreach (DataRow dr in dt.Rows)
            {
                ViewBag.htmlString = "<tr><td>Car Requested</td><td>" + dr["carName"] + "</td></tr><tr><td>Pick-Up Location</td><td>" + book.location + "</td></tr><tr><td>Pick-Up Date</td><td>" + book.pickUpDate + "</td></tr><tr><td>Return Date</td><td>" + book.returnDate + "</td></tr><tr><td>Base Rate</td><td>CAD " + dr["rentalCharge"] + "</td></tr></tr><tr><td>Num Of Days</td><td>" + days + "</td></tr><tr><td>Total</td><td>CAD" + total + "</td></tr>";
            }
            return(View());
        }