initial commit from an older template
This commit is contained in:
7
Models/BasicResponses/BasicResponse.cs
Executable file
7
Models/BasicResponses/BasicResponse.cs
Executable file
@@ -0,0 +1,7 @@
|
||||
namespace GamificationService.Models.BasicResponses;
|
||||
|
||||
public class BasicResponse
|
||||
{
|
||||
public short Code { get; set; }
|
||||
public string Message { get; set; }
|
||||
}
|
||||
21
Models/DTO/AuthDTO.cs
Executable file
21
Models/DTO/AuthDTO.cs
Executable file
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class AuthDTO
|
||||
{
|
||||
[Required]
|
||||
[StringLength(50, MinimumLength = 3, ErrorMessage = "Username must be between 3 and 50 characters")]
|
||||
public string Username { get; set; } = null!;
|
||||
|
||||
[Required]
|
||||
[EmailAddress(ErrorMessage = "Invalid email address")]
|
||||
public string Email { get; set; } = null!;
|
||||
|
||||
[Required]
|
||||
[StringLength(100, MinimumLength = 8, ErrorMessage = "Password must be between 8 and 100 characters")]
|
||||
public string Password { get; set; } = null!;
|
||||
|
||||
[Required]
|
||||
public bool RememberMe { get; set; }
|
||||
}
|
||||
7
Models/DTO/DisableTwoFactorDTO.cs
Normal file
7
Models/DTO/DisableTwoFactorDTO.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class DisableTwoFactorDTO
|
||||
{
|
||||
public int TwoFactorProvider { get; set; }
|
||||
public string Code { get; set; }
|
||||
}
|
||||
6
Models/DTO/EnableTwoFactorDTO.cs
Normal file
6
Models/DTO/EnableTwoFactorDTO.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class EnableTwoFactorDTO
|
||||
{
|
||||
public int TwoFactorProvider { get; set; }
|
||||
}
|
||||
11
Models/DTO/GetAllRightsResponse.cs
Normal file
11
Models/DTO/GetAllRightsResponse.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using GamificationService.Models.Database;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class GetAllRightsResponse
|
||||
{
|
||||
public List<Right> Rights { get; set; }
|
||||
public int TotalCount { get; set; }
|
||||
public int PageNumber { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
}
|
||||
11
Models/DTO/GetAllRolesResponse.cs
Normal file
11
Models/DTO/GetAllRolesResponse.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using GamificationService.Models.Database;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class GetAllRolesResponse
|
||||
{
|
||||
public List<ApplicationRole> Roles { get; set; }
|
||||
public int TotalCount { get; set; }
|
||||
public int PageNumber { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
}
|
||||
11
Models/DTO/GetTwoFactorDTO.cs
Normal file
11
Models/DTO/GetTwoFactorDTO.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class GetTwoFactorDTO
|
||||
{
|
||||
[Required]
|
||||
public int TwoFactorProvider { get; set; }
|
||||
[StringLength(50, MinimumLength = 3, ErrorMessage = "Username must be between 3 and 50 characters")]
|
||||
public string? Username { get; set; } = null!;
|
||||
}
|
||||
14
Models/DTO/InstructionCategoryCreateDTO.cs
Normal file
14
Models/DTO/InstructionCategoryCreateDTO.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionCategoryCreateDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Title is required")]
|
||||
public string Title { get; set; } = null!;
|
||||
}
|
||||
|
||||
|
||||
|
||||
10
Models/DTO/InstructionCategoryDTO.cs
Normal file
10
Models/DTO/InstructionCategoryDTO.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionCategoryDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
public string? Title { get; set; } = null!;
|
||||
}
|
||||
|
||||
|
||||
38
Models/DTO/InstructionCreateDTO.cs
Normal file
38
Models/DTO/InstructionCreateDTO.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionCreateDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Title is required")]
|
||||
public string Title { get; set; } = null!;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Paragraphs are required")]
|
||||
public List<InstructionParagraphCreateDTO> Paragraphs { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Category id is required")]
|
||||
public long CategoryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If AssignDate is set, the instruction will be automatically enabled
|
||||
/// when the date is reached. If it's not set, the test will automatically
|
||||
/// obtain the current date as its AssignDate as soon as the instruction
|
||||
/// will be enabled by the IsEnabled parameter.
|
||||
/// </summary>
|
||||
public DateTime? AssignDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When deadline is reached, no more submissions are allowed for this instruction.
|
||||
/// </summary>
|
||||
public DateTime? DeadlineDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Disabled instructions cannot be seen by users.
|
||||
/// Tests for such instructions cannot be submitted either.
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = false;
|
||||
}
|
||||
21
Models/DTO/InstructionDTO.cs
Normal file
21
Models/DTO/InstructionDTO.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
public string? Title { get; set; }
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public List<InstructionParagraphDTO> Paragraphs { get; set; } = new List<InstructionParagraphDTO>();
|
||||
|
||||
public long? CategoryId { get; set; }
|
||||
|
||||
public DateTime? AssignDate { get; set; }
|
||||
|
||||
public DateTime? DeadlineDate { get; set; }
|
||||
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
|
||||
25
Models/DTO/InstructionParagraphCreateDTO.cs
Normal file
25
Models/DTO/InstructionParagraphCreateDTO.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionParagraphCreateDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
public long? InstructionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Order defines the order of the paragraphs inside the instruction.
|
||||
/// There must not be two paragraphs with the same order.
|
||||
/// </summary>
|
||||
public int Order { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Text is required")]
|
||||
public string Text { get; set; } = null!;
|
||||
|
||||
public string? ImageUrl { get; set; }
|
||||
|
||||
public string? VideoUrl { get; set; }
|
||||
}
|
||||
|
||||
|
||||
21
Models/DTO/InstructionParagraphDTO.cs
Normal file
21
Models/DTO/InstructionParagraphDTO.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionParagraphDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
public long? InstructionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Order defines the order of the paragraphs inside the instruction.
|
||||
/// There must not be two paragraphs with the same order.
|
||||
/// </summary>
|
||||
public int Order { get; set; }
|
||||
|
||||
public string? Text { get; set; } = null!;
|
||||
|
||||
public string? ImageUrl { get; set; }
|
||||
|
||||
public string? VideoUrl { get; set; }
|
||||
}
|
||||
|
||||
20
Models/DTO/InstructionTestCreateDTO.cs
Normal file
20
Models/DTO/InstructionTestCreateDTO.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using GamificationService.Utils.Enums;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionTestCreateDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
public string? Title { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Questions must be specified")]
|
||||
public ICollection<InstructionTestQuestionCreateDTO> Questions { get; set; } = null!;
|
||||
|
||||
public int MaxAttempts { get; set; } = 10;
|
||||
|
||||
[Range(0, 1.0, ErrorMessage = "Minimum score must be between 0.6 and 1.0")]
|
||||
public double MinScore { get; set; } = 0.6;
|
||||
|
||||
public InstructionTestScoreCalcMethod ScoreCalcMethod { get; set; } = InstructionTestScoreCalcMethod.MaxGrade;
|
||||
}
|
||||
23
Models/DTO/InstructionTestDTO.cs
Normal file
23
Models/DTO/InstructionTestDTO.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using GamificationService.Utils.Enums;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionTestDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
// Reserved just in case
|
||||
[StringLength(300, ErrorMessage = "Title cannot be longer than 300 characters")]
|
||||
public string? Title { get; set; }
|
||||
|
||||
public int MaxAttempts { get; set; } = 10;
|
||||
|
||||
public double MinScore { get; set; } = 0.6;
|
||||
|
||||
public List<InstructionTestQuestionDTO> Questions { get; set; } = new List<InstructionTestQuestionDTO>();
|
||||
|
||||
public InstructionTestScoreCalcMethod ScoreCalcMethod { get; set; } = InstructionTestScoreCalcMethod.MaxGrade;
|
||||
|
||||
}
|
||||
|
||||
26
Models/DTO/InstructionTestQuestionCreateDTO.cs
Normal file
26
Models/DTO/InstructionTestQuestionCreateDTO.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionTestQuestionCreateDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
public bool IsMultipleAnswer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Question will be displayed in the paragraph with the same order number.
|
||||
/// There can be multiple questions attached to the same paragraph.
|
||||
/// </summary>
|
||||
public int Order { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Must have question text")]
|
||||
public string Question { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Must have answer options")]
|
||||
public ICollection<string> Answers { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Must have correct answers")]
|
||||
public ICollection<int> CorrectAnswers { get; set; } = null!;
|
||||
}
|
||||
|
||||
25
Models/DTO/InstructionTestQuestionDTO.cs
Normal file
25
Models/DTO/InstructionTestQuestionDTO.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionTestQuestionDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
public bool IsMultipleAnswer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Question will be displayed in the paragraph with the same order number.
|
||||
/// There can be multiple questions attached to the same paragraph.
|
||||
/// </summary>
|
||||
public int Order { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Must have question text")]
|
||||
public string Question { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Must have answer options")]
|
||||
public ICollection<string> Answers { get; set; } = null!;
|
||||
|
||||
public ICollection<int>? CorrectAnswers { get; set; }
|
||||
}
|
||||
|
||||
12
Models/DTO/InstructionTestResultDTO.cs
Normal file
12
Models/DTO/InstructionTestResultDTO.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionTestResultDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
public long? InstructionTestId { get; set; }
|
||||
|
||||
public long? UserId { get; set; }
|
||||
|
||||
public int Score { get; set; }
|
||||
}
|
||||
12
Models/DTO/InstructionTestSubmissionDTO.cs
Normal file
12
Models/DTO/InstructionTestSubmissionDTO.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class InstructionTestSubmissionDTO
|
||||
{
|
||||
[Required(ErrorMessage = "InstructionTestId is required")]
|
||||
public int InstructionTestId { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Answers must be provided")]
|
||||
public List<List<int>> Answers { get; set; } = null!;
|
||||
}
|
||||
9
Models/DTO/LoginResultResponse.cs
Executable file
9
Models/DTO/LoginResultResponse.cs
Executable file
@@ -0,0 +1,9 @@
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class LoginResultResponse
|
||||
{
|
||||
public bool? RequiresTwoFactorAuth { get; set; }
|
||||
public bool Success { get; set; }
|
||||
public RefreshTokenDTO? Token { get; set; }
|
||||
public int? TwoFactorProvider { get; set; }
|
||||
}
|
||||
7
Models/DTO/RefreshTokenDTO.cs
Executable file
7
Models/DTO/RefreshTokenDTO.cs
Executable file
@@ -0,0 +1,7 @@
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class RefreshTokenDTO
|
||||
{
|
||||
public string AccessToken { get; set; } = null!;
|
||||
public string RefreshToken { get; set; } = null!;
|
||||
}
|
||||
7
Models/DTO/RightDTO.cs
Normal file
7
Models/DTO/RightDTO.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class RightDTO
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
7
Models/DTO/RoleDTO.cs
Normal file
7
Models/DTO/RoleDTO.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class RoleDTO
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
16
Models/DTO/TwoFactorDTO.cs
Executable file
16
Models/DTO/TwoFactorDTO.cs
Executable file
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class TwoFactorDTO
|
||||
{
|
||||
[Required]
|
||||
public int TwoFactorProvider { get; set; }
|
||||
[StringLength(50, MinimumLength = 3, ErrorMessage = "Username must be between 3 and 50 characters")]
|
||||
public string? Username { get; set; } = null!;
|
||||
|
||||
[Required]
|
||||
[StringLength(6, MinimumLength = 6, ErrorMessage = "Code must be 6 characters long")]
|
||||
public string Code { get; set; } = null!;
|
||||
public bool RememberMe { get; set; }
|
||||
}
|
||||
33
Models/DTO/UserProfileCreateDTO.cs
Normal file
33
Models/DTO/UserProfileCreateDTO.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using GamificationService.Utils.Enums;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class UserProfileCreateDTO
|
||||
{
|
||||
[Required(ErrorMessage = "Name is required")]
|
||||
[StringLength(100, ErrorMessage = "Name must be less than 100 characters")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Surname is required")]
|
||||
[StringLength(100, ErrorMessage = "Surname must be less than 100 characters")]
|
||||
public string Surname { get; set; } = null!;
|
||||
|
||||
[StringLength(50, ErrorMessage = "Patronymic must be less than 50 characters")]
|
||||
public string? Patronymic { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Birthdate is required")]
|
||||
public DateTime Birthdate { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Gender is required")]
|
||||
public Gender Gender { get; set; }
|
||||
|
||||
[EmailAddress(ErrorMessage = "Invalid email")]
|
||||
public string? ContactEmail { get; set; }
|
||||
|
||||
[Phone(ErrorMessage = "Invalid contact phone number")]
|
||||
public string? ContactPhone { get; set; }
|
||||
|
||||
[Url(ErrorMessage = "Invalid avatar url")]
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
37
Models/DTO/UserProfileDTO.cs
Executable file
37
Models/DTO/UserProfileDTO.cs
Executable file
@@ -0,0 +1,37 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using GamificationService.Utils.Enums;
|
||||
|
||||
namespace GamificationService.Models.DTO;
|
||||
|
||||
public class UserProfileDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
public long? UserId { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Name is required")]
|
||||
[StringLength(100, ErrorMessage = "Name must be less than 100 characters")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Surname is required")]
|
||||
[StringLength(100, ErrorMessage = "Surname must be less than 100 characters")]
|
||||
public string Surname { get; set; } = null!;
|
||||
|
||||
[StringLength(50, ErrorMessage = "Patronymic must be less than 50 characters")]
|
||||
public string? Patronymic { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Birthdate is required")]
|
||||
public DateTime Birthdate { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Gender is required")]
|
||||
public Gender Gender { get; set; }
|
||||
|
||||
[EmailAddress(ErrorMessage = "Invalid email")]
|
||||
public string? ContactEmail { get; set; }
|
||||
|
||||
[Phone(ErrorMessage = "Invalid contact phone number")]
|
||||
public string? ContactPhone { get; set; }
|
||||
|
||||
[Url(ErrorMessage = "Invalid avatar url")]
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
15
Models/Database/ApplicationRole.cs
Executable file
15
Models/Database/ApplicationRole.cs
Executable file
@@ -0,0 +1,15 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
|
||||
public class ApplicationRole : IdentityRole<long>
|
||||
{
|
||||
public ApplicationRole() : base() { }
|
||||
public ApplicationRole(string roleName) : base(roleName) { }
|
||||
public string? Description { get; set; }
|
||||
|
||||
public List<UserRole> UserRoles { get; set; } = new List<UserRole>();
|
||||
public List<RoleRight> RoleRights { get; set; } = new List<RoleRight>();
|
||||
}
|
||||
19
Models/Database/ApplicationUser.cs
Executable file
19
Models/Database/ApplicationUser.cs
Executable file
@@ -0,0 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using GamificationService.Utils;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class ApplicationUser : IdentityUser<long>
|
||||
{
|
||||
[Required(ErrorMessage = "Username is required")]
|
||||
[StringLength(50, ErrorMessage = "Username must be less than 50 characters")]
|
||||
public string Username { get; set; } = null!;
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
public string? TwoFactorSecret { get; set; }
|
||||
public bool EmailConfirmed { get; set; }
|
||||
public List<TwoFactorProvider> TwoFactorProviders { get; set; } = new List<TwoFactorProvider>();
|
||||
public List<RefreshToken> RefreshTokens { get; set; } = new List<RefreshToken>();
|
||||
|
||||
public List<UserRole> UserRoles { get; set; } = new List<UserRole>();
|
||||
}
|
||||
9
Models/Database/AuditableEntity.cs
Executable file
9
Models/Database/AuditableEntity.cs
Executable file
@@ -0,0 +1,9 @@
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class AuditableEntity
|
||||
{
|
||||
public DateTimeOffset CreatedOn { get; set; }
|
||||
public string CreatedBy { get; set; } = string.Empty;
|
||||
public DateTimeOffset UpdatedOn { get; set; }
|
||||
public string UpdatedBy { get; set; } = string.Empty;
|
||||
}
|
||||
29
Models/Database/Instruction.cs
Normal file
29
Models/Database/Instruction.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class Instruction
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Title is required")]
|
||||
public string Title { get; set; } = null!;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public long CategoryId { get; set; }
|
||||
[Required(ErrorMessage = "Category must be specified")]
|
||||
public InstructionCategory Category { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<InstructionParagraph> Paragraphs { get; set; }
|
||||
|
||||
public long? InstructionTestId { get; set; }
|
||||
public InstructionTest? InstructionTest { get; set; }
|
||||
|
||||
public DateTime? AssignDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime? DeadlineDate { get; set; }
|
||||
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
13
Models/Database/InstructionCategory.cs
Normal file
13
Models/Database/InstructionCategory.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class InstructionCategory
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Title is required")]
|
||||
public string Title { get; set; } = null!;
|
||||
}
|
||||
|
||||
21
Models/Database/InstructionParagraph.cs
Normal file
21
Models/Database/InstructionParagraph.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class InstructionParagraph
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
public long InstructionId { get; set; }
|
||||
[Required(ErrorMessage = "Must be linked to instruction")]
|
||||
|
||||
public int Order { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Paragraph text is required")]
|
||||
public string Text { get; set; } = null!;
|
||||
|
||||
public string? ImageUrl { get; set; }
|
||||
|
||||
public string? VideoUrl { get; set; }
|
||||
}
|
||||
23
Models/Database/InstructionTest.cs
Normal file
23
Models/Database/InstructionTest.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using GamificationService.Utils.Enums;
|
||||
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class InstructionTest
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
// Reserved just in case
|
||||
[MaxLength(300, ErrorMessage = "Title cannot be longer than 300 characters")]
|
||||
public string? Title { get; set; }
|
||||
|
||||
public virtual ICollection<InstructionTestQuestion> Questions { get; set; }
|
||||
|
||||
public int MaxAttempts { get; set; } = 10;
|
||||
|
||||
public double MinScore { get; set; } = 0.6;
|
||||
|
||||
public InstructionTestScoreCalcMethod ScoreCalcMethod { get; set; } = InstructionTestScoreCalcMethod.MaxGrade;
|
||||
|
||||
}
|
||||
26
Models/Database/InstructionTestQuestion.cs
Normal file
26
Models/Database/InstructionTestQuestion.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class InstructionTestQuestion
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Must be tied to an instruction test")]
|
||||
public InstructionTest InstructionTest { get; set; } = null!;
|
||||
public long InstructionTestId { get; set; }
|
||||
|
||||
public int Order { get; set; }
|
||||
|
||||
public bool IsMultipleAnswer { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Must have question text")]
|
||||
public string Question { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Must have answer options")]
|
||||
public ICollection<string> Answers { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Must have correct answer ids")]
|
||||
public ICollection<int> CorrectAnswers { get; set; } = null!;
|
||||
}
|
||||
20
Models/Database/InstructionTestResult.cs
Normal file
20
Models/Database/InstructionTestResult.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class InstructionTestResult
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
public long InstructionTestId { get; set; }
|
||||
[Required(ErrorMessage = "Instruction test is required")]
|
||||
public virtual InstructionTest InstructionTest { get; set; } = null!;
|
||||
|
||||
public long UserId { get; set; }
|
||||
[Required(ErrorMessage = "User is required")]
|
||||
public ApplicationUser User { get; set; } = null!;
|
||||
|
||||
[Range(0, 100, ErrorMessage = "Score must be a number from 0 to 100")]
|
||||
public int Score { get; set; }
|
||||
}
|
||||
25
Models/Database/RefreshToken.cs
Executable file
25
Models/Database/RefreshToken.cs
Executable file
@@ -0,0 +1,25 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class RefreshToken
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
public long UserId { get; set; }
|
||||
public ApplicationUser User { get; set; } = null!;
|
||||
|
||||
[Required]
|
||||
public string Token { get; set; } = null!;
|
||||
|
||||
public DateTime Expires { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public bool IsExpired => DateTime.UtcNow >= Expires;
|
||||
|
||||
public bool IsRevoked { get; set; }
|
||||
public string? RevokedByIp { get; set; }
|
||||
public DateTime? RevokedOn { get; set; }
|
||||
|
||||
public bool IsActive => !IsRevoked && !IsExpired;
|
||||
}
|
||||
18
Models/Database/Right.cs
Executable file
18
Models/Database/Right.cs
Executable file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class Right
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(50)]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[StringLength(100)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
public List<RoleRight> RoleRights { get; set; } = new List<RoleRight>();
|
||||
}
|
||||
10
Models/Database/RoleRight.cs
Executable file
10
Models/Database/RoleRight.cs
Executable file
@@ -0,0 +1,10 @@
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class RoleRight
|
||||
{
|
||||
public long RoleId { get; set; }
|
||||
public ApplicationRole Role { get; set; } = null!;
|
||||
|
||||
public long RightId { get; set; }
|
||||
public Right Right { get; set; } = null!;
|
||||
}
|
||||
40
Models/Database/UserProfile.cs
Executable file
40
Models/Database/UserProfile.cs
Executable file
@@ -0,0 +1,40 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using GamificationService.Utils.Enums;
|
||||
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class UserProfile
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "User is required")]
|
||||
public long UserId { get; set; }
|
||||
public ApplicationUser? User { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Name is required")]
|
||||
[StringLength(100, ErrorMessage = "Name must be less than 100 characters")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Surname is required")]
|
||||
[StringLength(100, ErrorMessage = "Surname must be less than 100 characters")]
|
||||
public string Surname { get; set; } = null!;
|
||||
|
||||
[StringLength(50, ErrorMessage = "Patronymic must be less than 50 characters")]
|
||||
public string? Patronymic { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Gender is required")]
|
||||
public Gender Gender { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Birthdate is required")]
|
||||
public DateTime Birthdate { get; set; }
|
||||
|
||||
[EmailAddress(ErrorMessage = "Invalid email")]
|
||||
public string? ContactEmail { get; set; }
|
||||
|
||||
[Phone(ErrorMessage = "Invalid contact phone number")]
|
||||
public string? ContactPhone { get; set; }
|
||||
|
||||
[Url(ErrorMessage = "Invalid avatar url")]
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
10
Models/Database/UserRole.cs
Executable file
10
Models/Database/UserRole.cs
Executable file
@@ -0,0 +1,10 @@
|
||||
namespace GamificationService.Models.Database;
|
||||
|
||||
public class UserRole
|
||||
{
|
||||
public long UserId { get; set; }
|
||||
public ApplicationUser User { get; set; } = null!;
|
||||
|
||||
public long RoleId { get; set; }
|
||||
public ApplicationRole Role { get; set; } = null!;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace GamificationService.Models.Messages.InstructionTests;
|
||||
|
||||
public class CreateInstructionTestRequest
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace GamificationService.Models.Messages.InstructionTests;
|
||||
|
||||
public class CreateInstructionTestResponse
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace GamificationService.Models.Messages.InstructionTests;
|
||||
|
||||
public class UpdateInstructionTestRequest
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace GamificationService.Models.Messages.InstructionTests;
|
||||
|
||||
public class UpdateInstructionTestResponse
|
||||
{
|
||||
|
||||
}
|
||||
37
Models/Messages/Instructions/CreateInstructionRequest.cs
Normal file
37
Models/Messages/Instructions/CreateInstructionRequest.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using GamificationService.Models.DTO;
|
||||
|
||||
namespace GamificationService.Models.Messages.Instructions;
|
||||
|
||||
public class CreateInstructionRequest
|
||||
{
|
||||
[Required(ErrorMessage = "Title is required")]
|
||||
public string Title { get; set; } = null!;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Paragraphs are required")]
|
||||
public List<InstructionParagraphCreateDTO> Paragraphs { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Category id is required")]
|
||||
public long CategoryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If AssignDate is set, the instruction will be automatically enabled
|
||||
/// when the date is reached. If it's not set, the test will automatically
|
||||
/// obtain the current date as its AssignDate as soon as the instruction
|
||||
/// will be enabled by the IsEnabled parameter.
|
||||
/// </summary>
|
||||
public DateTime? AssignDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When deadline is reached, no more submissions are allowed for this instruction.
|
||||
/// </summary>
|
||||
public DateTime? DeadlineDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Disabled instructions cannot be seen by users.
|
||||
/// Tests for such instructions cannot be submitted either.
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = false;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace GamificationService.Models.Messages.Instructions;
|
||||
|
||||
public class CreateInstructionResponse
|
||||
{
|
||||
|
||||
}
|
||||
40
Models/Messages/Instructions/UpdateInstructionRequest.cs
Normal file
40
Models/Messages/Instructions/UpdateInstructionRequest.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using GamificationService.Models.DTO;
|
||||
|
||||
namespace GamificationService.Models.Messages.Instructions;
|
||||
|
||||
public class UpdateInstructionRequest
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Title is required")]
|
||||
public string Title { get; set; } = null!;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Paragraphs are required")]
|
||||
public List<InstructionParagraphCreateDTO> Paragraphs { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Category id is required")]
|
||||
public long CategoryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If AssignDate is set, the instruction will be automatically enabled
|
||||
/// when the date is reached. If it's not set, the test will automatically
|
||||
/// obtain the current date as its AssignDate as soon as the instruction
|
||||
/// will be enabled by the IsEnabled parameter.
|
||||
/// </summary>
|
||||
public DateTime? AssignDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When deadline is reached, no more submissions are allowed for this instruction.
|
||||
/// </summary>
|
||||
public DateTime? DeadlineDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Disabled instructions cannot be seen by users.
|
||||
/// Tests for such instructions cannot be submitted either.
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace GamificationService.Models.Messages.Instructions;
|
||||
|
||||
public class UpdateInstructionResponse
|
||||
{
|
||||
|
||||
}
|
||||
6
Models/Messages/UserProfiles/CreateUserProfileRequest.cs
Normal file
6
Models/Messages/UserProfiles/CreateUserProfileRequest.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace GamificationService.Models.Messages.UserProfiles;
|
||||
|
||||
public class CreateUserProfileRequest
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace GamificationService.Models.Messages.UserProfiles;
|
||||
|
||||
public class CreateUserProfileResponse
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
6
Models/Messages/UserProfiles/UpdateUserProfileRequest.cs
Normal file
6
Models/Messages/UserProfiles/UpdateUserProfileRequest.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace GamificationService.Models.Messages.UserProfiles;
|
||||
|
||||
public class UpdateUserProfileRequest
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace GamificationService.Models.Messages.UserProfiles;
|
||||
|
||||
public class UpdateUserProfileResponse
|
||||
{
|
||||
|
||||
}
|
||||
7
Models/UserSession.cs
Executable file
7
Models/UserSession.cs
Executable file
@@ -0,0 +1,7 @@
|
||||
namespace GamificationService.Models;
|
||||
|
||||
public class UserSession
|
||||
{
|
||||
public string? Login { get; set; }
|
||||
public bool IsAuthenticated { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user