コード例 #1
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()));
        }
コード例 #2
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()));
        }