Class representing all information needed to render one lesson (field) on timetable
Пример #1
0
        public ExportLecture(TimetableField ttf)
        {
            name = ttf.lecture_acr;
            //day order ranges from 0 to 4, DayOfWeek from 1 to 5
            day = (DayOfWeek)Enum.ToObject(typeof(DayOfWeek), Int32.Parse(ttf.day_order) + 1);
            startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                Int32.Parse(ttf.time_hours), Int32.Parse(ttf.time_minutes), 0);

            Double time_duration = Double.Parse(ttf.duration);
            int hours = (int)time_duration;
            int minutes = (int)((time_duration - hours) * 60);
            length = new TimeSpan(hours, minutes, 0);

            //length = new TimeSpan(Int32.Parse(ttf.duration),0,0);
            lecturer = ttf.lecturer;
            room = ttf.classroom;
            departementColor = "#" + int.Parse(ttf.color).ToString("X6");
            regularLecture = ttf.period=="Ano" ? true : false;
        }
Пример #2
0
 /// <summary>
 /// Returns 1.1.2001 date with hours and minutes of the TimetableField
 /// </summary>
 /// <param name="field">Field to be processed</param>
 /// <returns></returns>
 private static DateTime getStartTime(TimetableField field)
 {
     return new DateTime(2001, 1, 1, int.Parse(field.time_hours), int.Parse(field.time_minutes), 0);
 }
Пример #3
0
        public ActionResult EditTimetableField(string uid, string lecture, string lecturer, string room, string department, string day, string hours, string minutes, string duration, string period)
        {
            int uniqueID;
            if (int.TryParse(uid, out uniqueID))
            {
                minutes = Convert.ToInt32(minutes).ToString("00");

                M.CustomTimetableFields.RemoveAll(field => field.UniqueID == uniqueID);

                var newField = new TimetableField { lecturer = lecturer, lecture_acr = lecture, classroom = room, department_acr = department, day = day, time = hours + minutes, duration = duration };
                newField.period = (period.ToLower() == "true" ? "Ano" : "Ne");

                var possibleDepartments = M.Departments.Where(dep => dep.acronym == department).ToArray();
                if (possibleDepartments.Any())
                    newField.color = possibleDepartments[0].color;
                /*
                var possibleTimes = M.Times.Where(t => t.hours == hours).ToArray();
                if (possibleTimes.Any())
                {
                    newField.time_hours = possibleTimes[0].hours;
                    newField.time_minutes = possibleTimes[0].minutes;
                }
                */
                newField.time_hours = hours;
                newField.time_minutes = minutes;

                var possibleDays = M.Days.Where(d => d.name == day).ToArray();
                if (possibleDays.Any())
                    newField.day_order = possibleDays[0].daysOrder;

                newField.RecalculateUniqueID();
                M.CustomTimetableFields.Add(newField);
            }
            SaveToSession();
            return PartialView("Rozvrh", M);
        }
Пример #4
0
 /// <summary>
 /// Returns fields duration
 /// </summary>
 /// <param name="field">Field to be processed</param>
 /// <returns></returns>
 private static TimeSpan getDuration(TimetableField field)
 {
     string input = field.duration;
     Double time_duration = 2;
     Double.TryParse(input, NumberStyles.Number, CultureInfo.GetCultureInfo("cs-CZ"), out time_duration);
     int hours = (int) time_duration;
     int minutes = (int) (time_duration-hours)*60;
     return new TimeSpan(hours, minutes, 0);
 }