Exemplo n.º 1
0
        public MainWindow()
        {
            months = new List <string> {
                "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
            };


            user     = new TutoringDB.CurrentUser();
            readUser = new TutoringDB.TutorDatabaseEntities();
            readUser.CurrentUsers.Load();
            var userList = from i in readUser.CurrentUsers select i;

            user = userList.FirstOrDefault();

            InitializeComponent();

            finished = true;

            monthLabel.Content = months.FirstOrDefault(w => w == DateTime.Today.ToString("MMMM"));

            selectedMonth = DateTime.Today.Month;
            currYear      = DateTime.Today.Year;
            calendarMonth = (MonthCounter)DateTime.Today.Month;

            nextButton.Click += (o, e) => refreshCalendar(1);
            prevButton.Click += (o, e) => refreshCalendar(2);

            Notifications       = new ObservableCollection <Notification>();
            NotificationCommand = new RelayCommand <object>(onNotificationClicked);
            //readUser.TutorTuteeNotifications.Load();
            //var nots = from i in readUser.TutorTuteeNotifications
            //           where i.Tutee.Username == user.UserName || i.Tutor.UserName == user.UserName
            //           select i;
            //foreach (var not in nots) Notifications.Add(new Notification(not.Message, not.Type, (int)not.targetId));
            //if (Notifications.Count == 0)
            //{
            //    Notifications.Add(new Notification("Nothing here!", "empty", -1));
            //}
            //else Notifications.Add(new Notification("Clear", "clear", -1));

            //NotificationsList.ItemsSource = Notifications;
            refreshNotifications();

            DataContext = this;
        }
Exemplo n.º 2
0
        public Week()
        {
            Width  = SystemParameters.WorkArea.Width;
            Height = SystemParameters.WorkArea.Height;
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            finished     = true;
            selectedDate = DateTime.Today;

            user     = new TutoringDB.CurrentUser();
            readUser = new TutoringDB.TutorDatabaseEntities();
            readUser.CurrentUsers.Load();
            var userList = from i in readUser.CurrentUsers select i;

            user = userList.FirstOrDefault();

            InitializeComponent();

            Notifications       = new ObservableCollection <Notification>();
            NotificationCommand = new RelayCommand <object>(onNotificationClicked);
            readUser.TutorTuteeNotifications.Where(not => not.Tutee.Username == user.UserName || not.Tutor.UserName == user.UserName).Load();
            var nots = from i in readUser.TutorTuteeNotifications
                       where i.Tutee.Username == user.UserName || i.Tutor.UserName == user.UserName
                       select i;

            foreach (var not in nots)
            {
                Notifications.Add(new Notification(not.Message, not.Type, (int)not.targetId));
            }
            if (Notifications.Count == 0)
            {
                Notifications.Add(new Notification("Nothing here!", "empty", -1));
            }
            else
            {
                Notifications.Add(new Notification("Clear", "clear", -1));
            }
            NotificationsList.ItemsSource = Notifications;

            nextButton.Click += (o, e) => refreshWeek(7);
            prevButton.Click += (o, e) => refreshWeek(-7);
        }
Exemplo n.º 3
0
        public AccountInfo()
        {
            //Get the current user
            user     = new TutoringDB.CurrentUser();
            readUser = new TutoringDB.TutorDatabaseEntities();
            readUser.CurrentUsers.Load();
            user = readUser.CurrentUsers.FirstOrDefault();

            TutoringDB.TutorDatabaseEntities tutorSchedule = new TutoringDB.TutorDatabaseEntities();


            if (user.Type.ToLower().Contains("tutee"))
            {
                tutorSchedule.Tutees
                .Where(userF => (userF.Username == user.UserName))
                .Load();
                var userList = from i in tutorSchedule.Tutees
                               where i.Username == user.UserName
                               select i;
                var tuteeUser = userList.FirstOrDefault();
                info.UserFullName      = tuteeUser.FirstName + " " + tuteeUser.LastName;
                info.UserUsernameValue = tuteeUser.Username;
                info.UserYearValue     = tuteeUser.Year.ToString();
                info.UserApprovedValue = "No";
            }
            else if (user.Type.ToLower().Contains("tutor"))
            {
                tutorSchedule.Tutors
                .Where(userF => (userF.UserName == user.UserName))
                .Load();
                var userList = from i in tutorSchedule.Tutors
                               where i.UserName == user.UserName
                               select i;

                var tutorUser = userList.FirstOrDefault();
                info.UserFullName      = tutorUser.FirstName + " " + tutorUser.LastName;
                info.UserUsernameValue = tutorUser.UserName;
                info.UserYearValue     = tutorUser.Year.ToString();
                info.UserApprovedValue = tutorUser.Authorized.ToString();
            }
            else
            {
                tutorSchedule.Faculties
                .Where(fac => fac.Username == user.UserName)
                .Load();
                var userList = from i in tutorSchedule.Faculties
                               where i.Username == user.UserName
                               select i;

                var facultyUser = userList.FirstOrDefault();
                info.UserFullName      = facultyUser.First_Name + " " + facultyUser.LastName;
                info.UserUsernameValue = facultyUser.Username;
                info.UserYearValue     = "Not applicable";
                info.UserApprovedValue = "Can approve or deny requests to tutor";
            }
            info.WrongOldPassword = "";

            DataContext = info;

            InitializeComponent();
        }