Exemplo n.º 1
0
        public void GetAllBookingsByUserIdTest()
        {
            var bookingrepo = new BookingRepo(bookcontextmock.Object);
            var bookinglist = bookingrepo.GetById(1);

            Assert.AreEqual(2, bookinglist.Count());
        }
        public static string GetBookingNumberAndManageBooking(CheckOutData data)
        {
            try
            {
                CurrencyManager currencyManager = new CurrencyManager();
                var             BaseCur         = ConfigurationSettings.AppSettings["BaseCur"];

                double ExcahngeRate = currencyManager.GetCurrencyConversion(BaseCur, data.Currency, data.Sid);
                data.SellPrice = Math.Round(data.SellPrice * ExcahngeRate, 3);
                string BookingNum = null;
                BookingNum = BookingRepo.checkbookingnumberavailability(data.Sid);
                if (BookingNum == null)
                {
                    BookingNum = "";


                    BookingNum = BookingRepo.GetBookingNumber(data.Sid, data.Src, data.Pid);

                    if (BookingNum != null)
                    {
                        var tasks        = new List <Task>();
                        var tokenSource1 = new CancellationTokenSource();
                        var tokenSource2 = new CancellationTokenSource();
                        var token1       = tokenSource1.Token;
                        var token2       = tokenSource2.Token;

                        tasks.Add(Task.Factory.StartNew(() =>
                        {
                            data = fillAllTrivellers(data);
                            BookingRepo.SaveBookingResult(data, BookingNum);
                        }
                                                        , token1));
                        //tasks.Add(Task.Factory.StartNew(() =>
                        //{
                        //    SearchstatisticDA searchstatistic = new SearchstatisticDA();
                        //searchstatistic.AddMetaSearchStatistic(data, BookingNum);
                        //}
                        //            , token2));
                        //call save Delivary*****************
                        Task.WaitAll(tasks.ToArray());
                    }

                    return(BookingNum);
                }

                else
                {
                    BookingRepo.EditBookingPaxes(data, BookingNum);

                    return(BookingNum);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.WriteToFile("SaveBookingController/Errors/", "SaveBookingController" + "BLL" + data.Sid, ex.InnerException?.Message, ex.Message + ex.StackTrace);

                return(null);
            }
        }
 public ActionResult DeleteConfirmed(int bookingId)
 {
     if (BookingRepo.DeleteBooking(bookingId))
     {
         return(RedirectToAction("Index"));
     }
     return(View(BookingRepo.GetBooking(bookingId)));
 }
        public void AddBookingDetails()
        {
            var bookingrepo = new BookingRepo(billcontextmock.Object);
            var bookingobj  = bookingrepo.PostBooking(new Booking {
                Bookingid = 1, CustomerId = "ak", ServiceProviderId = "123"
            });

            Assert.IsNotNull(bookingobj);
        }
Exemplo n.º 5
0
        public void AddBookingDetailTest()
        {
            var bookingrepo = new BookingRepo(bookcontextmock.Object);
            var bookingobj  = bookingrepo.Book(new Booking {
                BookingId = 3, pg_Id = 1, UserId = 1, BookingDate = DateTime.Parse("15-10-2020 00:00:00"), No_ofMonth = 1, TotalCost = 6000.00
            });

            Assert.IsNotNull(bookingobj);
        }
        public ActionResult Details(int bookingId)
        {
            var bookingVM = new BookingVM()
            {
                Booking = BookingRepo.GetBooking(bookingId)
            };

            bookingVM.CalculateDiscounts(AnimalRepo.GetAnimalTypes(), new Random().Next(0, 6));
            bookingVM.TotalPrice = CalculatePrice(bookingVM);

            return(View(bookingVM));
        }
        public void CreateBookingForPerson(string person)
        {
            try
            {
                BookingRepo.CreateBooking(person);
            }
            catch (Exception e) when(!e.IsLogged())
            {
                string errorMsg = $"An error occurred while creating a booking for person {person}.";

                e.Log(errorMsg);
                throw;
            }
        }
        public ActionResult BookNow(PackagePicture packagePicture)
        {
            var ad = Context.UserInfos.FirstOrDefault(u => u.UID == HttpUtil.Current.ID);

            var result = BookingRepo.MinusBalance(HttpUtil.Current.ID, packagePicture.Price);

            if (result.HasError)
            {
                ViewBag.Error = result.Message;
                return(Content(ViewBag.Error));
            }

            return(Content("Successfully Booking Done"));
        }
Exemplo n.º 9
0
        public void testgetbooking()
        {
            var context = CreateContext.getNewContext("TestingDB");
            var repo    = new BookingRepo(context);
            var VC      = new BookingController(repo);
            IEnumerable <Bookings> Result = VC.GetBookings();

            string[] names = { "Cancelled", "Upcoming" };
            int      count = 0;

            foreach (Bookings b in Result)
            {
                Assert.Equal(b.ClientName, names[count]);
                count++;
            }
        }
Exemplo n.º 10
0
        private void frmSeatVIew_Load(object sender, EventArgs e)
        {
            foreach (Control c in this.Controls)
            {
                if (c.GetType() == typeof(Button))
                {
                    if (c.Name != "btnConfirm")
                    {
                        c.Click += buttonClick;
                    }
                }
            }

            this.FillEntity();
            string bookedSeatNames = BookingRepo.GetBookedSeats(Booking.ScheduleId, Booking.JourneyDate);

            string[] bookedSeatNamesArray = bookedSeatNames.Split(',');
            //  MessageBox.Show(bookedSeatNamesArray[0]);

            foreach (Control c in this.Controls)
            {
                if (c.GetType() == typeof(Button))
                {
                    if (c.Name != "btnConfirm")
                    {
                        foreach (string s in bookedSeatNamesArray)
                        {
                            //  MessageBox.Show(c.Name);
                            //  MessageBox.Show(s);
                            //  break;
                            if (c.Text == s)
                            {
                                c.Enabled   = false;
                                c.BackColor = Color.FromArgb(237, 193, 123);
                                c.ForeColor = Color.White;
                            }
                        }
                    }
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (!this.FillEntity())
            {
                return;
            }

            Ticket ticket = new Ticket();

            ticket.CustomerName  = this.txtName.Text;
            ticket.CustomerPhone = this.txtPhnNumber.Text;
            ticket.JourneyDate   = MainControl.cashierJourneyDate;
            ticket.SeatNo        = MainControl.booking.Seats;
            ticket.ScheduleId    = MainControl.booking.ScheduleId;
            ticket.Fare          = TicketRepo.GetFare(ticket.ScheduleId);
            ticket.TotalFare     = (int.Parse(ticket.Fare) * MainControl.selectedSeatCount).ToString();
            this.booking         = MainControl.booking;
            try
            {
                BookingRepo.Save(this.booking);
            }
            catch (Exception save)
            {
                MessageBox.Show("Can not save into Booking Table" + save.Message);
            }

            try
            {
                TicketRepo.Insert(ticket);
                this.SaveSalesAmount(ticket.ScheduleId);
                frmPrintedTicket printT = new frmPrintedTicket();
                printT.Phone = this.txtPhnNumber.Text;
                printT.Show();
                this.ClearUserInput();
            }
            catch (Exception save)
            {
                MessageBox.Show("Can not save into Ticket Table" + save.Message);
            }
        }
Exemplo n.º 12
0
        private void FillEntity()
        {
            this.Booking = new Booking()
            {
                JourneyDate        = MainControl.cashierJourneyDate,
                Seats              = selectedSeats,
                AvailableSeatCount = availableSeatCount,
                ScheduleId         = MainControl.scheduleId
            };

            try
            {
                // string[] id = TicketRepo.getRouteAndBusId(MainControl.cashierFrom, MainControl.cashierTo, MainControl.cashierBusType);
                // string routeId = id[0]; //route id is on the index 0
                //scheduleId = ScheduleRepo.GetScheduleId(routeId);
                this.availableSeatCount         = BookingRepo.GetAvailableSeatCount(MainControl.cashierJourneyDate, this.Booking.ScheduleId) - this.selectedSeatCount;
                this.Booking.AvailableSeatCount = availableSeatCount;
            }
            catch (Exception id)
            {
                MessageBox.Show("Error fetching Schedule ID" + id.Message);
            }
        }
Exemplo n.º 13
0
        public void TestInitialize()
        {
            dbcT      = new DBConnectorTest();
            bcT       = new BookingController();
            puacT     = new PickUpAgreementController();
            brT       = new BookingRepo();
            pudrT     = new PickUpAgreementRepo();
            prT       = new PackageRepo();
            p1        = new Package("Premium Pakke", "Polering og bilrude", 250.43);
            p2        = new Package("Luksus Pakke", "Polering og bilrude", 25000);
            p3        = new Package("Basis Pakke", "Polering og bilrude", 4444);
            packages1 = new List <Package>();
            packages2 = new List <Package>();
            packages1.Add(p1);
            packages1.Add(p2);
            packages1.Add(p3);
            packages2.Add(p1);
            packages2.Add(p2);
            stringPackagesT = new List <string>();
            d1 = new Driver("Mathias");
            d2 = new Driver("Muslim");
            d3 = new Driver("Adam");
            v1 = new Vehicle("12ty432", "BMW", 1);
            c1 = new Customer("Frank", "*****@*****.**", "004523438452", 1, "");
            c2 = new Customer("Daniel", "*****@*****.**", "004522639513", v1, 2, "");
            c3 = new Customer("muslim", "*****@*****.**", "004523674598", 3, "");

            put1              = new PickUpTruck("Autotransporter 1");
            b1                = new Booking(c1, "12.30", new DateTime(2019, 9, 24, 10, 00, 00), packages1, 1);
            b2                = new Booking(c1, "12.30", new DateTime(2019, 9, 24, 10, 00, 00), packages1, 2);
            b3                = new Booking(c2, "12.30", new DateTime(2019, 9, 24, 10, 00, 00), packages2, 3);
            b4                = new Booking(c3, "12.30", new DateTime(2019, 9, 24, 10, 00, 00), packages2, 4);
            bookingsT         = new List <Booking>();
            bookingStringsT   = new List <List <string> >();
            pickUpAgreementsT = new List <PickUpAgreement>();
            puaT              = new PickUpAgreement(1, d1, put1, "Odense C", 5000, v1, 500, "Rødegårdsvej 273", new DateTime(2019, 9, 24, 10, 00, 00), "15.30");
        }
Exemplo n.º 14
0
        public async Task <IHttpActionResult> GetBooking(int id)
        {
            var bookingTable = new BookingRepo().GetBookingTable(id);

            return(Ok(bookingTable));
        }
Exemplo n.º 15
0
        public async Task <IHttpActionResult> GetAllBookingTables()
        {
            var listOfAllBookings = new BookingRepo().GetAllBookingTables();

            return(Ok(listOfAllBookings));
        }
Exemplo n.º 16
0
        public async Task <IHttpActionResult> CheckIfTimeIsBooked(CheckIfTimeIsBokedModel checkIfTimeIsBokedModel)
        {
            var timeBooked = new BookingRepo().CheckIfTimeIsBooked(checkIfTimeIsBokedModel);

            return(Ok(timeBooked));
        }
 public ActionResult Index()
 {
     return(View(BookingRepo.GetBookings()));
 }
 public void CreateBookingForPerson(string person)
 {
     BookingRepo.CreateBooking(person);
 }
 public ActionResult Delete(int bookingId)
 {
     return(View(BookingRepo.GetBooking(bookingId)));
 }
Exemplo n.º 20
0
 public BookingController()
 {
     this.repo = new BookingRepo();
     this.attendanceOptions = this.getAttendanceOptions();
 }