diff --git a/Source/.editorconfig b/Source/.editorconfig index e4992cb14..54a56d230 100644 --- a/Source/.editorconfig +++ b/Source/.editorconfig @@ -558,4 +558,7 @@ dotnet_style_allow_statement_immediately_after_block_experimental = true:silent csharp_style_prefer_utf8_string_literals = true:suggestion # ReSharper -resharper_csharp_empty_block_style = together_same_line \ No newline at end of file +resharper_csharp_empty_block_style = together_same_line + +csharp_wrap_arguments_style=chop_if_long +csharp_wrap_chained_method_calls=chop_if_long \ No newline at end of file diff --git a/Source/Application/Kysect.Shreks.Application.GithubWorkflow/Factories/GithubSubmissionFactory.cs b/Source/Application/Kysect.Shreks.Application.GithubWorkflow/Factories/GithubSubmissionFactory.cs index 279c3f288..83319b9cd 100644 --- a/Source/Application/Kysect.Shreks.Application.GithubWorkflow/Factories/GithubSubmissionFactory.cs +++ b/Source/Application/Kysect.Shreks.Application.GithubWorkflow/Factories/GithubSubmissionFactory.cs @@ -89,6 +89,7 @@ public async Task CreateAsync(Guid userId, Guid assignmentId, Cancel .CountAsync(cancellationToken); return new GithubSubmission( + Guid.NewGuid(), count + 1, student, groupAssignment, diff --git a/Source/Application/Kysect.Shreks.Application.Google/Services/SubjectCourseTableService.cs b/Source/Application/Kysect.Shreks.Application.Google/Services/SubjectCourseTableService.cs index ecb2b5cb0..fbde1b981 100644 --- a/Source/Application/Kysect.Shreks.Application.Google/Services/SubjectCourseTableService.cs +++ b/Source/Application/Kysect.Shreks.Application.Google/Services/SubjectCourseTableService.cs @@ -49,7 +49,7 @@ public Task GetSubjectCourseTableId(Guid subjectCourseId, CancellationTo string spreadsheetId = await _spreadsheetManagementService .CreateSpreadsheetAsync(subjectCourse.Title, cancellationToken); - spreadsheetAssociation = new GoogleTableSubjectCourseAssociation(subjectCourse, spreadsheetId); + spreadsheetAssociation = new GoogleTableSubjectCourseAssociation(Guid.NewGuid(), subjectCourse, spreadsheetId); _context.SubjectCourseAssociations.Add(spreadsheetAssociation); await _context.SaveChangesAsync(cancellationToken); diff --git a/Source/Application/Kysect.Shreks.Application.Handlers/Github/AddGithubSubjectCourseAssociationHandler.cs b/Source/Application/Kysect.Shreks.Application.Handlers/Github/AddGithubSubjectCourseAssociationHandler.cs index 026e079ac..d691ab9fa 100644 --- a/Source/Application/Kysect.Shreks.Application.Handlers/Github/AddGithubSubjectCourseAssociationHandler.cs +++ b/Source/Application/Kysect.Shreks.Application.Handlers/Github/AddGithubSubjectCourseAssociationHandler.cs @@ -19,10 +19,14 @@ public AddGithubSubjectCourseAssociationHandler(IShreksDatabaseContext context) public async Task Handle(Command request, CancellationToken cancellationToken) { - SubjectCourse subjectCourse = - await _context.SubjectCourses.GetByIdAsync(request.SubjectCourseId, cancellationToken); - var githubSubjectCourseAssociation = - new GithubSubjectCourseAssociation(subjectCourse, request.Organization, request.TemplateRepository); + SubjectCourse subjectCourse = await _context.SubjectCourses + .GetByIdAsync(request.SubjectCourseId, cancellationToken); + + var githubSubjectCourseAssociation = new GithubSubjectCourseAssociation( + Guid.NewGuid(), + subjectCourse, + request.Organization, + request.TemplateRepository); _context.SubjectCourseAssociations.Add(githubSubjectCourseAssociation); await _context.SaveChangesAsync(cancellationToken); diff --git a/Source/Application/Kysect.Shreks.Application.Handlers/Github/AddGithubUserAssociationHandler.cs b/Source/Application/Kysect.Shreks.Application.Handlers/Github/AddGithubUserAssociationHandler.cs index 2c8ee5bbd..ac2d1cdc9 100644 --- a/Source/Application/Kysect.Shreks.Application.Handlers/Github/AddGithubUserAssociationHandler.cs +++ b/Source/Application/Kysect.Shreks.Application.Handlers/Github/AddGithubUserAssociationHandler.cs @@ -32,7 +32,7 @@ public async Task Handle(Command request, CancellationToken cancellationTo Student student = await _context.Students.GetByIdAsync(request.UserId, cancellationToken); - var association = new GithubUserAssociation(student.User, request.GithubUsername); + var association = new GithubUserAssociation(Guid.NewGuid(), student.User, request.GithubUsername); _context.UserAssociations.Add(association); _context.Users.Update(student.User); diff --git a/Source/Application/Kysect.Shreks.Application.Handlers/Github/SyncGithubAdminWithMentorsHandler.cs b/Source/Application/Kysect.Shreks.Application.Handlers/Github/SyncGithubAdminWithMentorsHandler.cs index 36eec408b..8d7a3ebad 100644 --- a/Source/Application/Kysect.Shreks.Application.Handlers/Github/SyncGithubAdminWithMentorsHandler.cs +++ b/Source/Application/Kysect.Shreks.Application.Handlers/Github/SyncGithubAdminWithMentorsHandler.cs @@ -99,8 +99,8 @@ private async Task CreateMentorFromAdmin( if (!isGithubUserExists) throw new DomainInvalidOperationException($"Github user with username {adminUsername} does not exist"); - var adminUser = new User(adminUsername, adminUsername, adminUsername); - var githubUserAssociation = new GithubUserAssociation(adminUser, adminUsername); + var adminUser = new User(Guid.NewGuid(), adminUsername, adminUsername, adminUsername); + var githubUserAssociation = new GithubUserAssociation(Guid.NewGuid(), adminUser, adminUsername); _shreksDatabaseContext.Users.Add(adminUser); _shreksDatabaseContext.UserAssociations.Add(githubUserAssociation); diff --git a/Source/Application/Kysect.Shreks.Application.Handlers/Students/CreateStudentHandler.cs b/Source/Application/Kysect.Shreks.Application.Handlers/Students/CreateStudentHandler.cs index d0ec10440..c29417ecb 100644 --- a/Source/Application/Kysect.Shreks.Application.Handlers/Students/CreateStudentHandler.cs +++ b/Source/Application/Kysect.Shreks.Application.Handlers/Students/CreateStudentHandler.cs @@ -30,7 +30,7 @@ public async Task Handle(Command request, CancellationToken cancellati if (group is null) throw EntityNotFoundException.For(request.GroupId); - var user = new User(request.FirstName, request.MiddleName, request.LastName); + var user = new User(Guid.NewGuid(), request.FirstName, request.MiddleName, request.LastName); var student = new Student(user, group); _context.Students.Add(student); diff --git a/Source/Application/Kysect.Shreks.Application.Handlers/Study/Assignments/CreateAssignmentHandler.cs b/Source/Application/Kysect.Shreks.Application.Handlers/Study/Assignments/CreateAssignmentHandler.cs index 79eacadf3..fefc211b9 100644 --- a/Source/Application/Kysect.Shreks.Application.Handlers/Study/Assignments/CreateAssignmentHandler.cs +++ b/Source/Application/Kysect.Shreks.Application.Handlers/Study/Assignments/CreateAssignmentHandler.cs @@ -26,6 +26,7 @@ public async Task Handle(Command request, CancellationToken cancellati await _context.SubjectCourses.GetByIdAsync(request.SubjectCourseId, cancellationToken); var assignment = new Assignment( + Guid.NewGuid(), request.Title, request.ShortName, request.Order, diff --git a/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateStudyGroupHandler.cs b/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateStudyGroupHandler.cs index 0b84c9438..7ff8e98fa 100644 --- a/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateStudyGroupHandler.cs +++ b/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateStudyGroupHandler.cs @@ -20,7 +20,7 @@ public CreateStudyGroupHandler(IShreksDatabaseContext context, IMapper mapper) public async Task Handle(Command request, CancellationToken cancellationToken) { - var studentGroup = new StudentGroup(request.Name); + var studentGroup = new StudentGroup(Guid.NewGuid(), request.Name); _context.StudentGroups.Add(studentGroup); await _context.SaveChangesAsync(cancellationToken); return new Response(_mapper.Map(studentGroup)); diff --git a/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateSubjectCourseHandler.cs b/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateSubjectCourseHandler.cs index fde4ac6b4..fbc60d715 100644 --- a/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateSubjectCourseHandler.cs +++ b/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateSubjectCourseHandler.cs @@ -24,7 +24,7 @@ public async Task Handle(Command request, CancellationToken cancellati { Subject subject = await _context.Subjects.GetByIdAsync(request.SubjectId, cancellationToken); var subjectCourse = - new SubjectCourse(subject, request.Title, (SubmissionStateWorkflowType)request.WorkflowType); + new SubjectCourse(Guid.NewGuid(), subject, request.Title, (SubmissionStateWorkflowType)request.WorkflowType); _context.SubjectCourses.Add(subjectCourse); await _context.SaveChangesAsync(cancellationToken); diff --git a/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateSubjectHandler.cs b/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateSubjectHandler.cs index 3e2c499ce..94ee9b027 100644 --- a/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateSubjectHandler.cs +++ b/Source/Application/Kysect.Shreks.Application.Handlers/Study/CreateSubjectHandler.cs @@ -20,7 +20,7 @@ public CreateSubjectHandler(IShreksDatabaseContext context, IMapper mapper) public async Task Handle(Command request, CancellationToken cancellationToken) { - var subject = new Subject(request.Title); + var subject = new Subject(Guid.NewGuid(), request.Title); _context.Subjects.Add(subject); await _context.SaveChangesAsync(cancellationToken); return new Response(_mapper.Map(subject)); diff --git a/Source/Application/Kysect.Shreks.Application.Handlers/Users/UpdateUserGithubUsernameHandler.cs b/Source/Application/Kysect.Shreks.Application.Handlers/Users/UpdateUserGithubUsernameHandler.cs index 10421900a..809859b94 100644 --- a/Source/Application/Kysect.Shreks.Application.Handlers/Users/UpdateUserGithubUsernameHandler.cs +++ b/Source/Application/Kysect.Shreks.Application.Handlers/Users/UpdateUserGithubUsernameHandler.cs @@ -48,7 +48,7 @@ public async Task Handle(Command request, CancellationToken cancellati throw new DomainInvalidOperationException(message); } - var association = new GithubUserAssociation(user, request.GithubUsername); + var association = new GithubUserAssociation(Guid.NewGuid(), user, request.GithubUsername); user.AddAssociation(association); await _context.UserAssociations.AddAsync(association, cancellationToken); diff --git a/Source/Application/Kysect.Shreks.Application.Handlers/Users/UpdateUserUniversityIdHandler.cs b/Source/Application/Kysect.Shreks.Application.Handlers/Users/UpdateUserUniversityIdHandler.cs index d0f0f6fbc..5768d75b2 100644 --- a/Source/Application/Kysect.Shreks.Application.Handlers/Users/UpdateUserUniversityIdHandler.cs +++ b/Source/Application/Kysect.Shreks.Application.Handlers/Users/UpdateUserUniversityIdHandler.cs @@ -28,7 +28,7 @@ public async Task Handle(Command request, CancellationToken cancellationTo if (association is null) { - association = new IsuUserAssociation(user, request.UniversityId); + association = new IsuUserAssociation(Guid.NewGuid(), user, request.UniversityId); _context.UserAssociations.Add(association); } else diff --git a/Source/DeveloperEnvironment/Kysect.Shreks.DeveloperEnvironment/DeveloperEnvironmentSeeder.cs b/Source/DeveloperEnvironment/Kysect.Shreks.DeveloperEnvironment/DeveloperEnvironmentSeeder.cs index b9ccb3bf9..ec4878204 100644 --- a/Source/DeveloperEnvironment/Kysect.Shreks.DeveloperEnvironment/DeveloperEnvironmentSeeder.cs +++ b/Source/DeveloperEnvironment/Kysect.Shreks.DeveloperEnvironment/DeveloperEnvironmentSeeder.cs @@ -44,8 +44,13 @@ private void AddGithubUserAssociations(DeveloperEnvironmentSeedingRequest reques { SubjectCourse subjectCourse = _subjectCourseGenerator.GeneratedEntities[0]; _context.SubjectCourses.Attach(subjectCourse); - var githubSubjectCourseAssociation = - new GithubSubjectCourseAssociation(subjectCourse, request.Organization, request.TemplateRepository); + + var githubSubjectCourseAssociation = new GithubSubjectCourseAssociation( + Guid.NewGuid(), + subjectCourse, + request.Organization, + request.TemplateRepository); + _context.SubjectCourseAssociations.Add(githubSubjectCourseAssociation); } @@ -58,7 +63,7 @@ private void AddUsers(DeveloperEnvironmentSeedingRequest request) { User user = users[index]; string login = request.Users[index]; - _context.UserAssociations.Add(new GithubUserAssociation(user, login)); + _context.UserAssociations.Add(new GithubUserAssociation(Guid.NewGuid(), user, login)); } } } \ No newline at end of file diff --git a/Source/Directory.Build.props b/Source/Directory.Build.props index 011d282e4..3e084d912 100644 --- a/Source/Directory.Build.props +++ b/Source/Directory.Build.props @@ -3,7 +3,7 @@ latest True true - 1591;SA1633;SA1101;SA1503;SA1309;SA1601;SA1201;SA1502;SA1127;SA1128 + 1591;SA1633;SA1101;SA1503;SA1309;SA1601;SA1201;SA1502;SA1127;SA1128;SA1600;SA1611;SA1604;SA1629;SA1602 diff --git a/Source/Domain/Kysect.Shreks.Core/Study/Assignment.cs b/Source/Domain/Kysect.Shreks.Core/Study/Assignment.cs index 355f56a2c..c4fdcd2ad 100644 --- a/Source/Domain/Kysect.Shreks.Core/Study/Assignment.cs +++ b/Source/Domain/Kysect.Shreks.Core/Study/Assignment.cs @@ -9,13 +9,14 @@ public partial class Assignment : IEntity private readonly HashSet _groupAssignments; public Assignment( + Guid id, string title, string shortName, int order, Points minPoints, Points maxPoints, SubjectCourse subjectCourse) - : this(Guid.NewGuid()) + : this(id) { ArgumentNullException.ThrowIfNull(title); diff --git a/Source/Domain/Kysect.Shreks.Core/Study/StudentGroup.cs b/Source/Domain/Kysect.Shreks.Core/Study/StudentGroup.cs index e6ef5600a..61787677b 100644 --- a/Source/Domain/Kysect.Shreks.Core/Study/StudentGroup.cs +++ b/Source/Domain/Kysect.Shreks.Core/Study/StudentGroup.cs @@ -8,8 +8,7 @@ public partial class StudentGroup : IEntity { private readonly HashSet _students; - public StudentGroup(string name) - : this(Guid.NewGuid()) + public StudentGroup(Guid id, string name) : this(id) { ArgumentNullException.ThrowIfNull(name); diff --git a/Source/Domain/Kysect.Shreks.Core/Study/Subject.cs b/Source/Domain/Kysect.Shreks.Core/Study/Subject.cs index 197e6c16d..15d3bce40 100644 --- a/Source/Domain/Kysect.Shreks.Core/Study/Subject.cs +++ b/Source/Domain/Kysect.Shreks.Core/Study/Subject.cs @@ -7,8 +7,7 @@ public partial class Subject : IEntity { private readonly HashSet _courses; - public Subject(string title) - : this(Guid.NewGuid()) + public Subject(Guid id, string title) : this(id) { ArgumentNullException.ThrowIfNull(title); diff --git a/Source/Domain/Kysect.Shreks.Core/Study/SubjectCourse.cs b/Source/Domain/Kysect.Shreks.Core/Study/SubjectCourse.cs index 3174424db..f117973e0 100644 --- a/Source/Domain/Kysect.Shreks.Core/Study/SubjectCourse.cs +++ b/Source/Domain/Kysect.Shreks.Core/Study/SubjectCourse.cs @@ -15,8 +15,8 @@ public partial class SubjectCourse : IEntity private readonly HashSet _groups; private readonly HashSet _mentors; - public SubjectCourse(Subject subject, string title, SubmissionStateWorkflowType? workflowType) - : this(Guid.NewGuid()) + public SubjectCourse(Guid id, Subject subject, string title, SubmissionStateWorkflowType? workflowType) + : this(id) { Subject = subject; Title = title; diff --git a/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/GithubSubjectCourseAssociation.cs b/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/GithubSubjectCourseAssociation.cs index ceeb69cfb..cdc8bc8dc 100644 --- a/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/GithubSubjectCourseAssociation.cs +++ b/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/GithubSubjectCourseAssociation.cs @@ -5,10 +5,11 @@ namespace Kysect.Shreks.Core.SubjectCourseAssociations; public partial class GithubSubjectCourseAssociation : SubjectCourseAssociation { public GithubSubjectCourseAssociation( + Guid id, SubjectCourse subjectCourse, string githubOrganizationName, string templateRepositoryName) - : base(subjectCourse) + : base(id) { GithubOrganizationName = githubOrganizationName; TemplateRepositoryName = templateRepositoryName; diff --git a/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/GoogleTableSubjectCourseAssociation.cs b/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/GoogleTableSubjectCourseAssociation.cs index 5eea1e066..74463f264 100644 --- a/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/GoogleTableSubjectCourseAssociation.cs +++ b/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/GoogleTableSubjectCourseAssociation.cs @@ -4,8 +4,7 @@ namespace Kysect.Shreks.Core.SubjectCourseAssociations; public partial class GoogleTableSubjectCourseAssociation : SubjectCourseAssociation { - public GoogleTableSubjectCourseAssociation(SubjectCourse subjectCourse, string spreadsheetId) - : base(subjectCourse) + public GoogleTableSubjectCourseAssociation(Guid id, SubjectCourse subjectCourse, string spreadsheetId) : base(id) { SpreadsheetId = spreadsheetId; } diff --git a/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/SubjectCourseAssociation.cs b/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/SubjectCourseAssociation.cs index de87ae56a..9def3942f 100644 --- a/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/SubjectCourseAssociation.cs +++ b/Source/Domain/Kysect.Shreks.Core/SubjectCourseAssociations/SubjectCourseAssociation.cs @@ -5,8 +5,7 @@ namespace Kysect.Shreks.Core.SubjectCourseAssociations; public abstract partial class SubjectCourseAssociation : IEntity { - protected SubjectCourseAssociation(SubjectCourse subjectCourse) - : this(Guid.NewGuid()) + protected SubjectCourseAssociation(Guid id, SubjectCourse subjectCourse) : this(id) { SubjectCourse = subjectCourse; } diff --git a/Source/Domain/Kysect.Shreks.Core/SubmissionAssociations/GithubSubmissionAssociation.cs b/Source/Domain/Kysect.Shreks.Core/SubmissionAssociations/GithubSubmissionAssociation.cs index 1127cc996..d28202971 100644 --- a/Source/Domain/Kysect.Shreks.Core/SubmissionAssociations/GithubSubmissionAssociation.cs +++ b/Source/Domain/Kysect.Shreks.Core/SubmissionAssociations/GithubSubmissionAssociation.cs @@ -5,11 +5,12 @@ namespace Kysect.Shreks.Core.SubmissionAssociations; public partial class GithubSubmissionAssociation : SubmissionAssociation { public GithubSubmissionAssociation( + Guid id, GithubSubmission submission, string organization, string repository, long prNumber) - : base(submission) + : base(id) { Repository = repository; PrNumber = prNumber; diff --git a/Source/Domain/Kysect.Shreks.Core/SubmissionAssociations/SubmissionAssociation.cs b/Source/Domain/Kysect.Shreks.Core/SubmissionAssociations/SubmissionAssociation.cs index a8e2e0733..a4951e962 100644 --- a/Source/Domain/Kysect.Shreks.Core/SubmissionAssociations/SubmissionAssociation.cs +++ b/Source/Domain/Kysect.Shreks.Core/SubmissionAssociations/SubmissionAssociation.cs @@ -5,8 +5,7 @@ namespace Kysect.Shreks.Core.SubmissionAssociations; public abstract partial class SubmissionAssociation : IEntity { - protected SubmissionAssociation(Submission submission) - : this(Guid.NewGuid()) + protected SubmissionAssociation(Guid id, Submission submission) : this(id) { Submission = submission; } diff --git a/Source/Domain/Kysect.Shreks.Core/Submissions/GithubSubmission.cs b/Source/Domain/Kysect.Shreks.Core/Submissions/GithubSubmission.cs index 44b006ae7..974abe3c6 100644 --- a/Source/Domain/Kysect.Shreks.Core/Submissions/GithubSubmission.cs +++ b/Source/Domain/Kysect.Shreks.Core/Submissions/GithubSubmission.cs @@ -8,6 +8,7 @@ namespace Kysect.Shreks.Core.Submissions; public partial class GithubSubmission : Submission { public GithubSubmission( + Guid id, int code, Student student, GroupAssignment groupAssignment, @@ -16,9 +17,10 @@ public GithubSubmission( string organization, string repository, long prNumber) - : base(code, student, groupAssignment, submissionDate, payload) + : base(id, code, student, groupAssignment, submissionDate, payload) { var association = new GithubSubmissionAssociation( + Guid.NewGuid(), this, organization, repository, diff --git a/Source/Domain/Kysect.Shreks.Core/Submissions/Submission.cs b/Source/Domain/Kysect.Shreks.Core/Submissions/Submission.cs index b4c788f25..15dac218d 100644 --- a/Source/Domain/Kysect.Shreks.Core/Submissions/Submission.cs +++ b/Source/Domain/Kysect.Shreks.Core/Submissions/Submission.cs @@ -15,12 +15,13 @@ public abstract partial class Submission : IEntity private readonly HashSet _associations; protected Submission( + Guid id, int code, Student student, GroupAssignment groupAssignment, SpbDateTime submissionDate, string payload) - : this(Guid.NewGuid()) + : this(id) { Code = code; SubmissionDate = submissionDate; diff --git a/Source/Domain/Kysect.Shreks.Core/UserAssociations/GithubUserAssociation.cs b/Source/Domain/Kysect.Shreks.Core/UserAssociations/GithubUserAssociation.cs index 4f0ff5a9e..dd559dd1a 100644 --- a/Source/Domain/Kysect.Shreks.Core/UserAssociations/GithubUserAssociation.cs +++ b/Source/Domain/Kysect.Shreks.Core/UserAssociations/GithubUserAssociation.cs @@ -4,8 +4,7 @@ namespace Kysect.Shreks.Core.UserAssociations; public partial class GithubUserAssociation : UserAssociation { - public GithubUserAssociation(User user, string githubUsername) - : base(user) + public GithubUserAssociation(Guid id, User user, string githubUsername) : base(id, user) { GithubUsername = githubUsername; } diff --git a/Source/Domain/Kysect.Shreks.Core/UserAssociations/IsuUserAssociation.cs b/Source/Domain/Kysect.Shreks.Core/UserAssociations/IsuUserAssociation.cs index fe59fb119..9ba82a576 100644 --- a/Source/Domain/Kysect.Shreks.Core/UserAssociations/IsuUserAssociation.cs +++ b/Source/Domain/Kysect.Shreks.Core/UserAssociations/IsuUserAssociation.cs @@ -4,8 +4,7 @@ namespace Kysect.Shreks.Core.UserAssociations; public partial class IsuUserAssociation : UserAssociation { - public IsuUserAssociation(User user, int universityId) - : base(user) + public IsuUserAssociation(Guid id, User user, int universityId) : base(id, user) { UniversityId = universityId; } diff --git a/Source/Domain/Kysect.Shreks.Core/UserAssociations/UserAssociation.cs b/Source/Domain/Kysect.Shreks.Core/UserAssociations/UserAssociation.cs index ac0dff405..5e93be1d3 100644 --- a/Source/Domain/Kysect.Shreks.Core/UserAssociations/UserAssociation.cs +++ b/Source/Domain/Kysect.Shreks.Core/UserAssociations/UserAssociation.cs @@ -5,8 +5,7 @@ namespace Kysect.Shreks.Core.UserAssociations; public abstract partial class UserAssociation : IEntity { - protected UserAssociation(User user) - : this(Guid.NewGuid()) + protected UserAssociation(Guid id, User user) : this(id) { User = user; user.AddAssociation(this); diff --git a/Source/Domain/Kysect.Shreks.Core/Users/StudentExtensions.cs b/Source/Domain/Kysect.Shreks.Core/Users/StudentExtensions.cs index f8ad8519c..ce318fb5a 100644 --- a/Source/Domain/Kysect.Shreks.Core/Users/StudentExtensions.cs +++ b/Source/Domain/Kysect.Shreks.Core/Users/StudentExtensions.cs @@ -6,6 +6,6 @@ public static class StudentExtensions { public static GithubUserAssociation AddGithubAssociation(this Student student, string githubUsername) { - return new GithubUserAssociation(student.User, githubUsername); + return new GithubUserAssociation(Guid.NewGuid(), student.User, githubUsername); } } \ No newline at end of file diff --git a/Source/Domain/Kysect.Shreks.Core/Users/User.cs b/Source/Domain/Kysect.Shreks.Core/Users/User.cs index 802fb75dc..6526cffd1 100644 --- a/Source/Domain/Kysect.Shreks.Core/Users/User.cs +++ b/Source/Domain/Kysect.Shreks.Core/Users/User.cs @@ -8,8 +8,7 @@ public partial class User : IEntity { private readonly HashSet _associations; - public User(string firstName, string middleName, string lastName) - : this(Guid.NewGuid()) + public User(Guid id, string firstName, string middleName, string lastName) : this(id) { ArgumentNullException.ThrowIfNull(firstName); ArgumentNullException.ThrowIfNull(middleName); diff --git a/Source/Infrastructure/Integration/Kysect.Shreks.Integration.Google/Tools/ISheetManagementService.cs b/Source/Infrastructure/Integration/Kysect.Shreks.Integration.Google/Tools/ISheetManagementService.cs index dcbb532a0..000ff8fef 100644 --- a/Source/Infrastructure/Integration/Kysect.Shreks.Integration.Google/Tools/ISheetManagementService.cs +++ b/Source/Infrastructure/Integration/Kysect.Shreks.Integration.Google/Tools/ISheetManagementService.cs @@ -4,12 +4,12 @@ public interface ISheetManagementService { /// /// Clears all values and formatting of a sheet - /// if it exists and creates it otherwise + /// if it exists and creates it otherwise. /// - /// Sheet id + /// Sheet id. Task CreateOrClearSheetAsync(string spreadsheetId, string sheetTitle, CancellationToken token); - /// Sheet id + /// Sheet id. Task CreateSheetAsync(string spreadsheetId, string sheetTitle, CancellationToken token); Task CheckIfExists(string spreadsheetId, string sheetTitle, CancellationToken token); diff --git a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/AssignmentGenerator.cs b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/AssignmentGenerator.cs index 5fde24daa..9f6e3458f 100644 --- a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/AssignmentGenerator.cs +++ b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/AssignmentGenerator.cs @@ -27,6 +27,7 @@ protected override Assignment Generate(int index) int assignmentOrder = index + 1; var assignment = new Assignment( + _faker.Random.Guid(), _faker.Commerce.Product(), $"lab-{assignmentOrder}", assignmentOrder, diff --git a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/StudentGroupGenerator.cs b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/StudentGroupGenerator.cs index 547c28f7f..a539c80d1 100644 --- a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/StudentGroupGenerator.cs +++ b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/StudentGroupGenerator.cs @@ -20,6 +20,6 @@ public StudentGroupGenerator(EntityGeneratorOptions options, Faker protected override StudentGroup Generate(int index) { int groupNumber = _faker.Random.Int(MinGroupNumber, MaxGroupNumber); - return new StudentGroup($"M{groupNumber}"); + return new StudentGroup(_faker.Random.Guid(), $"M{groupNumber}"); } } \ No newline at end of file diff --git a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/SubjectCourseGenerator.cs b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/SubjectCourseGenerator.cs index bd4976029..6a5112f13 100644 --- a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/SubjectCourseGenerator.cs +++ b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/SubjectCourseGenerator.cs @@ -48,7 +48,7 @@ protected override SubjectCourse Generate(int index) const SubmissionStateWorkflowType reviewType = SubmissionStateWorkflowType.ReviewWithDefense; - var subjectCourse = new SubjectCourse(subject, subjectCourseName, reviewType); + var subjectCourse = new SubjectCourse(_faker.Random.Guid(), subject, subjectCourseName, reviewType); IEnumerable users = _faker.Random .ListItems(_userGenerator.GeneratedEntities.ToList(), 2) diff --git a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/SubjectGenerator.cs b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/SubjectGenerator.cs index ca15d67ec..aae43204a 100644 --- a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/SubjectGenerator.cs +++ b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Study/SubjectGenerator.cs @@ -16,6 +16,6 @@ public SubjectGenerator(EntityGeneratorOptions options, Faker faker) protected override Subject Generate(int index) { - return new Subject(_faker.Commerce.Product()); + return new Subject(_faker.Random.Guid(), _faker.Commerce.Product()); } } \ No newline at end of file diff --git a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/SubjectCourseAssociations/SubjectCourseAssociationGenerator.cs b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/SubjectCourseAssociations/SubjectCourseAssociationGenerator.cs index 5be4a5605..6000bbdb4 100644 --- a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/SubjectCourseAssociations/SubjectCourseAssociationGenerator.cs +++ b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/SubjectCourseAssociations/SubjectCourseAssociationGenerator.cs @@ -33,6 +33,7 @@ protected override GithubSubjectCourseAssociation Generate(int index) SubjectCourse subjectCourse = _subjectCourseGenerator.GeneratedEntities[index]; var association = new GithubSubjectCourseAssociation( + _faker.Random.Guid(), subjectCourse, _faker.Random.Guid().ToString(), _faker.Internet.UserName()); diff --git a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Submissions/GithubSubmissionGenerator.cs b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Submissions/GithubSubmissionGenerator.cs index 09b4677b0..0a02f6cac 100644 --- a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Submissions/GithubSubmissionGenerator.cs +++ b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/Submissions/GithubSubmissionGenerator.cs @@ -36,8 +36,7 @@ protected override GithubSubmission Generate(int index) Assignment assignment = _faker.PickRandom(assignments); IEnumerable students = assignment.GroupAssignments.SelectMany(x => x.Group.Students) - .Where(student => assignment.SubjectCourse.Mentors - .Any(mentor => mentor.User.Equals(student.User)) is false); + .Where(student => assignment.SubjectCourse.Mentors.Any(mentor => mentor.User.Equals(student.User)) is false); Student student = _faker.PickRandom(students); @@ -46,6 +45,7 @@ protected override GithubSubmission Generate(int index) int submissionCount = groupAssignment.Submissions.Count(x => x.Student.Equals(student)); var submission = new GithubSubmission( + _faker.Random.Guid(), submissionCount + 1, student, groupAssignment, diff --git a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/User/UserGenerator.cs b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/User/UserGenerator.cs index 4870a1c5a..62d0ee21f 100644 --- a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/User/UserGenerator.cs +++ b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/User/UserGenerator.cs @@ -18,6 +18,7 @@ public UserGenerator(EntityGeneratorOptions options, Faker faker) protected override User Generate(int index) { return new User( + _faker.Random.Guid(), _faker.Name.FirstName(), _faker.Name.MiddleName(), _faker.Name.LastName()); diff --git a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/UserAssociations/GithubUserAssociationGenerator.cs b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/UserAssociations/GithubUserAssociationGenerator.cs index 37be566d7..52483a53c 100644 --- a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/UserAssociations/GithubUserAssociationGenerator.cs +++ b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/UserAssociations/GithubUserAssociationGenerator.cs @@ -27,7 +27,7 @@ protected override GithubUserAssociation Generate(int index) User user = _userGenerator.GeneratedEntities[index]; - var association = new GithubUserAssociation(user, _faker.Random.Guid().ToString()); + var association = new GithubUserAssociation(_faker.Random.Guid(), user, _faker.Random.Guid().ToString()); return association; } diff --git a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/UserAssociations/IsuUserAssociationGenerator.cs b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/UserAssociations/IsuUserAssociationGenerator.cs index b4dc69241..0ff67c707 100644 --- a/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/UserAssociations/IsuUserAssociationGenerator.cs +++ b/Source/Infrastructure/Kysect.Shreks.Seeding/EntityGenerators/UserAssociations/IsuUserAssociationGenerator.cs @@ -41,7 +41,7 @@ protected override IsuUserAssociation Generate(int index) } int id = _faker.Random.Int(MinIsuNumber, MaxIsuNumber); - var association = new IsuUserAssociation(user, id); + var association = new IsuUserAssociation(_faker.Random.Guid(), user, id); return association; } diff --git a/Source/Infrastructure/Kysect.Shreks.Seeding/Kysect.Shreks.Seeding.csproj b/Source/Infrastructure/Kysect.Shreks.Seeding/Kysect.Shreks.Seeding.csproj index 37cdb601d..f94b65f46 100644 --- a/Source/Infrastructure/Kysect.Shreks.Seeding/Kysect.Shreks.Seeding.csproj +++ b/Source/Infrastructure/Kysect.Shreks.Seeding/Kysect.Shreks.Seeding.csproj @@ -4,8 +4,6 @@ net6.0 enable enable - latest - True diff --git a/Source/Kysect.Shreks.sln b/Source/Kysect.Shreks.sln index 9372a96c5..ea2f40cf0 100644 --- a/Source/Kysect.Shreks.sln +++ b/Source/Kysect.Shreks.sln @@ -59,11 +59,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kysect.Shreks.Application.G EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kysect.Shreks.Application.GithubWorkflow.Abstractions", "Application\Kysect.Shreks.Application.GithubWorkflow.Abstractions\Kysect.Shreks.Application.GithubWorkflow.Abstractions.csproj", "{3B0EB40E-6E3C-4F8D-BBD7-9B7FC5FB7D68}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{557DD492-F931-45E9-8E1E-96FAE771E747}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kysect.Shreks.Application.Google", "Application\Kysect.Shreks.Application.Google\Kysect.Shreks.Application.Google.csproj", "{A57B6F3D-1DC1-41A7-90CD-99158B4D55DA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kysect.Shreks.Controllers", "Presentation\Kysect.Shreks.Controllers\Kysect.Shreks.Controllers.csproj", "{561BAC9C-4E54-414A-BFDA-AFF90B6F5ADF}" diff --git a/Source/Playground/Kysect.Shreks.Playground.Github/TestEnv/TestEnvExtensions.cs b/Source/Playground/Kysect.Shreks.Playground.Github/TestEnv/TestEnvExtensions.cs index 8922e0da6..3619e2cc0 100644 --- a/Source/Playground/Kysect.Shreks.Playground.Github/TestEnv/TestEnvExtensions.cs +++ b/Source/Playground/Kysect.Shreks.Playground.Github/TestEnv/TestEnvExtensions.cs @@ -19,21 +19,23 @@ public static IServiceCollection AddGithubPlaygroundDatabase( TestEnvironmentConfiguration config) { serviceCollection - .AddDatabaseContext(optionsBuilder => optionsBuilder - .UseSqlite("Filename=shreks-gh.db") - .UseLazyLoadingProxies()); + .AddDatabaseContext( + optionsBuilder => optionsBuilder + .UseSqlite("Filename=shreks-gh.db") + .UseLazyLoadingProxies()); - serviceCollection.AddEntityGenerators(o => - { - o.ConfigureFaker(o => o.Locale = "ru"); - o.ConfigureEntityGenerator(o => o.Count = config.Users.Count); - o.ConfigureEntityGenerator(o => o.Count = config.Users.Count); - o.ConfigureEntityGenerator(o => o.Count = 0); - o.ConfigureEntityGenerator(o => o.Count = 0); - o.ConfigureEntityGenerator(o => o.Count = 0); - o.ConfigureEntityGenerator(o => o.Count = 1); - o.ConfigureEntityGenerator(o => o.Count = 0); - }); + serviceCollection.AddEntityGenerators( + o => + { + o.ConfigureFaker(o => o.Locale = "ru"); + o.ConfigureEntityGenerator(o => o.Count = config.Users.Count); + o.ConfigureEntityGenerator(o => o.Count = config.Users.Count); + o.ConfigureEntityGenerator(o => o.Count = 0); + o.ConfigureEntityGenerator(o => o.Count = 0); + o.ConfigureEntityGenerator(o => o.Count = 0); + o.ConfigureEntityGenerator(o => o.Count = 1); + o.ConfigureEntityGenerator(o => o.Count = 0); + }); return serviceCollection.AddDatabaseSeeders(); } @@ -58,15 +60,22 @@ public static async Task UseTestEnv( { User user = users[index]; string login = config.Users[index]; - dbContext.UserAssociations.Add(new GithubUserAssociation(user, login)); + dbContext.UserAssociations.Add(new GithubUserAssociation(Guid.NewGuid(), user, login)); } - IEntityGenerator subjectCourseGenerator = - serviceProvider.GetRequiredService>(); + IEntityGenerator subjectCourseGenerator = serviceProvider + .GetRequiredService>(); + SubjectCourse subjectCourse = subjectCourseGenerator.GeneratedEntities[0]; dbContext.SubjectCourses.Attach(subjectCourse); - dbContext.SubjectCourseAssociations.Add( - new GithubSubjectCourseAssociation(subjectCourse, config.Organization, config.TemplateRepository)); + + var association = new GithubSubjectCourseAssociation( + Guid.NewGuid(), + subjectCourse, + config.Organization, + config.TemplateRepository); + + dbContext.SubjectCourseAssociations.Add(association); await dbContext.SaveChangesAsync(cancellationToken); #pragma warning restore CS0162 diff --git a/Source/Presentation/Kysect.Shreks.Controllers/Kysect.Shreks.Controllers.csproj b/Source/Presentation/Kysect.Shreks.Controllers/Kysect.Shreks.Controllers.csproj index c997ad0bb..f4c6886ee 100644 --- a/Source/Presentation/Kysect.Shreks.Controllers/Kysect.Shreks.Controllers.csproj +++ b/Source/Presentation/Kysect.Shreks.Controllers/Kysect.Shreks.Controllers.csproj @@ -6,7 +6,6 @@ enable latest True - 1701;1702;CA1062;SA1101;SA1309;SA1633;SA1503;SA1127;SA1128;SA1502 diff --git a/Source/Tests/Kysect.Shreks.Tests.Handlers/Kysect.Shreks.Tests.Handlers.csproj b/Source/Tests/Kysect.Shreks.Tests.Handlers/Kysect.Shreks.Tests.Handlers.csproj index 2897e955f..e2a5f7249 100644 --- a/Source/Tests/Kysect.Shreks.Tests.Handlers/Kysect.Shreks.Tests.Handlers.csproj +++ b/Source/Tests/Kysect.Shreks.Tests.Handlers/Kysect.Shreks.Tests.Handlers.csproj @@ -4,7 +4,7 @@ net6.0 enable enable - 1701;1702;IL2121;CA1707;1591;SA1633;SA1101;SA1503;SA1309;SA1601;SA1201 + $(NoWarn);1701;1702;IL2121;CA1707;1591;SA1633;SA1101;SA1503;SA1309;SA1601;SA1201 false diff --git a/Source/Tests/Kysect.Shreks.Tests.Services/Kysect.Shreks.Tests.Services.csproj b/Source/Tests/Kysect.Shreks.Tests.Services/Kysect.Shreks.Tests.Services.csproj index cbdef96ea..e27d521c8 100644 --- a/Source/Tests/Kysect.Shreks.Tests.Services/Kysect.Shreks.Tests.Services.csproj +++ b/Source/Tests/Kysect.Shreks.Tests.Services/Kysect.Shreks.Tests.Services.csproj @@ -4,7 +4,7 @@ net6.0 enable enable - 1701;1702;IL2121;CA1707;1591;SA1633;SA1101;SA1503;SA1309;SA1601;SA1201 + $(NoWarn);1701;1702;IL2121;CA1707;1591;SA1633;SA1101;SA1503;SA1309;SA1601;SA1201 false diff --git a/Source/Tests/Kysect.Shreks.Tests/GithubWorkflow/Tools/GithubApplicationTestContextGenerator.cs b/Source/Tests/Kysect.Shreks.Tests/GithubWorkflow/Tools/GithubApplicationTestContextGenerator.cs index 2d77d79be..6460db791 100644 --- a/Source/Tests/Kysect.Shreks.Tests/GithubWorkflow/Tools/GithubApplicationTestContextGenerator.cs +++ b/Source/Tests/Kysect.Shreks.Tests/GithubWorkflow/Tools/GithubApplicationTestContextGenerator.cs @@ -44,15 +44,29 @@ public async Task Create() _context.StudentGroups.Add(group); Subject subject = _subjectGenerator.Generate(); - var subjectCourse = - new SubjectCourse(subject, _faker.Commerce.ProductName(), SubmissionStateWorkflowType.ReviewOnly); + var subjectCourse = new SubjectCourse( + _faker.Random.Guid(), + subject, + _faker.Commerce.ProductName(), + SubmissionStateWorkflowType.ReviewOnly); + var githubSubjectCourseAssociation = new GithubSubjectCourseAssociation( + _faker.Random.Guid(), subjectCourse, _faker.Company.CompanyName(), _faker.Commerce.ProductName()); + var subjectCourseGroup = new SubjectCourseGroup(subjectCourse, group); - var assignment = - new Assignment(_faker.Hacker.Verb(), "task-0", 1, new Points(0), new Points(10), subjectCourse); + + var assignment = new Assignment( + _faker.Random.Guid(), + _faker.Hacker.Verb(), + "task-0", + 1, + new Points(0), + new Points(10), + subjectCourse); + subjectCourse.AddAssignment(assignment); var groupAssignment = new GroupAssignment(group, assignment, DateOnly.FromDateTime(DateTime.Now)); diff --git a/Source/Tests/Kysect.Shreks.Tests/Kysect.Shreks.Tests.csproj b/Source/Tests/Kysect.Shreks.Tests/Kysect.Shreks.Tests.csproj index 99a6a2a64..174a91f82 100644 --- a/Source/Tests/Kysect.Shreks.Tests/Kysect.Shreks.Tests.csproj +++ b/Source/Tests/Kysect.Shreks.Tests/Kysect.Shreks.Tests.csproj @@ -6,7 +6,7 @@ latest True false - 1701;1702;IL2121;CA1707;SA1633;SA1309;SA1101;SA1518;SA1502 + $(NoWarn);1701;1702;IL2121;CA1707;SA1633;SA1309;SA1101;SA1518;SA1502