コード例 #1
0
        public async Task <ActionResult> AddAssignment(Guid groupId, [FromBody] AddAssignment command)
        {
            command.UserId  = User.GetUserId();
            command.GroupId = groupId;
            await _assignmentService.AddAssignment(command);

            return(Ok());
        }
コード例 #2
0
        public ActionResult AddAssignment(int id)//route id!
        {
            var model = new AddAssignment();

            model.ClassID   = id;                                                            //make sure you assign a class id to the model so you are adding the assignment to the right class
            model.ClassName = _teacherRepository.GetClassInformationbyClassID(id).ClassName; //if you need class information and it is not available in the model - request it here!
            model.DueDate   = DateTime.Now.Date.AddDays(1);                                  //set the default value for the due date (otherwise the non-nullable property defaults to Jan. 1, 0001)
            return(View(model));
        }
コード例 #3
0
        public ActionResult AddAssignment(AddAssignment assignment)
        {
            if (ModelState.IsValid)//ModelState.IsValid tells you if any model errors have been added to ModelState - ex passing non-number as int
            {
                var dto = assignment.CreateClassFromUIModel();
                dto.UserID = User.Identity.GetUserId();
                _teacherRepository.AddNewAssignmentbyClass(dto);
                return(RedirectToAction("Gradebook", new{ id = assignment.ClassID }));
            }

            return(View(assignment));
        }
コード例 #4
0
        private void AddAssignment()
        {
            AddAssignment assignment = new AddAssignment();

            assignment.ShowDialog();

            Assignments.Add(new Assignment(
                                assignment.CName,
                                assignment.StartDate,
                                assignment.NumberDaysNeeded,
                                assignment.Location,
                                assignment.NumberModelsNeeded,
                                assignment.Comment));

            Assignments.SaveAssignments();
        }
コード例 #5
0
        public async Task AddAssignment(AddAssignment command)
        {
            await _administratorService.ValidateAtLeastModerator(command.UserId, command.GroupId);

            var group = await GetGroupForAssignmentActions(command);

            var course = command.CourseId == null ? null : ValidateCourseExists(command.CourseId.Value, group);
            IAssignmentActions assignmentActions =
                command is ITeamAssignment cmd?group.Teams.First(t => t.Name == cmd.TeamName) : group;

            assignmentActions.AddAsignment(new Assignment(
                                               command.Name,
                                               command.Description,
                                               course == null ? command.Semester : course.Semester,
                                               command.Deadline,
                                               course));

            await _groupRepository.SaveChangesAsync();
        }