Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task<OperationResult> Handle(RegisterNewUserCommand request, Cancel
return OperationResult.Fail(userRegisteredResult.Errors.Select(_ => _.Description).ToList());
}

var userObtainedRoleStudentResult = await _userManager.AddToRoleAsync(newUser, DomainRoles.Student.ToString());
var userObtainedRoleStudentResult = await _userManager.AddToRoleAsync(newUser, DomainRoles.DomainUser.ToString());

if (!userObtainedRoleStudentResult.Succeeded)
{
Expand Down
5 changes: 2 additions & 3 deletions server/StudySharp.Domain/Enums/DomainRoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
{
public enum DomainRoles
{
Unknown = 0,
Teacher = 1,
Student = 2,
DomainUser = 1,
Teacher = 2,
Moderator = 3,
Admin = 4,
}
Expand Down
9 changes: 9 additions & 0 deletions server/StudySharp.Domain/Models/AppearanceType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace StudySharp.Domain.Models
{
public enum AppearanceType
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we won't have access modifiers for other entities in the future?
Maybe add "Course" to this name, or change it to more corresponding to courses

{
IsPublic = 1,
IsPrivate = 2,
IsInternal = 3,
}
}
5 changes: 4 additions & 1 deletion server/StudySharp.Domain/Models/Course.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ public sealed class Course : IWithDateCreated, IWithDateModified
public int Id { get; set; }
public string Name { get; set; }
public List<Tag> Tags { get; set; }
public int TeacherId { get; set; }
public int? TeacherId { get; set; }
public Teacher Teacher { get; set; }
public int? OrganizationId { get; set; }
public Organization Organization { get; set; }
public AppearanceType Appearance { get; set; }
public List<TheoryBlock> TheoryBlocks { get; set; }
public List<PracticalBlock> PracticalBlocks { get; set; }
public DateTimeOffset DateCreated { get; private set; }
Expand Down
12 changes: 12 additions & 0 deletions server/StudySharp.Domain/Models/DomainUser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace StudySharp.Domain.Models
{
public sealed class DomainUser
{
public int Id { get; set; }
public int AppUserId { get; set; }
public int? TeacherId { get; set; }
public Teacher Teacher { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
}
18 changes: 18 additions & 0 deletions server/StudySharp.Domain/Models/Organization.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using StudySharp.Domain.Contracts;

namespace StudySharp.Domain.Models
{
public sealed class Organization : IWithDateCreated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe IWithDateModified too?

{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int OwnerId { get; set; }
public OrganizationStatus Status { get; set; }
public DateTimeOffset DateCreated { get; private set; }
void IWithDateCreated.SetDateCreated(DateTimeOffset value) => DateCreated = value;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move this property to the last line

public List<DomainUser> Members { get; set; }
}
}
12 changes: 12 additions & 0 deletions server/StudySharp.Domain/Models/OrganizationRepresentative.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace StudySharp.Domain.Models
{
public sealed class OrganizationRepresentative
{
public int OrganizationId { get; set; }
public int MemberId { get; set; }
public bool CanCreate { get; set; }
public bool CanEdit { get; set; }
public bool CanDelete { get; set; }
public bool IsOrganizationManager { get; set; }
}
}
9 changes: 9 additions & 0 deletions server/StudySharp.Domain/Models/OrganizationStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace StudySharp.Domain.Models
{
public enum OrganizationStatus
{
New = 1,
OnConsideration = 2,
Confirmed = 3,
}
}
3 changes: 0 additions & 3 deletions server/StudySharp.Domain/Models/Teacher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ namespace StudySharp.Domain.Models
{
public sealed class Teacher
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add DomainUser to Teacher, it may help us in some situations

public int UserId { get; set; }
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public List<Course> Courses { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace StudySharp.DomainServices.Configurations
{
public class ContentConfiguration : IEntityTypeConfiguration<Course>
public sealed class CourseConfiguration : IEntityTypeConfiguration<Course>
{
public void Configure(EntityTypeBuilder<Course> builder)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using StudySharp.Domain.Models;

namespace StudySharp.DomainServices.Configurations
{
public sealed class DomainUserConfiguration : IEntityTypeConfiguration<DomainUser>
{
public void Configure(EntityTypeBuilder<DomainUser> builder)
{
builder
.HasKey(_ => _.Id);

builder
.Property(_ => _.FirstName)
.IsRequired();

builder
.Property(_ => _.LastName)
.IsRequired();

builder
.HasOne(_ => _.Teacher)
.WithOne()
.HasForeignKey<DomainUser>(_ => _.TeacherId);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using StudySharp.Domain.Models;

namespace StudySharp.DomainServices.Configurations
{
public sealed class OrganizationConfiguration : IEntityTypeConfiguration<Organization>
{
public void Configure(EntityTypeBuilder<Organization> builder)
{
throw new NotImplementedException();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using StudySharp.Domain.Models;

namespace StudySharp.DomainServices.Configurations
{
public sealed class OrganizationRepresentativeConfiguration : IEntityTypeConfiguration<OrganizationRepresentative>
{
public void Configure(EntityTypeBuilder<OrganizationRepresentative> builder)
{
throw new NotImplementedException();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace StudySharp.DomainServices.Configurations
{
public class QuizConfiguration : IEntityTypeConfiguration<Quiz>
public sealed class QuizConfiguration : IEntityTypeConfiguration<Quiz>
{
public void Configure(EntityTypeBuilder<Quiz> builder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace StudySharp.DomainServices.Configurations
{
public class TagConfiguration : IEntityTypeConfiguration<Tag>
public sealed class TagConfiguration : IEntityTypeConfiguration<Tag>
{
public void Configure(EntityTypeBuilder<Tag> builder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@

namespace StudySharp.DomainServices.Configurations
{
public class TeacherConfiguration : IEntityTypeConfiguration<Teacher>
public sealed class TeacherConfiguration : IEntityTypeConfiguration<Teacher>
{
public void Configure(EntityTypeBuilder<Teacher> builder)
{
builder
.HasKey(_ => _.Id);

builder
.Property(_ => _.FirstName)
.IsRequired();

builder
.Property(_ => _.LastName)
.IsRequired();
.HasMany(_ => _.Courses)
.WithOne(_ => _.Teacher)
.HasForeignKey(_ => _.TeacherId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace StudySharp.DomainServices.Configurations
{
public class TheoryBlockConfiguration : IEntityTypeConfiguration<TheoryBlock>
public sealed class TheoryBlockConfiguration : IEntityTypeConfiguration<TheoryBlock>
{
public void Configure(EntityTypeBuilder<TheoryBlock> builder)
{
Expand Down
3 changes: 3 additions & 0 deletions server/StudySharp.DomainServices/StudySharpDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace StudySharp.DomainServices
{
public class StudySharpDbContext : IdentityDbContext<ApplicationUser, IdentityRole<int>, int>
{
public DbSet<DomainUser> DomainUsers { get; set; }
public DbSet<Organization> Organizations { get; set; }
public DbSet<OrganizationRepresentative> OrganizationRepresentatives { get; set; }
public DbSet<Teacher> Teachers { get; set; }
public DbSet<Course> Courses { get; set; }
public DbSet<PracticalBlock> PracticalBlocks { get; set; }
Expand Down