public static void OutputCoursesForTheDay(Course toOutput, WorkDays day, TimeBlocks block)
        {
            Console.WriteLine();
            Console.WriteLine("-----------------------------");
            Console.WriteLine(day + " " + block);
            if (toOutput != null)
            {
                Console.WriteLine(toOutput.Name);
                if (toOutput.TypeOfCourse == CourseTypes.WPM)
                {
                    Console.WriteLine("WPM");
                }

                if (toOutput.TypeOfCourse == CourseTypes.Unspecified)
                {
                    Console.WriteLine("-");
                }

                if (toOutput.TypeOfCourse == CourseTypes.Mandatory)
                {
                    Console.WriteLine(toOutput.AssociatedCohort.Name);
                }

                Console.WriteLine(toOutput.CourseLecturer.Name);
                if (toOutput.ChosenLectureRoom != null)
                {
                    Console.WriteLine(toOutput.ChosenLectureRoom.Name);
                }
            }
            Console.WriteLine("______________________________");
            Console.WriteLine();
        }
 public ScheduleEntry(Course toBlock, WorkDays day, TimeBlocks block)
 {
     _allScheduledCoursesCollection = new List <Course>();
     _dayOfEntry       = day;
     _timeBlockOfEntry = block;
     _allScheduledCoursesCollection.Add(toBlock);
 }
Esempio n. 3
0
        public async Task <IActionResult> PutTimeBlocks([FromRoute] int id, [FromBody] TimeBlocks timeBlocks)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != timeBlocks.Id)
            {
                return(BadRequest());
            }

            _context.Entry(timeBlocks).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TimeBlocksExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            TimeBlocks retTimeBlock = _context.TimeBlocks.Where(newT => newT.Id == id).FirstOrDefault();

            return(new JsonResult(retTimeBlock));
        }
 public TaskViewModel(Task task, DayViewModel dayViewModel)
 {
     _task         = task;
     _dayViewModel = dayViewModel;
     // Todo: this will throw an exception if there is no match
     Time = TimeBlocks.First(t => t.Minutes == _task.Time);
 }
Esempio n. 5
0
 public void AddEntryToAllAssociatedSchedules(WorkDays day, TimeBlocks timeBlock)
 {
     this.scheduledDay  = day;
     this.scheduledTime = timeBlock;
     SpecificSchedule.SetEntryForDayAndTimeBlock(new ScheduleEntry(this, day, timeBlock), day, timeBlock);
     CourseLecturer.SpecificSchedule.SetEntryForDayAndTimeBlock(new ScheduleEntry(this, day, timeBlock), day, timeBlock);
     AssociatedCohort.SpecificSchedule.SetEntryForDayAndTimeBlock(new ScheduleEntry(this, day, timeBlock), day, timeBlock);
     ChosenLectureRoom.SpecificSchedule.SetEntryForDayAndTimeBlock(new ScheduleEntry(this, day, timeBlock), day, timeBlock);
 }
 /// <summary>
 /// Using data binding, update the text fields that can change on the clocks
 /// </summary>
 protected void UpdateClocks()
 {
     TimeBlocks.ForEach(e => {
         DateTime Now = TimeZoneInfo.ConvertTime(DateTime.Now, ViewModel.TimezonesAvailable[(string)e.Tag]);
         e.Text       = Now.ToString(ViewModel.TimeFormat);
     });
     DateBlocks.ForEach(e => {
         DateTime Now = TimeZoneInfo.ConvertTime(DateTime.Now, ViewModel.TimezonesAvailable[(string)e.Tag]);
         e.Text       = Now.ToString(ViewModel.DateFormat);
     });
 }
 public static void OutputCoursesForTheDay(Course toOutput, WorkDays day, TimeBlocks block)
 {
     Console.WriteLine();
     Console.WriteLine("-----------------------------");
     Console.WriteLine(day + " " + block);
     Console.WriteLine(toOutput.Name);
     Console.WriteLine(toOutput.AssociatedCohort.Name);
     Console.WriteLine(toOutput.CourseLecturer.Name);
     Console.WriteLine(toOutput.ChosenLectureRoom.Name);
     Console.WriteLine("______________________________");
     Console.WriteLine();
 }
        /// <summary>
        /// Dump and create the top section clocks
        /// </summary>
        protected void CreateClocks()
        {
            ClocksHolder.Children.Clear();
            TimeBlocks.Clear();
            DateBlocks.Clear();

            foreach (string OneClock in ViewModel.Clocks)
            {
                var TmpClock = CreateOneClock(OneClock);
                if (TmpClock != null)
                {
                    ClocksHolder.Children.Add(TmpClock);
                }
            }
        }
Esempio n. 9
0
 public bool CheckIfSchedulesLineUp(WorkDays day, TimeBlocks block)
 {
     if (CourseLecturer.SpecificSchedule.GetEntryForDayAndTimeBlock(day, block) == null)
     {
         if (AssociatedCohort.SpecificSchedule.GetEntryForDayAndTimeBlock(day, block) == null)
         {
             foreach (LectureRoom roomToCheck in CompatibleRooms)
             {
                 if (roomToCheck.SpecificSchedule.GetEntryForDayAndTimeBlock(day, block) == null)
                 {
                     ChosenLectureRoom = roomToCheck;
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Esempio n. 10
0
        public TimeBlock CreateTimeBlock()
        {
            ResetScreenShotTimer();
            if (currentTimeBlock != null)
            {
                PreviousTimeBlock = currentTimeBlock;
            }

            TimeBlock timeblock = new TimeBlock();

            timeblock.Start = DateTime.Today;
            TimeBlocks.Add(timeblock);
            currentTimeBlock = timeblock;
            timeblock.Work   = this;
            timeblock.Subcon = this.Subcon;

            Random r    = new Random();
            int    rInt = r.Next(0, timeBlockLength * 60); //for ints

            timeblock.ScreenShotCapturedSecond = rInt;
            return(timeblock);
        }
Esempio n. 11
0
        // TODO slighty changed this to check for == 0 instead of  == null
        public bool CheckIfSchedulesLineUp(WorkDays day, TimeBlocks block)
        {
            Console.WriteLine();
            Console.WriteLine("Checking Schedules for: ");
            Console.WriteLine(CourseLecturer.Name);
            Console.WriteLine(Name);

            if (CourseLecturer.SpecificSchedule.GetEntryForDayAndTimeBlock(day, block)._allScheduledCoursesCollection.Count == 0)
            {
                if (AssociatedCohort.SpecificSchedule.GetEntryForDayAndTimeBlock(day, block)._allScheduledCoursesCollection.Count == 0)
                {
                    Console.WriteLine("Cohort Schedule Free");
                    foreach (LectureRoom roomToCheck in CompatibleRooms)
                    {
                        if (roomToCheck.SpecificSchedule.GetEntryForDayAndTimeBlock(day, block)._allScheduledCoursesCollection.Count == 0)
                        {
                            ChosenLectureRoom = roomToCheck;
                            return(true);
                        }
                        else
                        {
                            Console.WriteLine("Kein Raum frei");
                            return(false);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Kohorte keine Zeit hat");
                    return(false);
                }
            }
            else
            {
                Console.WriteLine("Dozent keine Zeit hat");
                return(false);
            }
            return(false);
        }
Esempio n. 12
0
        public async Task <IActionResult> PostTimeBlocks([FromBody] JObject newData)
        {
            TimeBlocks timeBlocks = JsonConvert.DeserializeObject <TimeBlocks>(newData["TimeBlocks"].ToString());

            TimeSpan startLimit = new TimeSpan(9, 0, 0);  //10 AM
            TimeSpan endLimit   = new TimeSpan(17, 0, 0); //5 PM
            TimeSpan currStart  = new TimeSpan(timeBlocks.StartTime.Hour, timeBlocks.StartTime.Minute, 0);
            TimeSpan currEnd    = new TimeSpan(timeBlocks.EndTime.Hour, timeBlocks.EndTime.Minute, 0);

            if (currStart < startLimit || currStart > endLimit || currEnd > endLimit || currEnd < startLimit)
            {
                return(BadRequest());
            }
            if (timeBlocks.EndTime <= timeBlocks.StartTime)
            {
                return(BadRequest());
            }
            else if (timeBlocks.EndTime <= timeBlocks.StartTime)
            {
                return(BadRequest());
            }
            else if (_context.Users.Any(tempUser => tempUser.Id == timeBlocks.UserId) == false)
            {
                return(BadRequest());
            }
            else if (_context.Organizations.Any(tempOrg => tempOrg.Id == timeBlocks.OrganizationId) == false)
            {
                return(BadRequest());
            }
            timeBlocks.Active = true;
            _context.TimeBlocks.Add(timeBlocks);
            await _context.SaveChangesAsync();

            var response = new { timeBlocks = timeBlocks };

            return(new JsonResult(response));
        }
        /// <summary>
        /// Creates one clock to be displayed in the top section
        /// </summary>
        /// <param name="timezone"></param>
        /// <returns></returns>
        protected UIElement CreateOneClock(string timezone)
        {
            if (!ViewModel.TimezonesAvailable.ContainsKey(timezone))
            {
                return(null);
            }

            Grid Ret = new Grid()
            {
                Width = 180, Height = 88, Margin = new Thickness(5, 5, 0, 0), Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EEEEEE"))
            };

            Ret.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(24)
            });
            Ret.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            Ret.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(24)
            });

            #region Row 0
            TextBlock TmpText = new TextBlock()
            {
                Text = timezone, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 5, 0, 0)
            };
            Viewbox VB = new Viewbox()
            {
                Margin = new Thickness(2)
            };
            VB.SetValue(Grid.RowProperty, 0);
            VB.Child = TmpText;
            Ret.Children.Add(VB);
            #endregion

            #region Row 1
            TmpText = new TextBlock()
            {
                Text = "", FontFamily = new FontFamily(new Uri("pack://application:,,,/"), "Resources/Fonts/#Orbitron"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Tag = timezone
            };
            VB = new Viewbox();
            VB.SetValue(Grid.RowProperty, 1);
            VB.Child = TmpText;
            Ret.Children.Add(VB);
            TimeBlocks.Add(TmpText);
            #endregion

            #region Row 2
            TmpText = new TextBlock()
            {
                Text = "", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 5), Tag = timezone
            };
            TmpText.SetValue(Grid.RowProperty, 2);
            Ret.Children.Add(TmpText);
            DateBlocks.Add(TmpText);
            #endregion

            return(Ret);
        }
Esempio n. 14
0
 public void SetEntryForDayAndTimeBlock(ScheduleEntry entry, WorkDays day, TimeBlocks block)
 {
     scheduleMatrix[(int)day, (int)block] = entry;
 }
Esempio n. 15
0
 public ScheduleEntry GetEntryForDayAndTimeBlock(WorkDays day, TimeBlocks block)
 {
     return(scheduleMatrix[(int)day, (int)block]);
 }