public Reservation(Teacher teacher, IRoom room, Group group)
     : base(FindSpaceForNewReservation(teacher, room, group))
 {
     Teacher = teacher;
     Room = room;
     Group = group;
 }
 private static bool CheckCollisionsBeforeAdding(DateTime dateOfStart, DateTime dateOfEnd, Teacher teacher, IRoom room, Group group)
 {
     return CheckCollisions(dateOfStart.ToUnixTimestamp(), dateOfEnd.ToUnixTimestamp(), teacher.Ptr, room.Ptr, group.Ptr);
 }
        private static IntPtr FindSpaceForNewReservation(Teacher teacher, IRoom room, Group group)
        {
            var start = DateTime.Now.Subtract(TimeSpan.FromMinutes(DateTime.Now.Minute)).AddHours(1);
            var end = start.AddHours(1);

            while (!CheckCollisionsBeforeAdding(start, end, teacher, room, group))
            {
                start += TimeSpan.FromHours(1);
                end += TimeSpan.FromHours(1);
            }

            return CreateNewReservation(
                "Type the name",
                start.ToUnixTimestamp(),
                end.ToUnixTimestamp(),
                teacher.Ptr,
                room.Ptr, group.Ptr);
        }
        public bool Edit(string name, DateTime dateOfStart, DateTime dateOfEnd, Teacher teacher, IRoom room, Group group)
        {
            if (EditReservation(Ptr, name, dateOfStart.ToUnixTimestamp(), dateOfEnd.ToUnixTimestamp(), teacher.Ptr, room.Ptr, group.Ptr))
            {
                Teacher = App.Teachers.SingleOrDefault(x => x.Ptr == GetReservationTeacher(Ptr));
                Room = App.Rooms.SingleOrDefault(x => x.Ptr == GetReservationRoom(Ptr));
                Group = App.Groups.SingleOrDefault(x => x.Ptr == GetReservationGroup(Ptr));

                OnPropertyChanged("Name");
                OnPropertyChanged("DateOfStart");
                OnPropertyChanged("DateOfEnd");
                InvokePropertyChanged();

                return true;
            }

            return false;
        }