Exemple #1
0
        public IActionResult GetAll()
        {
            //connect user to his courses
            //also add tokens to user in here
            try
            {
                _feideApi.GetUserInfo(_userManager.GetUserId(User));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            //Variable to store the data we are going to send to the front-end.
            CalendarViewModel tasks = new CalendarViewModel();

            //List to store the courses the user have in.
            List <string> courses = new List <string>();

            //Get course codes from the user
            List <Course> courseObjects = _db.Courses.Where(w => w.UserId == _userManager.GetUserAsync(User).Result.Id).ToList();

            //Loop through the list and add the course cods
            foreach (var obj in courseObjects)
            {
                courses.Add(obj.Code);
            }

            //Add TimeEdit reservation to tasks in the calendar
            //Get all reservation from the te controller
            foreach (var res in _te.GetAll(courses).Result)
            {
                //Take out every task out from the list
                foreach (var te in res.Reservations)
                {
                    //Add the task to the te
                    tasks.AddTask(te);
                }
            }

            //Getting the ones from the database.
            var list = _db.Tasks.Where(w => w.UserId == _userManager.GetUserAsync(User).Result.Id).ToList();

            foreach (var t in list)
            {
                tasks.AddTask(t);
            }

            //Return OK code with the task payload
            return(Ok(tasks.GetTasks()));
        }
Exemple #2
0
        public IActionResult GetTestTimeEditTasks()
        {
            //Variable to store the data we are going to send to the front-end.
            CalendarViewModel tasks = new CalendarViewModel();

            //List to store the course codes in
            List <string> courses = new List <string>();

            //Get course codes from the user
            List <Course> courseObjects = _db.Courses.Where(w => w.UserId == _userManager.GetUserAsync(User).Result.Id).ToList();

            //Loop through and add all the course codes.
            foreach (var obj in courseObjects)
            {
                courses.Add(obj.Code);
            }

            //Add TimeEdit reservation to tasks in the calendar
            //Get all reservation from the te controller
            foreach (var res in _te.GetAllTest(courses).Result)
            {
                //Take out every task out from the list
                foreach (var te in res.Reservations)
                {
                    //Add the task to the te
                    tasks.AddTask(te);
                }
            }

            //Return OK code with the task payload
            return(Ok(tasks.GetTasks()));
        }
Exemple #3
0
        private void AddButtonClicked()
        {
            try
            {
                var parent = VisualTreeExtensions.FindParent <MainCalendarView>(this);
                if (parent == null)
                {
                    throw new NullReferenceException("Couldn't find parent.");
                }

                CalendarViewModel viewModel = parent.ViewModel;
                if (viewModel == null)
                {
                    throw new NullReferenceException("Parent's view model was null");
                }

                App.ShowFlyoutAddTaskOrEvent(
                    elToCenterFrom: _addButton,
                    addTaskAction: delegate { viewModel.AddTask(base.Date); },
                    addEventAction: delegate { viewModel.AddEvent(base.Date); },
                    addHolidayAction: delegate { viewModel.AddHoliday(base.Date); });
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
        private void showPopupMenuAdd()
        {
            try
            {
                App.ShowFlyoutAddTaskOrEvent(
                    elToCenterFrom: buttonAdd,
                    addTaskAction: delegate { _viewModel.AddTask(false); },
                    addEventAction: delegate { _viewModel.AddEvent(false); },
                    addHolidayAction: delegate { _viewModel.AddHoliday(false); });
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }