コード例 #1
0
        public async Task <IActionResult> EditLmsTaskSetLmsTasks(LmsTaskSetLmsTask lmsTaskSetLmsTask,
                                                                 LmsTasksFilterAndSortModel lmsTasksFilterAndSortModel,
                                                                 string mode)
        {
            ViewBag.LmsTasksFilterAndSortModel = lmsTasksFilterAndSortModel;

            if (lmsTaskSetLmsTask.LmsTaskSetId == 0)
            {
                return(NotFound());
            }

            if (lmsTaskSetLmsTask.LmsTaskId != 0)
            {
                if (mode == "AddTaskToTaskSet")
                {
                    await _lmsTaskSetRepository.AddLmsTaskSetLmsTaskAsync(lmsTaskSetLmsTask);
                }

                if (mode == "RemoveTaskFromTaskSet")
                {
                    await _lmsTaskSetRepository.RemoveLmsTaskSetLmsTaskAsync(lmsTaskSetLmsTask);
                }
            }

            ViewBag.AppUsers        = _selectListRepository.GetSelectListLmsTaskAppUsers(lmsTasksFilterAndSortModel.FilterAppUserId);
            ViewBag.DisciplineNames = _selectListRepository.GetSelectListLmsTaskDisciplineNames(lmsTasksFilterAndSortModel.FilterDisciplineNameId);
            ViewBag.LmsTaskTypes    = _selectListRepository.GetSelectListLmsTaskTypes(lmsTasksFilterAndSortModel.FilterLmsTaskTypeId);

            if (lmsTasksFilterAndSortModel.IsRequestDataImmediately)
            {
                lmsTaskSetLmsTask.LmsTaskSet = await _lmsTaskSetRepository.GetLmsTaskSetAsync(lmsTaskSetLmsTask.LmsTaskSetId);

                ViewBag.LmsTasks = _lmsTaskRepository.GetLmsTasks(lmsTasksFilterAndSortModel);
                return(View(lmsTaskSetLmsTask));
            }
            else
            {
                lmsTaskSetLmsTask.LmsTaskSet = await _lmsTaskSetRepository.GetLmsTaskSetAsync(lmsTaskSetLmsTask.LmsTaskSetId);

                ViewBag.LmsTasks = (await _lmsTaskSetRepository.GetLmsTaskSetAsync(lmsTaskSetLmsTask.LmsTaskSetId)).LmsTaskSetLmsTasks.Select(t => t.LmsTask);
                return(View(lmsTaskSetLmsTask));
            }
        }
コード例 #2
0
        public async Task <IActionResult> Index(LmsTasksFilterAndSortModel lmsTasksFilterAndSortModel)
        {
            ViewBag.LmsTasksFilterAndSortModel = lmsTasksFilterAndSortModel;

            ViewBag.AppUsers        = _selectListRepository.GetSelectListLmsTaskAppUsers(lmsTasksFilterAndSortModel.FilterAppUserId);
            ViewBag.DisciplineNames = _selectListRepository.GetSelectListLmsTaskDisciplineNames(lmsTasksFilterAndSortModel.FilterDisciplineNameId);
            ViewBag.LmsTaskTypes    = _selectListRepository.GetSelectListLmsTaskTypes(lmsTasksFilterAndSortModel.FilterLmsTaskTypeId);

            if (lmsTasksFilterAndSortModel.IsRequestDataImmediately)
            {
                var lmsTasks = _lmsTaskRepository.GetLmsTasks(lmsTasksFilterAndSortModel);
                lmsTasks = lmsTasks.OrderByDescending(t => t.DateTimeOfCreation);

                return(View(await lmsTasks.ToListAsync()));
            }
            else
            {
                return(View());
            }
        }