Beispiel #1
0
        public void addName(FreeTime freeTime)
        {
            DateTime startTimeNEW = DateTime.ParseExact(freeTime.startTime, "HH:mm", null);
            DateTime endTimeNEW   = DateTime.ParseExact(freeTime.endTime, "HH:mm", null);


            foreach (PartialTime partialTime in partialTimes)
            {
                DateTime startTimeDiary = DateTime.ParseExact(partialTime.startTime, "HH:mm", null);
                DateTime endTimeDiary   = DateTime.ParseExact(partialTime.endTime, "HH:mm", null);

                //checks if the new time conatains this duration
                if (startTimeNEW <= startTimeDiary && endTimeNEW >= endTimeDiary)
                {
                    //checks if already contains
                    if (!partialTime.names.Contains(freeTime.name))
                    {
                        //if not increase counter and add name
                        partialTime.peopleNum++;
                        partialTime.addPerson(freeTime.name);
                    }
                }

                //edit JSON
            }
        }
Beispiel #2
0
        public static bool isFreeTimeLegal(FreeTime freeTime, DiaryService diaryService)
        {
            //checks if start and end time appear in the list
            if (!diaryService.isAppearInStart(freeTime.startTime))
            {
                return(false);
            }
            if (!diaryService.isAppearInEnd(freeTime.endTime))
            {
                return(false);
            }

            //checks if end is bigger than start
            DateTime startTime = DateTime.ParseExact(freeTime.startTime, "HH:mm", null);
            DateTime endTime   = DateTime.ParseExact(freeTime.endTime, "HH:mm", null);

            if (startTime > endTime)
            {
                return(false);
            }

            if (String.IsNullOrEmpty(freeTime.name))
            {
                return(false);
            }
            return(true);
        }
Beispiel #3
0
 public void addName(FreeTime freeTime)
 {
     //sensetive acces, need to be synchronized
     lock (lockObj)
     {
         diary.addName(freeTime);
         dataConnection.updateDiary(diary.getPartialTimes());
     }
 }