public Reservation(Teacher teacher, IRoom room, Group group)
     : base(FindSpaceForNewReservation(teacher, room, group))
 {
     Teacher = teacher;
     Room = room;
     Group = group;
 }
        public void Edit(string firstName, string lastName, Group group, int passedTerms, double avgOfMarks)
        {
            EditStudent(Ptr, firstName, lastName, group.Ptr, passedTerms, avgOfMarks);
            Group = App.Groups.SingleOrDefault(x => x.Ptr == GetStudentGroup(Ptr));

            OnPropertyChanged("FirstName");
            OnPropertyChanged("LastName");
            OnPropertyChanged("PassedTerms");
            OnPropertyChanged("AvgOfMarks");

            ViewModelLocator.Students.ReloadData();
            ViewModelLocator.Groups.ReloadData();
            InvokePropertyChanged();
        }
 public Student(string firstName, string lastName, Group group, int passedTerms, double avgOfMarks)
     : base(CreateNewStudent(firstName, lastName, group.Ptr, passedTerms, avgOfMarks))
 {
     Group = group;
 }
        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);
        }
 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);
 }
        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;
        }