public async Task DeleteAssignment(DeleteAssignment command) { await _administratorService.ValidateAtLeastAdministrator(command.UserId, command.GroupId); var group = await GetGroupForAssignmentActions(command); IAssignmentActions assignmentActions = command is ITeamAssignment cmd?group.Teams.First(t => t.Name == cmd.TeamName) : group; assignmentActions.DeleteAssignment(command.AssignmentId); await _groupRepository.SaveChangesAsync(); }
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(); }