示例#1
0
        public IActionResult SubmitCourse(KursViewModel kursViewModel)
        {
            List <Room>     Rooms    = _databaseHandler.GetAllRooms();
            List <DateTime> datelist = HttpContext.Session.GetObjectFromJson <List <DateTime> >("datelist");

            for (int x = 0; x < kursViewModel.rooms.Count; x++)
            {
                /*var roomlistobject = kursViewModel.Roomlist[x];
                 * roomlistobject.ChosenRoom=Rooms.Find(r => r.Name.Equals(kursViewModel.rooms[x]));
                 * kursViewModel.Roomlist[x] = roomlistobject;*/
            }
            List <DateandRoom> datenandRooms = new List <DateandRoom>();

            for (int x = 0; x < kursViewModel.rooms.Count; x++)
            {
                datenandRooms.Add(new DateandRoom
                {
                    block   = Array.IndexOf(Data.BlockStartArray, datelist[x].ToString("HH:mm")),
                    room    = Rooms.Find(r => r.Name.Equals(kursViewModel.rooms[x])),
                    weekday = (int)datelist[x].DayOfWeek
                });
            }


            _databaseHandler.AddCourse(datenandRooms, kursViewModel.start, kursViewModel.end, kursViewModel.kursname,
                                       _userManager.GetUserId(User));



            return(RedirectToAction("Index", "Reservation"));
        }
示例#2
0
        public void TestAddCourse()
        {
            _reservationContext.Rooms.Add(_testRooms[0]);
            _reservationContext.Teachers.Add(_testTeachers[0]);
            _reservationContext.SaveChanges();

            string tId    = _reservationContext.Teachers.First().Id;
            int    roomId = _reservationContext.Rooms.First().RoomId;

            /*_databaseHandler.AddCourse(new DateTime(2017, 1, 1), new DateTime(2017, 1, 30), 0,
             *  tId , roomId , "Informatik");*/
            _databaseHandler.AddCourse(new DateTime(2017, 1, 1), new DateTime(2017, 1, 30), 0, tId, roomId, "TestCourse", 1);

            Assert.Equal(5, _reservationContext.Reservations.Count());

            Clear();
        }