public void Configuration(IAppBuilder app) { ConfigureAuth(app); Initer.Init(@"Server=ADWA;Database=Hotel;Trusted_Connection=true"); var clientData = new ClientData("test", "test", "test", "test"); var client = new Client { ClientData = clientData }; var repo = new ClientRepository(); repo.Save(client); var features = new List<Feature>(); features.Add(Feature.Bathroom); var room = new Room { Quality = RoomQuality.Average, Features = features, Type = RoomType.HotelRoom }; room.SetCapacity(5); var roomRepo = new RoomRepository(); roomRepo.Save(room); var features2 = new List<Feature>(); features2.Add(Feature.Bathroom); features2.Add(Feature.Tv); var room2 = new Room { Quality = RoomQuality.Good, Features = features2, Type = RoomType.HotelRoom }; room2.SetCapacity(2); roomRepo.Save(room2); var duration = new DayDuration(DateTime.Now, DateTime.Now.AddDays(1)); var reservation = new Reservation(client, room, duration); var reservationRepo = new ReservationRepository(); reservationRepo.Save(reservation); }
public static void DeleteRoom(int roomID) { MessageController.DeleteRoomMessages(roomID); var roomRep = new RoomRepository(); roomRep.Delete(roomRep.GetById(roomID)); roomRep.SaveChanges(); }
// Sort through Rooms to find next one public static int NextRoomID() { // Find vacant Rooms. If none, create one and add it to list List<int> roomIDs = new List<int>(); vacantRoomInit: var allRooms = new RoomRepository().All().ToList(); var vacantRoomsWithUsers = (from room in allRooms where Enumerable.Range(1, 4).Contains(UserProfileController.GetUserProfileCount(room.RoomID)) select new { RoomID = room.RoomID }).ToList(); var emptyRooms = (from room in allRooms where UserProfileController.GetUserProfileCount(room.RoomID) == 0 select new { RoomID = room.RoomID }).ToList(); if (vacantRoomsWithUsers.Count == 0 && emptyRooms.Count > 0) { // All rooms with users are full but an empty one exists, return empty room return emptyRooms.First().RoomID; } else if (vacantRoomsWithUsers.Count == 0 && emptyRooms.Count == 0) { // Create new Room, re-populate vacantRoomIDs or obtain new RoomID another way var roomRep = new RoomRepository(); Room newRoom = new Room { Name = "Public Room" }; roomRep.Create(newRoom); roomRep.SaveChanges(); goto vacantRoomInit; } profileInit: // Change this to reflect online users only at deployment var allProfiles = new UserProfileRepository().All().ToList(); var profiles = (from p in allProfiles.Where(p => Membership.GetUser(p.aspUserID).IsOnline) where vacantRoomsWithUsers.Select(r => r.RoomID).Contains(p.RoomID) && !VisitedRooms.Select(r => r.RoomID).Contains(p.RoomID) select p).ToList(); if (profiles.Count == 0) { VisitedRooms.Clear(); goto profileInit; } // Obtain room with earliest JoinRoomTime var resultRoom = (from p in profiles group p by p.RoomID into results orderby results.Max(x => x.JoinRoomTime) select new { RoomID = results.Key }).First(); VisitedRooms.Add(new RoomRepository().GetById(resultRoom.RoomID)); return resultRoom.RoomID; }
public RoomController(IConfiguration configuration) { roomRepository = new RoomRepository(configuration); equipmentRepository = new EquipmentRepository(configuration); buildingRepository = new BuildingRepository(configuration); accountRepository = new AccountRepository(configuration); complaintRepository = new ComplaintRepository(configuration); departmentRepository = new DepartmentRepository(configuration); maintenanceRepository = new MaintenanceRepository(configuration); surveyRepository = new SurveyRepository(configuration); historyRepository = new HistoryRepository(configuration); }
static void Main(string[] args) { RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING); Console.WriteLine("Getting All Rooms:"); Console.WriteLine(); List <Room> allRooms = roomRepo.GetAll(); foreach (Room room in allRooms) { Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}"); } Console.WriteLine("----------------------------"); //Console.WriteLine("Getting Room with Id 1"); //Room singleRoom = roomRepo.GetById(1); //Console.WriteLine($"{singleRoom.Id} {singleRoom.Name} {singleRoom.MaxOccupancy}"); //adding bathroom //Room bathroom = new Room //{ // Name = "Bathroom", // MaxOccupancy = 1 //}; //roomRepo.Insert(bathroom); //Room shed = new Room //{ // Name = "Shed", // MaxOccupancy = 50 //}; //roomRepo.Insert(shed); Console.WriteLine("-------------------------------"); //Console.WriteLine($"Added the new Room with id {shed.Id} and name of {shed.Name}"); //bathroom.MaxOccupancy = 18; //roomRepo.Update(bathroom); //Console.WriteLine($" bathrooms occupancy is {bathroom.Id}"); //roomRepo.Delete(9); //roomRepo.GetAll(); RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING); List <Roommate> withRoom = roommateRepo.GetAllWithRoom(3); foreach (Roommate rm in withRoom) { Console.WriteLine($"{rm.Firstname} is living in the {rm.Room.Name}"); } }
static void GetAllRooms(RoomRepository roomRepo) { Console.WriteLine("Getting All Rooms:"); Console.WriteLine(); List <Room> allRooms = roomRepo.GetAll(); foreach (Room room in allRooms) { Console.WriteLine($"{room.Id} {room.Name} {room.MaxOccupancy}"); } }
public Room AddEquipmentToRoom(Room room, MedEquipmentType eqType, uint number) { if (number == 0) { return(room); } for (uint i = 0; i < number; i++) { AddMedEquipmentItem(eqType, room); } return(RoomRepository.GetInstance().Read(room.GetId())); }
static List <Room> ListAllRooms(string name) { RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING); List <Room> rooms = roomRepo.GetAll(); foreach (Room r in rooms) { Console.WriteLine($"{r.Id} - {r.Name} Max Occupancy({r.MaxOccupancy})"); } return(rooms); }
//Getting the room by searching the ID public Room getRoom(int id) { using (RoomRepository roomRepository = new RoomRepository("DefaultConnection")) { Room room = roomRepository.findOneRoom(id); room.Section = sectionLogic.findOneSection(room.SectionID); room.Levels = room_LevelsLogic.getRoomLevels(id); return(room); } }
public void GetByID_ThrowException_WhenInvalidIdIsSupplied() { var options = new DbContextOptionsBuilder <FacilityContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new FacilityContext(options); IRoomRepository repository = new RoomRepository(context); Assert.ThrowsException <ArgumentException>(() => repository.GetById(0)); Assert.ThrowsException <ArgumentException>(() => repository.GetById(-1)); }
static int AddRoom(Room aRoom) { RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING); roomRepo.Insert(aRoom); Console.WriteLine("-------------------------------"); Console.WriteLine($"Added the new Room with id {aRoom.Id}"); aRoom = roomRepo.GetById(aRoom.Id); Console.WriteLine($"Bathroom added with occupancy: {aRoom.MaxOccupancy}"); return(aRoom.Id); }
async public Task <IActionResult> New() { var room = RoomRepository.Create(); await RoomHelpers.WithRoomLock(room, () => { User user = SessionManager.GetCurrentUser(); room.State.Users.Add(user); room.State.Creator = user; }); return(RedirectToAction("Index", new { roomId = room.Id })); }
public ActionResult Edit(Room rm) { if (RoomRepository.Update(rm)) { return(RedirectToAction("Index")); } else { ViewBag.HataMesaji = "Lütfen Değişiklik Yapıp Tekrar Deneyiniz."; } return(View(rm)); }
static void Main(string[] args) { RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING); RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING); Console.Clear(); Console.WriteLine(); MainPage(roomRepo, roommateRepo); }
public ActionResult Add(Room room) { if (RoomRepository.Insert(room)) { return(RedirectToAction("Index")); } else { ViewBag.HataMesaji = "Oda Eklenemedi."; } return(View()); }
public JsonResult GetRooms() { RoomRepository roomRepo = new RoomRepository(); List <Room> rooms = roomRepo.GetAll(); List <string> roomnames = new List <string>(); foreach (var item in rooms) { roomnames.Add(item.Name); } return(Json(roomnames, JsonRequestBehavior.AllowGet)); }
public void CanSearchForRooms() { var roomName = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture); var room1 = new Room(0, roomName, new DateTime(2000, 12, 12)); var roomRepository = new RoomRepository(); roomRepository.Add(room1); var searchResults = roomRepository.GetRooms(roomName); Assert.AreEqual(1, searchResults.Count()); }
static void ListAllRooms() { RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING); List <Room> rooms = roomRepo.GetAll(); foreach (Room r in rooms) { Console.WriteLine($"{r.Id} - {r.Name} Max Occupancy({r.MaxOccupancy})"); } Console.Write("Press any key to continue"); Console.ReadKey(); }
public void GetAll_Test() { // Arrange TestKolgraphEntities context = new TestKolgraphEntities(); var repository = new RoomRepository(context); // Act IEnumerable <room> result = repository.GetAll(); // Assert Assert.IsNotNull(result); Assert.AreEqual(context.room.Count(), result.Count()); }
static void DeleteRoom() { RoomRepository roomRepo = new RoomRepository(CONNECTION_STRING); GetRooms(); Console.WriteLine("Enter the numeral of the room you'd like to delete:"); string roomIdStr = Console.ReadLine(); int roomId = Int32.Parse(roomIdStr); roomRepo.Delete(roomId); Console.WriteLine("Deleted the room. Here's the updated list:"); GetRooms(); }
public async Task <IActionResult> RoomInfo(int roomId) { var roomRepository = new RoomRepository(); var room = roomRepository.GetById(roomId); var authorizeResult = await _authorizationService.AuthorizeAsync(User, room, AppConstants.Policies.CanAccessToRoom); if (authorizeResult.Succeeded) { return(View()); } return(new ChallengeResult()); }
public void GetAllFilterByBranch_Test() { // Arrange TestKolgraphEntities context = new TestKolgraphEntities(); var repository = new RoomRepository(context); int branchId = 1; // Act IEnumerable <room> result = repository.GetAllFilterByBranch(branchId); // Assert Assert.AreEqual(context.room.Where(x => x.branchId == branchId).Count(), result.Count()); }
// GET api/values public IEnumerable <RoomInfo> Get() { IList <Domain.Entities.Room> rooms; using (var session = new NHibernateSessionPerRequest <RoomClassMap>()) { RoomRepository roomRepository = new RoomRepository(session.GetCurrentSession()); rooms = roomRepository.GetAll(); } return(rooms.Select(r => r.ConvertToPublicV001())); }
public UnitOfWork(HotelContext context) { Rooms = new RoomRepository(context); RoomTypes = new RoomTypeRepository(context); Customers = new CustomerRepository(context); Contracts = new ContractRepository(context); Employers = new EmployerRepository(context); ServiceRooms = new ServiceRepository(context); Bills = new BillRepository(context); ContractDetails = new ContractDetailRepository(context); _context = context; }
public async Task GetById_Should_Call_Http_Service_Get_With_Correct_URL() { //arrange RoomRepository roomRepository = new RoomRepository(this.httpServiceMock.Object); int roomId = 1; string expectedRoute = RestURl.RoomURl + roomId; //act await roomRepository.GetById(roomId); //assert this.httpServiceMock.Verify(m => m.Get <Room>(expectedRoute), Times.Once); }
public void Add_ThrowException_WhenNullIsSupplied() { //ARRANGE var options = new DbContextOptionsBuilder <FacilityContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new FacilityContext(options); IRoomRepository repository = new RoomRepository(context); //ACT & ASSERT Assert.ThrowsException <ArgumentNullException>(() => repository.Add(null)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var repo = new RoomRepository(); var rooms = repo.GetTrainingRooms(); var adapter = new ArrayAdapter <TrainingRoom>(this, Resource.Layout.RoomListItem, rooms.ToArray()); this.ListAdapter = adapter; }
public void GetRoomsByFloor_ThrowException_WhenUnexistingFloorIdIsSupplied() { //ARRANGE var options = new DbContextOptionsBuilder <FacilityContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new FacilityContext(options); IRoomRepository roomRepository = new RoomRepository(context); //ACT & ASSERT Assert.ThrowsException <KeyNotFoundException>(() => roomRepository.GetRoomsByFloor(999)); }
static void AddNewRoom(RoomRepository roomRepo) { Room bathroom = new Room { Name = "Bathroom", MaxOccupancy = 1 }; roomRepo.Insert(bathroom); Console.WriteLine("-------------------------------"); Console.WriteLine($"Added the new Room with id {bathroom.Id}"); }
static void DeleteRoom(RoomRepository roomRepo) { roomRepo.GetAll().ForEach(r => Console.WriteLine($"[{r.Id}] {r.Name}")); Console.WriteLine(); Console.Write("What is the ID of the room you want to delete? "); int roomId = int.Parse(Console.ReadLine()); roomRepo.Delete(roomId); Console.Write("Room has been successfully removed. Press any key to continue..."); Console.ReadKey(); }
public static void Seed(IServiceProvider serviceProvider) { #region Room RoomRepository roomRepository = serviceProvider.GetRequiredService <RoomRepository>(); if (!roomRepository.GetAllRooms().Any()) { roomRepository.AddRange(DbInitializer.GetRooms()); } #endregion #region RoomPrices RoomPricesRepository roomPricesRepository = serviceProvider.GetRequiredService <RoomPricesRepository>(); if (!roomPricesRepository.GetAllRoomPrices().Any()) { roomPricesRepository.AddRange(DbInitializer.getRoomPrices()); } #endregion #region MealPlan MealPlanRepository mealPlanRepository = serviceProvider.GetRequiredService <MealPlanRepository>(); if (!mealPlanRepository.GetAllMealPlans().Any()) { mealPlanRepository.AddRange(DbInitializer.getMealPlans()); } #endregion #region MealPlanPrices MealPlanPricesRepository mealPlanPricesRepository = serviceProvider.GetRequiredService <MealPlanPricesRepository>(); if (!mealPlanPricesRepository.GetAllMealPlansPrices().Any()) { mealPlanPricesRepository.AddRange(DbInitializer.getMealPlanPrices()); } #endregion }
public LeaveRoomCommandHandler(RoomRepository roomRepository, PlayerRepository playerRepository, IUnitOfWork <GameDbContext> unitOfWork, IHttpContextAccessor context, GameDbContext dbContext, GameHub gameHub) { _roomRepository = roomRepository; _playerRepository = playerRepository; _unitOfWork = unitOfWork; _context = context; _dbContext = dbContext; _gameHub = gameHub; }
public void Update_ThrowException_WhenUnexistingRoomIsSupplied() { var options = new DbContextOptionsBuilder <FacilityContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new FacilityContext(options); IRoomRepository repository = new RoomRepository(context); var room = new RoomTO { Id = 999 }; Assert.ThrowsException <KeyNotFoundException>(() => repository.Update(room)); }
public RoomDTO[] GetAllRooms(int hotelId) { IRoomRepository repository = new RoomRepository(this._connStrBuilder.ConnectionString); var rooms = repository.GetHotelRooms().Where(r => r.hotelId == hotelId); var freeRoomsDTOs = new List<RoomDTO>(); foreach (var room in rooms) { freeRoomsDTOs.Add(new RoomDTO() { id = room.id, hotelId = room.hotelId, roomClassId = room.roomClassId, flor = room.flor, number = room.number, roomStatus = RoomDTO.RoomStatusDict[room.roomStatus], roomDescr = room.roomDescr }); } return freeRoomsDTOs.ToArray(); }
public static int RandomRoomID() { int roomID; var r = new Random(); // Get random room var shuffled = new RoomRepository().All().OrderBy(x => r.Next()); roomID = shuffled.First().RoomID; return roomID; }
public HomeController() { newsRepository = new NewsRepository(); roomRepository = new RoomRepository(); }
public List<OrderDTO> ReserveRooms(List<int> roomIdsList, DateTime dateFrom, int daysCount = 1) { IRoomRepository roomsRepo = new RoomRepository(this._connStrBuilder.ConnectionString); IOrderRepository ordersRepo = new OrderRepository(this._connStrBuilder.ConnectionString); var rooms = new List<Room>(); var orders = new List<OrderDTO>(); if (roomIdsList != null) { rooms = roomsRepo.GetRoomsByIds(roomIdsList); foreach (var room in rooms) { if (room.roomStatus == (int)RoomStatus.Free) { string hash = this.GenHash(); DateTime startDate; if (dateFrom == null || dateFrom < DateTime.Today + TimeSpan.FromDays(1)) { startDate = DateTime.Today + TimeSpan.FromDays(1); } else { startDate = dateFrom; } ordersRepo.AddOrder( new Order() { roomId = room.id, orderToken = hash, reservationStart = startDate, reservationDays = daysCount }); orders.Add(new OrderDTO() { roomId = room.id, orderToken = hash, reservationStart = startDate, reservationDays = daysCount }); } } } return orders; }
public ActionResult Index() { RoomRepository repo = new RoomRepository(); ViewBag.Rooms = repo.SelectLimit(3); return View(); }
public RoomController() { repo = new RoomRepository(); }
public RoomsController() { //newsRepository = new NewsRepository(); roomRepository = new RoomRepository(); }
public void Init() { ctx = EFContext.CreateContext(); repo = new RoomRepository(ctx); }