コード例 #1
0
ファイル: Startup.cs プロジェクト: Adiqq/DDD-Playground
        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);
        }
コード例 #2
0
        public static void DeleteRoom(int roomID)
        {
            MessageController.DeleteRoomMessages(roomID);

            var roomRep = new RoomRepository();
            roomRep.Delete(roomRep.GetById(roomID));
            roomRep.SaveChanges();
        }
コード例 #3
0
        // 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;
        }
コード例 #4
0
 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);
 }
コード例 #5
0
        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}");
            }
        }
コード例 #6
0
        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}");
            }
        }
コード例 #7
0
 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()));
 }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: RoomLogic.cs プロジェクト: Umut93/BoldQuiz
        //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);
            }
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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);
        }
コード例 #12
0
ファイル: RoomController.cs プロジェクト: sbergot/DiceSharp
        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 }));
        }
コード例 #13
0
 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));
 }
コード例 #14
0
        static void Main(string[] args)
        {
            RoomRepository     roomRepo     = new RoomRepository(CONNECTION_STRING);
            RoommateRepository roommateRepo = new RoommateRepository(CONNECTION_STRING);

            Console.Clear();



            Console.WriteLine();
            MainPage(roomRepo, roommateRepo);
        }
コード例 #15
0
 public ActionResult Add(Room room)
 {
     if (RoomRepository.Insert(room))
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         ViewBag.HataMesaji = "Oda Eklenemedi.";
     }
     return(View());
 }
コード例 #16
0
        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));
        }
コード例 #17
0
        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());
        }
コード例 #18
0
        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();
        }
コード例 #19
0
        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());
        }
コード例 #20
0
        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();
        }
コード例 #21
0
        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());
        }
コード例 #22
0
        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());
        }
コード例 #23
0
        // 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()));
        }
コード例 #24
0
        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;
        }
コード例 #25
0
        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);
        }
コード例 #26
0
        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));
        }
コード例 #27
0
        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;
        }
コード例 #28
0
        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));
        }
コード例 #29
0
        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}");
        }
コード例 #30
0
        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();
        }
コード例 #31
0
        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
        }
コード例 #32
0
 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;
 }
コード例 #33
0
        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));
        }
コード例 #34
0
ファイル: Service.svc.cs プロジェクト: h4wk13/booking
        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();
        }
コード例 #35
0
        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;
        }
コード例 #36
0
 public HomeController()
 {
     newsRepository = new NewsRepository();
     roomRepository = new RoomRepository();
 }
コード例 #37
0
ファイル: Service.svc.cs プロジェクト: h4wk13/booking
        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;
        }
コード例 #38
0
 public ActionResult Index()
 {
     RoomRepository repo = new RoomRepository();
     ViewBag.Rooms = repo.SelectLimit(3);
     return View();
 }
コード例 #39
0
 public RoomController()
 {
     repo = new RoomRepository();
 }
コード例 #40
0
 public RoomsController()
 {
     //newsRepository = new NewsRepository();
     roomRepository = new RoomRepository();
 }
コード例 #41
0
ファイル: RoomTest.cs プロジェクト: charla-n/ManahostManager
 public void Init()
 {
     ctx = EFContext.CreateContext();
     repo = new RoomRepository(ctx);
 }