public async Task GetSearchResults_ShouldReturnAllRoomsContainingTheCriteria() { List <Room> rooms = new() { Rooms.Room1FreeAtPresent1ReservationUser3, Rooms.Room1TakenAtPresent1ReservationUser4 }; ApplicationDbContext context = await InMemoryFactory.InitializeContext() .SeedAsync(rooms); var roomService = new RoomServices(context); //Act var result1 = await roomService.GetSearchResults <RoomViewModel>(true, new RoomType[] { RoomType.Penthouse }, 2); var result2 = await roomService.GetSearchResults <RoomViewModel>(false, new RoomType[] { RoomType.Apartment }, 2); //Assert Assert.NotNull(result1); Assert.NotNull(result2); Assert.AreEqual(Rooms.Room1FreeAtPresent1ReservationUser3.Id, result1.FirstOrDefault().Id); Assert.AreEqual(Rooms.Room1FreeAtPresent1ReservationUser3.Number, result1.FirstOrDefault().Number); Assert.AreEqual(Rooms.Room1FreeAtPresent1ReservationUser3.Type, result1.FirstOrDefault().Type); Assert.AreEqual(Rooms.Room1TakenAtPresent1ReservationUser4.Id, result2.FirstOrDefault().Id); Assert.AreEqual(Rooms.Room1TakenAtPresent1ReservationUser4.Number, result2.FirstOrDefault().Number); Assert.AreEqual(Rooms.Room1TakenAtPresent1ReservationUser4.Type, result2.FirstOrDefault().Type); }
private void confirmBtn_Click(object sender, EventArgs e) { RoomServices roomServices = new RoomServices(); label7.Text = "Status"; updateBtn.Show(); confirmBtn.Hide(); Ward ward = new Ward(); ward.Name = comboBox1.Text; int WardId = roomServices.GetWId(ward).Id; Room room = new Room(); room.WId = WardId; room.RoomNumber = Convert.ToInt32(textBox5.Text); room.Type = comboBox2.Text; bool check = roomServices.Add(room); if (check) { MessageBox.Show("Added"); } else { MessageBox.Show("Error !"); } }
public async Task CountFreeRoomsAtPresent_ShouldCountAllFreeRooms() { //Arrange List <Room> rooms = new() { Rooms.Room1TakenAtPresent1ReservationUser4, Rooms.Room2TakenAtPresent, Rooms.Room1FreeAtPresent1ReservationUser3 }; List <ApplicationUser> users = new() { Users.User3NotEmployee }; ApplicationDbContext context = await InMemoryFactory.InitializeContext() .SeedAsync(users) .SeedAsync(rooms); var roomService = new RoomServices(context); //Act var result = await roomService.CountFreeRoomsAtPresent(); //Assert Assert.AreEqual(1, result); }
public ActionResult GetRoom() { try { //var param = Request.Form["query"]; var listRooms = RoomServices.SearchFor(x => x.IsDelete == false); var listRoomVM = new List <RoomViewModel>(); foreach (var item in listRooms) { var room = new RoomViewModel { Id = item.Id, Name = item.Name, Description = item.Description, Status = CheckStatus(item.Id) }; listRoomVM.Add(room); } return(Json(new { items = listRoomVM }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public void Test1() { var roomBusinessMock = new Mock <IRoomBusiness>(); roomBusinessMock.Setup(a => a.Add(It.IsAny <Room>())).Returns(true); var roomExpectancy = new List <Room> { new Room() { roomNumber = "1", isLocked = false, isReserved = false, roomType = RoomTypeEnum.Single }, new Room() { roomNumber = "2", isLocked = false, isReserved = false, roomType = RoomTypeEnum.Lux } }; roomBusinessMock.Setup(a => a.GetList()).Returns(roomExpectancy); var roomService = new RoomServices(roomBusinessMock.Object); var rooms = roomService.Insert(null); Assert.NotNull(rooms); Assert.True(rooms.Any()); for (var index = 0; index < rooms.Count; index++) { Assert.Equal(roomExpectancy[index].roomNumber, rooms[index].roomNumber); Assert.Equal(roomExpectancy[index].isLocked, rooms[index].isLocked); Assert.Equal(roomExpectancy[index].isReserved, rooms[index].isReserved); Assert.Equal(roomExpectancy[index].roomType, rooms[index].roomType); } }
public int CheckStatus(int id) { var booking = BookingServices.SearchFor(x => x.Room == id).ToList(); if (booking.Count > 0) { if (booking.Where(x => x.From <= DateTime.Now && x.To >= DateTime.Now).ToList().Count > 0) { //status provisional return(2); } } else { var room = RoomServices.GetById(id); if (room.IsActive) { // status available return(1); } else { //status invaiable return(3); } } return(0); }
private async Task GetEmptyRoom() { roomServices = new RoomServices(); var results = await roomServices.GetAvailableRoom(); listKamarKosong.ItemsSource = results; }
public void Should_Return_False_When_Room_Booking_Is_In_Conflict() { //I Jump the injection here I'll do it in the Services and api layer var roomRepository = RoomRepository.Instance; var bookingRepository = new BookingRepository(roomRepository); var bookingServices = new BookingServices(bookingRepository); var roomServices = new RoomServices(roomRepository); var booking = new Booking { BookingRange = new BookingRange { Year = 2017, Mounth = Month.August, Day = 9, Hours = new List <int> { 9, 10, 11 } }, RoomNumber = 1, User = new User() }; bookingServices.Add(booking); var result = roomServices.IsNoConflict(booking); Assert.IsFalse(result); }
public ActionResult Create(RoomViewModel model) { var res = new BaseResponse(); if (string.IsNullOrEmpty(model?.Name) || string.IsNullOrEmpty(model.Description)) { res.Msg = Constants.MsgFail; return(Json(res, JsonRequestBehavior.AllowGet)); } try { var room = new Room { Name = model.Name, Description = model.Description, CreatedBy = "Admin", CreatedOn = DateTime.Now, UpdatedBy = "Admin", UpdatedOn = DateTime.Now }; RoomServices.Add(room); return(Json(res, JsonRequestBehavior.AllowGet)); } catch { res.Msg = Constants.MsgFail; return(Json(res, JsonRequestBehavior.AllowGet)); } }
private void button2_Click(object sender, EventArgs e) { label7.Text = "Status"; //comboBox1.Hide(); //comboBox2.Hide(); //textBox2.Show(); //textBox3.Show(); Room temp = new Room(); RoomServices roomServices = new RoomServices(); Room room = new Room(); WardServices wardServices = new WardServices(); Ward ward = new Ward(); Ward Wtemp = new Ward(); temp.RoomNumber = Convert.ToInt32(textBox1.Text); room = roomServices.GetByRoomNumber(temp); if (room.Type != null) { Wtemp.Id = room.WId; ward = wardServices.Get(Wtemp); comboBox1.Text = ward.Name; textBox5.Text = room.Status.ToString(); comboBox2.Text = room.Type; } else { MessageBox.Show("Not found"); } }
public ActionResult Edit(RoomViewModel model) { var res = new BaseResponse(); if (string.IsNullOrEmpty(model?.Name) || string.IsNullOrEmpty(model.Description)) { res.Msg = Constants.MsgFail; return(Json(res, JsonRequestBehavior.AllowGet)); } try { var room = RoomServices.GetById(model.Id); if (room != null) { room.Name = model.Name; room.Description = model.Description; room.UpdatedOn = DateTime.Now; room.UpdatedBy = "Admin"; RoomServices.Update(room); return(Json(res, JsonRequestBehavior.AllowGet)); } res.Msg = "Cannot edit this item!"; return(Json(res, JsonRequestBehavior.AllowGet)); } catch { res.Msg = "Cannot edit this item!"; return(Json(res, JsonRequestBehavior.AllowGet)); } }
public void RefreshAll() { Guests.RefreshAll(); Rooms.RefreshAll(); Bills.RefreshAll(); RoomServices.RefreshAll(); Reciepts.RefreshAll(); Employees.RefreshAll(); }
public void Should_Display_All_Room() { //I Jump the injection here I'll do it in the Services and api layer var roomRepository = RoomRepository.Instance; var bookingServices = new RoomServices(roomRepository); List <Room> result = bookingServices.GetAll(); Assert.IsNotNull(result); }
public void Should_Only_Available_Hours_When_Room_Booking_Has_Two_Booking() { //I Jump the injection here I'll do it in the Services and api layer var roomRepository = RoomRepository.Instance; var bookingRepository = new BookingRepository(roomRepository); var bookingServices = new BookingServices(bookingRepository); var roomServices = new RoomServices(roomRepository); var booking1 = new Booking { Id = 1, BookingRange = new BookingRange { Year = 2017, Mounth = Month.August, Day = 9, Hours = new List <int> { 9, 10, 11 } }, RoomNumber = 1, User = new User() }; var booking2 = new Booking { Id = 1, BookingRange = new BookingRange { Year = 2017, Mounth = Month.August, Day = 9, Hours = new List <int> { 15, 16 } }, RoomNumber = 1, User = new User() }; var room1 = new Room { Name = "Room1", Bookings = new List <Booking> { booking1, booking2 }, Number = 1 }; roomRepository.Add(room1); var result = roomServices.GetAvailableHours(room1); Assert.AreEqual(19, result.Count()); }
protected View() { ClientRepository = new Repository <ClientEntity>(); RoomRepository = new Repository <RoomEntity>(); BookingRepository = new Repository <BookingEntity>(); ClientBusiness = new ClientBusiness(ClientRepository); RoomBusiness = new RoomBusiness(RoomRepository); HotelBusiness = new HotelBusiness(RoomRepository); BookingBusiness = new BookingBusiness(RoomRepository, BookingRepository); BookingServices = new BookingServices(BookingBusiness, ClientBusiness, RoomBusiness); RoomServices = new RoomServices(RoomBusiness); ClientServices = new ClientServices(ClientBusiness); HotelServices = new HotelServices(HotelBusiness); }
/// <summary> /// Interagi com o usuário para obter quartos por status /// </summary> private void ConsultByStatus() { CleanScreen(); var roomStatus = SelectRoomStatus(); var rooms = RoomServices.GetByStatus(roomStatus); foreach (var room in rooms) { ShowRoom(room); } PressToContinue(); }
public IHttpController Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) { if (controllerType == typeof(RoomController)) { var roomService = new RoomServices(RoomRepository.Instance); return(new RoomController(roomService)); } else if (controllerType == typeof(BookingController)) { var roomService = new RoomServices(RoomRepository.Instance); var bookingService = new BookingServices(new BookingRepository(RoomRepository.Instance)); return(new BookingController(bookingService, roomService)); } return(this.defaultHttpControllerActivator.Create(request, controllerDescriptor, controllerType)); }
/// <summary> /// Interagi com o usuário para inserir um novo quarto. /// </summary> private void Insert() { var room = new RoomEntity(); CleanScreen(); Message("Add a new room"); Message("-------------"); room.Type = SelectRoomType(); room.Status = SelectRoomStatus(); var roomEntity = RoomServices.Insert(room); PrintErrors(roomEntity.Validations); }
public async Task AddRoom_ShouldAddARoom() { //Arange List <Room> rooms = new() { Rooms.Room1 }; ApplicationDbContext context = await InMemoryFactory.InitializeContext() .SeedAsync(rooms); var roomService = new RoomServices(context); //Act await roomService.AddRoom(Rooms.Room2); //Assert Assert.AreEqual(rooms.Count + 1, context.Rooms.Count()); }
public void Should_Display_One_More_Room_After_Adding_A_New_One() { var roomRepository = RoomRepository.Instance; var bookingServices = new RoomServices(roomRepository); bookingServices.Add(new Room { Bookings = new List <Booking>(), Name = "Room1", Number = 1 }); List <Room> result = bookingServices.GetAll(); Assert.AreEqual("Room1", result.First().Name); }
/// <summary> /// Interagi com o usuário para que o mesmo selecione o tipo do quarto /// </summary> /// <returns>retorna o tipo do quarto selecionado</returns> private RoomTypeEntity SelectRoomType() { CleanScreen(); var roomTypes = RoomServices.GetAllTypes(); CleanScreen(); Message("Select a room type"); Message("-------------"); foreach (var room in roomTypes) { Message($"{room.Id} - {room.RoomType}"); } var option = Convert.ToInt32(GetInput()); return(roomTypes.FirstOrDefault(x => x.Id == option)); }
private void roomListBtn_Click(object sender, EventArgs e) { Ward temp = new Ward(); temp.Id = Convert.ToInt32(textBox1.Text); dataGridView1.Show(); RoomServices roomServices = new RoomServices(); if (roomServices.GetAllWId(temp) == null) { MessageBox.Show("NULL"); } else { dataGridView1.DataSource = roomServices.GetAllWId(temp); } }
public async Task GetRoom_ShouldGetARoomById() { //Arrange List <Room> rooms = new() { Rooms.Room1 }; ApplicationDbContext context = await InMemoryFactory.InitializeContext() .SeedAsync(rooms); var roomService = new RoomServices(context); //Act var resultRoom = await roomService.GetRoom <RoomViewModel>(Rooms.Room1.Id); //Assert Assert.IsNotNull(resultRoom); Assert.AreEqual(Rooms.Room1.Id, resultRoom.Id); Assert.AreEqual(Rooms.Room1.Capacity, resultRoom.Capacity); }
private void updateBtn_Click(object sender, EventArgs e) { Room room = new Room(); room.Type = comboBox2.Text; RoomServices roomServices = new RoomServices(); bool check = roomServices.Update(room); if (check) { MessageBox.Show("Updated"); } else { MessageBox.Show("Error !"); } }
public async Task DeleteRoom_ShouldRemoveARoom() { //Arrange List <Room> rooms = new() { Rooms.Room2 }; ApplicationDbContext context = await InMemoryFactory.InitializeContext() .SeedAsync(rooms); var roomService = new RoomServices(context); //Act await roomService.DeleteRoom(Rooms.Room2.Id); //Assert Assert.AreEqual(0, context.Rooms.Count()); }
public async Task GetAllByCapacity_ShouldGetAllRoomsByCapacity() { //Arange List <Room> rooms = new() { Rooms.Room1, Rooms.Room2 }; ApplicationDbContext context = await InMemoryFactory.InitializeContext() .SeedAsync(rooms); var roomService = new RoomServices(context); //Act var result = await roomService.GetAllByCapacity <RoomViewModel>(4); //Arrange Assert.AreEqual(1, result.Count()); }
public async Task GetMaxPrice_ShouldReturnTheHighestAdultPrice() { //Arange List <Room> rooms = new() { Rooms.Room1, Rooms.Room2 }; ApplicationDbContext context = await InMemoryFactory.InitializeContext() .SeedAsync(rooms); var roomService = new RoomServices(context); //Act var maxPrice = roomService.GetMaxPrice(); //Arrange Assert.AreEqual(rooms[1].AdultPrice, maxPrice.Result); }
public async Task GetMaxCapacity_ShouldReturnTheMaxCapacity() { //Arange List <Room> rooms = new() { Rooms.Room1, Rooms.Room2 }; ApplicationDbContext context = await InMemoryFactory.InitializeContext() .SeedAsync(rooms); var roomService = new RoomServices(context); //Act var maxCapacity = roomService.GetMaxCapacity(); //Arrange Assert.AreEqual(Rooms.Room2.Capacity, maxCapacity.Result); }
static void Main(string[] args) { //Get repository option from user string repositoryOption = Utils.GetRoomsRepositoryOptionFromUser(); ConnectionType connectionType = (repositoryOption == "1" ? ConnectionType.File : ConnectionType.Hardcoded); //Get the print option from user string printOption = Utils.GetPrintOptionFromUser(); PrintRooms printRooms = new PrintRooms(); RoomServices roomServices = new RoomServices(ConnectionType.File); string rooms = roomServices.GetRoomsAsString(ConnectionType.Hardcoded); printRooms.Print(rooms, printOption); //string rooms1 = roomServices.GetRoomAsString(connectionType, 1); //printRooms.Print(rooms1, printOption); Console.ReadKey(); }
public async Task CountAllRooms_ShouldCountAllRoomsInDb() { //Arange List <Room> rooms = new() { Rooms.Room1, Rooms.Room2 }; ApplicationDbContext context = await InMemoryFactory.InitializeContext() .SeedAsync(rooms); var roomService = new RoomServices(context); //Act var count = roomService.CountAllRooms(); //Arrange Assert.AreEqual(rooms.Count(), count); }