예제 #1
0
        private SubjectEntity MapOneSubject(SubjectModel subjectModel)
        {
            string subjectJson = TimetableSerializer.SerializeToJson(subjectModel);
            string subjectHash = HashCoder.GetSha256Hash(subjectJson);

            var info = new SubjectInfoEntity
            {
                Title             = subjectModel.Title,
                Teachers          = subjectModel.Teachers,
                LectureStartDate  = subjectModel.LectureStartDate,
                LectureEndDate    = subjectModel.LectureEndDate,
                PracticeStartDate = subjectModel.PracticeStartDate,
                PracticeEndDate   = subjectModel.PracticeEndDate
            };

            string infoJson = TimetableSerializer.SerializeToJson(info);
            string infoHash = HashCoder.GetSha256Hash(infoJson);

            info.Hash = infoHash;

            string daysJson = TimetableSerializer.SerializeToJson(subjectModel.Days);
            string daysHash = HashCoder.GetSha256Hash(daysJson);

            SubjectEntity entity = new SubjectEntity
            {
                Info     = info,
                Days     = MapSchoolDays(subjectModel.Days),
                HashDays = daysHash,
                Hash     = subjectHash
            };

            return(entity);
        }
예제 #2
0
        private SchoolDayEntity MapOneSchoolDay(SchoolDayModel day)
        {
            string dayJson = TimetableSerializer.SerializeToJson(day);
            string dayHash = HashCoder.GetSha256Hash(dayJson);

            var entity = new SchoolDayEntity
            {
                Day             = day.Day,
                IsDayOfEvenWeek = day.IsDayOfEvenWeek,
                Periods         = MapPeriods(day.Periods),
                Hash            = dayHash
            };

            return(entity);
        }
예제 #3
0
        public TimetableEntity MapTimetable(TimetableModel timetableModel)
        {
            string jsonTimetable = TimetableSerializer.SerializeToJson(timetableModel);
            string hashTimetable = HashCoder.GetSha256Hash(jsonTimetable);

            var entity = new TimetableEntity
            {
                Key      = timetableModel.Key,
                Groups   = MapGroups(timetableModel.Groups),
                Subjects = MapSubjects(timetableModel.Subjects),
                Hash     = hashTimetable
            };

            return(entity);
        }
예제 #4
0
        private PeriodEntity MapOnePeriod(PeriodModel period)
        {
            string periodJson = TimetableSerializer.SerializeToJson(period);
            string periodHash = HashCoder.GetSha256Hash(periodJson);

            var entity = new PeriodEntity
            {
                Number        = period.Number,
                Cabinet       = period.Cabinet,
                Subgroup      = period.Subgroup,
                IsLecture     = period.IsLecture,
                Option        = period.Modification.Option,
                OptionDate    = period.Modification.Date,
                OptionCabinet = period.Modification.Cabinet,
                Hash          = periodHash
            };

            return(entity);
        }