public static async Task Main(string[] args)
        {
            _hotelController = new HotelController(args);

            var shouldExit = false;

            do
            {
                Console.Write("Enter mode (1 = add hotel | 2 = display hotels | else = exit): ");
                var mode = Console.ReadLine();
                switch (mode?.Trim())
                {
                case "1":
                    var hotelToAdd = await RequestHotel();

                    await _hotelController.AddHotel(hotelToAdd);

                    break;

                case "2":
                    var hotels = await _hotelController.GetAllHotels();

                    foreach (var hotel in hotels)
                    {
                        Console.WriteLine($"\n{await MarkdownFormatter.FormatHotel(_hotelController, hotel)}\n\n");
                    }
                    break;

                default:
                    shouldExit = true;
                    break;
                }
            } while (!shouldExit);
        }
Ejemplo n.º 2
0
        public static async Task <string> FormatHotel(HotelController controller, Hotel hotel)
        {
            StringBuilder builder = new StringBuilder();

            // Basic stuff
            builder.AppendLine($"# {hotel.Name}\n");
            var addr = hotel.Address;

            builder.AppendLine($"## Location\n\n{addr.Street}\n{addr.ZipCode} {addr.City}\n");

            // Specials
            builder.AppendLine("## Specials\n");
            foreach (var speciality in hotel.Specialities)
            {
                builder.AppendLine($"* {speciality.Name}");
            }

            // Room types
            builder.AppendLine("|   Room Type   | Size | Price Valid From | Price Valid To | Price in € |");
            foreach (var room in hotel.Rooms)
            {
                var price = await controller.GetPrice(room);

                builder.AppendLine($"|{room.Title}|{room.Size:D4}m²|{price.FromDate}|{price.UntilDate}|{price.PricePerNight:D9} € |");
            }
            builder.AppendLine("\n");
            return(builder.ToString());
        }
        public async void Task_UpdateHotelById_Return_BadRequest()
        {
            //Arrange
            var controller = new HotelController(context);
            int?Id         = null;
            var hotel      = new Hotel()
            {
                HotelName          = "Ashoka is the name of the Hotel",
                HotelAddress       = "Delhi",
                HotelDistrict      = "Delhi",
                HotelCity          = "Delhi",
                HotelState         = "Delhi",
                HotelCountry       = "India",
                HotelEmailId       = "*****@*****.**",
                HotelRating        = "1",
                HotelContactNumber = 123654789,
                HotelImage         = "jkewhffj",
                HotelDescription   = "Description",
                HotelTypeId        = 7
            };
            //Act
            var data = await controller.Put(Id, hotel);

            //Asert
            Assert.IsType <BadRequestResult>(data);
        }
        public void Task_Edit_Hotel_Return_View()
        {
            //Arrange
            var controller = new HotelController(context);
            int id         = 32;


            var h = new Hotel()
            {
                HotelId            = 32,
                HotelName          = "Taj",
                HotelAddress       = "21-Mohan Nagar",
                HotelDistrict      = "South Delhi",
                HotelCity          = "New Delhi",
                HotelState         = "Delhi",
                HotelCountry       = "India",
                HotelEmailId       = "*****@*****.**",
                HotelRating        = "4",
                HotelContactNumber = 1213242,
                HotelImage         = "https://media-cdn.tripadvisor.com/media/photo-s/14/f4/d4/24/oyo-9674-hotel-oberoi.jpg",
                HotelDescription   = "Desc",
                HotelTypeId        = 2
            };

            //Act

            var EditData = controller.Edit(id, h);

            //Assert
            Assert.IsType <RedirectToActionResult>(EditData);
        }
        public void Can_Filter_Products()
        {
            Mock <IHotelRepository> mock = new Mock <IHotelRepository>();

            mock.Setup(m => m.Hotels).Returns(new Hotel[] {
                new Hotel {
                    HotelID = 1, NameHotel = "P1", City = "City1"
                },
                new Hotel {
                    HotelID = 2, NameHotel = "P2", City = "City2"
                },
                new Hotel {
                    HotelID = 3, NameHotel = "P3", City = "City3"
                },
                new Hotel {
                    HotelID = 4, NameHotel = "P4", City = "City4"
                },
                new Hotel {
                    HotelID = 5, NameHotel = "P5", City = "City5"
                },
            });

            HotelController controller = new HotelController(mock.Object);

            controller.PageSize = 3;

            Hotel[] result = ((HotelListViewModel)controller.List("Cat2", 1).Model).Hotels.ToArray();

            Assert.AreEqual(result.Length, 2);
            Assert.IsTrue(result[0].NameHotel == "P2" && result[0].City == "City2");
            Assert.IsTrue(result[1].NameHotel == "P4" && result[1].City == "Cat2");
        }
        public void Can_Paginate()
        {
            Mock <IHotelRepository> mock = new Mock <IHotelRepository>();

            mock.Setup(m => m.Hotels).Returns(new Hotel[]
            {
                new Hotel {
                    HotelID = 1, NameHotel = "P1"
                },
                new Hotel {
                    HotelID = 2, NameHotel = "P2"
                },
                new Hotel {
                    HotelID = 3, NameHotel = "P3"
                },
                new Hotel {
                    HotelID = 4, NameHotel = "P4"
                },
                new Hotel {
                    HotelID = 5, NameHotel = "P5"
                },
            });

            HotelController controller = new HotelController(mock.Object);

            controller.PageSize = 3;

            HotelListViewModel result = (HotelListViewModel)controller.List(null, 2).Model;

            Hotel[] prodArray = result.Hotels.ToArray();
            Assert.IsTrue(prodArray.Length == 2);
            Assert.AreEqual(prodArray[0].NameHotel, "P4");
            Assert.AreEqual(prodArray[1].NameHotel, "P5");
        }
        public async void Task_Update_UpdateHotelById_return_OkResult()
        {
            //Arrange

            var controller = new HotelController(context);
            var id         = 2;
            var hotel      = new Hotel()
            {
                HotelId            = 2,
                HotelName          = "The Ashoka",
                HotelAddress       = "Delhi",
                HotelDistrict      = "Delhi",
                HotelCity          = "Delhi",
                HotelState         = "Delhi",
                HotelCountry       = "India",
                HotelEmailId       = "*****@*****.**",
                HotelRating        = "1",
                HotelContactNumber = 123654789,
                HotelImage         = "jkewhffj",
                HotelDescription   = "Description",
                HotelTypeId        = 2
            };

            //Act
            var data = await controller.Put(id, hotel);

            //Assert
            Assert.IsType <NoContentResult>(data);
        }
Ejemplo n.º 8
0
        public async Task TestIndexFunction_WhenGetHotelDetailsListReturnsNull_ShouldReturnViewResult(string apiUrl, string authCode)
        {
            //arrange
            HotelController hotelController = new HotelController(config.Object, log.Object, service.Object);

            service.Setup(x => x.GetHotelDetailsList(It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(() =>
            {
                return(null);
            });
            config.Setup(x => x.GetSection("APIUrl").Value).Returns(() =>
            {
                return(apiUrl);
            });
            config.Setup(x => x.GetSection("AuthCode").Value).Returns(() =>
            {
                return(authCode);
            });

            //act
            var result = await hotelController.Index(2, 3) as ViewResult;

            //assert
            Assert.That(result.ViewData["ResultSet"], Is.Null);
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.TypeOf <ViewResult>());
        }
Ejemplo n.º 9
0
 public RegisterServiceView()
 {
     InitializeComponent();
     customerController       = new CustomerController();
     hotelController          = new HotelController();
     transportationController = new TransportationController();
     entertainmentController  = new EntertainmentController();
 }
Ejemplo n.º 10
0
        public async void Task_DeleteHotel_Return_NotFoundResult()
        {
            var controller = new HotelController(context);
            var HotelId    = 77;
            var data       = await controller.Delete(HotelId);

            Assert.IsType <NotFoundResult>(data);
        }
Ejemplo n.º 11
0
        public async void Task_DeleteHotel_Return_OkResult()
        {
            var controller = new HotelController(context);
            var HotelId    = 21;
            var data       = await controller.Delete(HotelId);

            Assert.IsType <OkObjectResult>(data);
        }
Ejemplo n.º 12
0
        public async void Task_DeleteHotel_Return_BadResultResult()
        {
            var controller = new HotelController(context);
            int?HotelId    = null;
            var data       = await controller.Delete(HotelId);

            Assert.IsType <BadRequestResult>(data);
        }
Ejemplo n.º 13
0
        public async void Task_GetHotelById_Return_OkResult()
        {
            var controller = new HotelController(context);
            var HotelId    = 7;
            var data       = await controller.Get(HotelId);

            Assert.IsType <OkObjectResult>(data);
        }
Ejemplo n.º 14
0
        public async void Task_GetHotelById_Return_NotFoundResult()
        {
            var controller = new HotelController(context);
            var HotelId    = 50;
            var data       = await controller.Get(HotelId);

            Assert.IsType <NotFoundResult>(data);
        }
Ejemplo n.º 15
0
        public async void Task_GetHotelById_BadRequestResult()
        {
            var controller = new HotelController(context);
            int?HotelId    = null;
            var data       = await controller.Get(HotelId);

            Assert.IsType <BadRequestResult>(data);
        }
Ejemplo n.º 16
0
        public async void Task_GetAllHotel_Return_OkResult()
        {
            //Arrange
            var controller = new HotelController(context);

            //Act
            var data = await controller.Get();

            Assert.IsType <OkObjectResult>(data);
        }
        private void AvbRooms_Click(object sender, RoutedEventArgs e)
        {
            //søk på ledige rom og så bytt til valgt rom
            List <Room> availableRooms = HotelController.RetrieveAvaliableRooms(hcx, selectedRes.DateStart, selectedRes.DateEnd);

            AvailableRooms.DataContext = availableRooms;

            AvbRoomsTxt.Visibility    = Visibility.Visible;
            AvailableRooms.Visibility = Visibility.Visible;
        }
        public void Task_Get_All_Hotel_Return_OkResult()
        {
            //Arrange
            var controller = new HotelController(context);
            //Act
            var data = controller.Index();

            //Assert
            Assert.IsType <ViewResult>(data);
        }
Ejemplo n.º 19
0
 public Booked_Packages()
 {
     hotelController          = new HotelController();
     transportationController = new TransportationController();
     entertainmentController  = new EntertainmentController();
     customerController       = new CustomerController();
     bookingController        = new BookingController();
     InitializeComponent();
     getServices();
     UpdateCustomerGrid();
 }
Ejemplo n.º 20
0
        public async System.Threading.Tasks.Task TestHotelprocessorGetHotelByMhidAsync()
        {
            var Actualdata = ReadJsondata();

            IHotelRepository _repository = new HotelRepository(_dbcontext);
            IHotelProcessor  _processor  = new HotelProcessor(_repository);
            var controller = new HotelController(_processor);
            var response   = _processor.GetHotelByMhid(1);

            Assert.AreEqual(response.Model.Name.ToLower(), Actualdata.model.name.ToLower());
        }
Ejemplo n.º 21
0
 public BookingView(int customerId)
 {
     customerController       = new CustomerController();
     bookingController        = new BookingController();
     hotelController          = new HotelController();
     transportationController = new TransportationController();
     entertainmentController  = new EntertainmentController();
     _id = customerId;
     InitializeComponent();
     //fillDropDowns();
 }
        public async void Task_DeleteHotel_return_NotFound()
        {
            //Arrange
            var controller = new HotelController(context);
            int Id         = 41;

            //Act
            var data = await controller.Get(Id);

            //Asert
            Assert.IsType <NotFoundResult>(data);
        }
        public async void Task_DeleteHotel_return_BadResult()
        {
            //Arrange
            var controller = new HotelController(context);
            int?Id         = null;

            //Act
            var data = await controller.Get(Id);

            //Asert
            Assert.IsType <BadRequestResult>(data);
        }
Ejemplo n.º 24
0
        public void Create_ShouldCreateOneHotel()
        {
            mockContext = new Mock <IHotelAC>();
            mockSet     = new Mock <DbSet <Hotel> >();
            mockContext.Setup(m => m.Hoteli).Returns(mockSet.Object);

            var controller = new HotelController(mockContext.Object);

            controller.Create(new Hotel());

            mockSet.Verify(m => m.Add(It.IsAny <Hotel>()), Times.Once, "Could not add a hotel");
            mockContext.Verify(m => m.SaveChanges(), Times.Once, "Could not add the hotel to the database");
        }
Ejemplo n.º 25
0
        public void Details_ShouldReturnCorrectHotel()
        {
            mockSet     = new Mock <DbSet <Hotel> >();
            mockContext = new Mock <IHotelAC>();
            mockContext.Setup(x => x.Hoteli.Find(42)).Returns(new Hotel {
                HotelID = 42
            });

            var controller = new HotelController(mockContext.Object);
            var result     = controller.Details(42) as ViewResult;
            var hotel      = (Hotel)result.ViewData.Model;

            Assert.IsNotNull(hotel.HotelID, "There does not exist a hotel");
            Assert.AreEqual(42, hotel.HotelID, "The expected id does not match the hotel id");
        }
Ejemplo n.º 26
0
        public void Index_ShouldReturnSameCountOfHotels()
        {
            var context = new TestHotelContext();

            var controller = new HotelController(context);

            controller.Create(new Hotel());
            controller.Create(new Hotel());
            controller.Create(new Hotel());
            var result     = controller.Index() as ViewResult;
            var hotelsData = (IList <Hotel>)result.ViewData.Model;

            Assert.IsNotNull(hotelsData, "There is no data in the hotels list");
            Assert.AreEqual(3, hotelsData.Count(), "The data does not corespond to the expected data count");
        }
        public async void Task_GetHotelById_Return_MatchResult()
        {
            //Arrange
            var controller = new HotelController(context);
            var Id         = 1;

            //Act
            var data = await controller.Get(Id);

            //Asert
            Assert.IsType <OkObjectResult>(data);
            var okresult = data.Should().BeOfType <OkObjectResult>().Subject;
            var hotel    = okresult.Value.Should().BeAssignableTo <Hotel>().Subject;

            Assert.Equal("Oberoi", hotel.HotelName);
        }
Ejemplo n.º 28
0
        public async void Task_GetAllHotel_Return_NotFound()
        {
            //Arrange
            var controller = new HotelController(context);
            var data       = await controller.Get();

            data = null;
            if (data != null)
            {
                Assert.IsType <OkObjectResult>(data);
            }
            else
            {
                //Assert.Equal(data, null);
            }
        }
Ejemplo n.º 29
0
 public BookingView(int bookingId, bool editMode)
 {
     customerController       = new CustomerController();
     bookingController        = new BookingController();
     hotelController          = new HotelController();
     transportationController = new TransportationController();
     entertainmentController  = new EntertainmentController();
     _id = bookingId;
     InitializeComponent();
     _editMode = editMode;
     if (_editMode)
     {
         btnSubmit.Text = "Edit";
     }
     getBookinInfo();
 }
Ejemplo n.º 30
0
        protected void searchButton_Click(object sender, EventArgs e)
        {
            DateTime dateStart = CalendarFrom.SelectedDate.GetValueOrDefault();
            DateTime dateEnd   = CalendarTo.SelectedDate.GetValueOrDefault();

            if (dateStart == null || dateEnd == null)
            {
                return;
            }

            if (dateEnd.CompareTo(dateStart) < 0)
            {
                DateTime tmp = dateStart;
                dateStart = dateEnd;
                dateEnd   = tmp;
            }
            else if (dateEnd.CompareTo(dateStart) == 0 || dateEnd == DateTime.MinValue || dateStart == DateTime.MinValue)
            {
                return;
            }

            int beds = int.Parse((numberOfBeds.SelectedItem as ComboBoxItem).Tag.ToString()); //Usikker om detta er riktig
            //stian har endra -> må hente ut selecteditem som comboboxitem og så hente ut tag

            int quality = 0;

            //var checkedValue = (panel.Children.OfType<RadioButton>().FirstOrDefault(r => r.IsChecked.HasValue && r.IsChecked.Value));
            if (radioBTNok.IsChecked == true)
            {
                quality = 0;
            }
            else if (radioBTNgood.IsChecked == true)
            {
                quality = 1;
            }
            else if (radioBTNamazing.IsChecked == true)
            {
                quality = 2;
            }


            List <Room> availableRooms = HotelController.RetrieveAvaliableRooms(hcx, beds, quality, dateStart, dateEnd);

            roomList.DataContext = availableRooms;

            // Mer her? Hvordan "selecte" etter man får opp lista med ledige rom?
        }