Exemplo n.º 1
0
        public async Task UpdateAssignment(UpdateAssignment 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.UpdateAssignment(command.Name,
                                               command.Description,
                                               course == null ? command.Semester : course.Semester,
                                               command.Deadline,
                                               course,
                                               command.AssignmentId);

            await _groupRepository.SaveChangesAsync();
        }
        public async Task <ActionResult> UpdateAssignment(Guid groupId, Guid assignmentId, [FromBody] UpdateAssignment command)
        {
            command.UserId       = User.GetUserId();
            command.GroupId      = groupId;
            command.AssignmentId = assignmentId;
            await _assignmentService.UpdateAssignment(command);

            return(Ok());
        }