예제 #1
0
        public async Task <IActionResult> Edit(int id, int?createdQuestionId = null)
        {
            var assignment = await AssignmentService.GetAssignmentAsync(ClassroomName, id);

            if (assignment == null)
            {
                return(NotFound());
            }

            if (createdQuestionId != null)
            {
                var createdQuestion = await QuestionService.GetQuestionAsync
                                      (
                    ClassroomName,
                    createdQuestionId.Value
                                      );

                assignment.Questions.Add
                (
                    new AssignmentQuestion()
                {
                    Name       = createdQuestion.Name,
                    Order      = assignment.Questions.Count,
                    Question   = createdQuestion,
                    QuestionId = createdQuestion.Id
                }
                );
            }

            await PopulateDropDownsAsync(assignment);

            return(View("CreateEdit", assignment));
        }
예제 #2
0
        public async Task <IActionResult> Delete(int id)
        {
            var assignment = await AssignmentService.GetAssignmentAsync(ClassroomName, id);

            if (assignment == null)
            {
                return(NotFound());
            }

            return(View(assignment));
        }
        /// <summary>
        /// Executes before the action is executed.
        /// </summary>
        protected override async Task InitializeAsync()
        {
            await base.InitializeAsync();

            Assignment = await AssignmentService.GetAssignmentAsync
                         (
                ClassroomName,
                AssignmentId
                         );

            ViewBag.Assignment = Assignment;
        }
예제 #4
0
        public async Task <IActionResult> GetAssignmentAsync(long assignmentId)
        {
            var result = await _assignmentService.GetAssignmentAsync(assignmentId);

            return(Json(result));
        }