aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/Data
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-10-05 14:45:21 +0200
committerivarlovlie <git@ivarlovlie.no>2022-10-05 14:45:21 +0200
commitb7e39b59fd0fc7b5610ebff29035bf622079e0d8 (patch)
tree64be84ebbdac9f7ceced983390c53b10d575af5c /server/src/Data
parent2001c035fbb417ab0a3d42cfb04d17420bde4086 (diff)
downloadgreatoffice-b7e39b59fd0fc7b5610ebff29035bf622079e0d8.tar.xz
greatoffice-b7e39b59fd0fc7b5610ebff29035bf622079e0d8.zip
refactor: Change file structure
Diffstat (limited to 'server/src/Data')
-rw-r--r--server/src/Data/AppDbContext.cs51
-rw-r--r--server/src/Data/Database/ApiAccessToken.cs31
-rw-r--r--server/src/Data/Database/Base.cs15
-rw-r--r--server/src/Data/Database/BaseWithOwner.cs19
-rw-r--r--server/src/Data/Database/Customer.cs6
-rw-r--r--server/src/Data/Database/CustomerContact.cs12
-rw-r--r--server/src/Data/Database/CustomerEvent.cs7
-rw-r--r--server/src/Data/Database/ForgotPasswordRequest.cs23
-rw-r--r--server/src/Data/Database/Project.cs7
-rw-r--r--server/src/Data/Database/Tenant.cs11
-rw-r--r--server/src/Data/Database/TimeCategory.cs31
-rw-r--r--server/src/Data/Database/TimeEntry.cs45
-rw-r--r--server/src/Data/Database/TimeLabel.cs31
-rw-r--r--server/src/Data/Database/Todo.cs13
-rw-r--r--server/src/Data/Database/TodoComment.cs7
-rw-r--r--server/src/Data/Database/TodoLabel.cs8
-rw-r--r--server/src/Data/Database/TodoProject.cs16
-rw-r--r--server/src/Data/Database/TodoProjectAccessControl.cs11
-rw-r--r--server/src/Data/Database/TodoStatus.cs45
-rw-r--r--server/src/Data/Database/User.cs37
-rw-r--r--server/src/Data/Dtos/TimeQueryDto.cs34
-rw-r--r--server/src/Data/Dtos/UserArchiveDto.cs131
-rw-r--r--server/src/Data/Enums/TimeEntryQueryDuration.cs37
-rw-r--r--server/src/Data/Exceptions/ForgotPasswordRequestNotFoundException.cs21
-rw-r--r--server/src/Data/Exceptions/UserNotFoundException.cs19
-rw-r--r--server/src/Data/Models/ApiSpecDocument.cs9
-rw-r--r--server/src/Data/Models/AppPath.cs23
-rw-r--r--server/src/Data/Models/LoggedInUserModel.cs7
-rw-r--r--server/src/Data/Results/ErrorResult.cs12
-rw-r--r--server/src/Data/Static/AppClaims.cs8
-rw-r--r--server/src/Data/Static/AppConfiguration.cs58
-rw-r--r--server/src/Data/Static/AppConstants.cs12
-rw-r--r--server/src/Data/Static/AppDateTime.cs16
-rw-r--r--server/src/Data/Static/AppEnvironmentVariables.cs21
-rw-r--r--server/src/Data/Static/AppHeaders.cs7
-rw-r--r--server/src/Data/Static/AppPaths.cs17
-rw-r--r--server/src/Data/Static/JsonSettings.cs11
37 files changed, 0 insertions, 869 deletions
diff --git a/server/src/Data/AppDbContext.cs b/server/src/Data/AppDbContext.cs
deleted file mode 100644
index c970429..0000000
--- a/server/src/Data/AppDbContext.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore;
-
-namespace IOL.GreatOffice.Api.Data;
-
-public class AppDbContext : DbContext, IDataProtectionKeyContext
-{
- public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
- public DbSet<User> Users { get; set; }
- public DbSet<ForgotPasswordRequest> ForgotPasswordRequests { get; set; }
- public DbSet<TimeLabel> TimeLabels { get; set; }
- public DbSet<TimeEntry> TimeEntries { get; set; }
- public DbSet<TimeCategory> TimeCategories { get; set; }
- public DbSet<ApiAccessToken> AccessTokens { get; set; }
- public DbSet<Tenant> Tenants { get; set; }
- public DbSet<DataProtectionKey> DataProtectionKeys { get; set; }
-
- protected override void OnModelCreating(ModelBuilder modelBuilder) {
- modelBuilder.Entity<User>(e => {
- e.ToTable("users");
- });
-
- modelBuilder.Entity<ForgotPasswordRequest>(e => {
- e.HasOne(c => c.User);
- e.ToTable("forgot_password_requests");
- });
-
- modelBuilder.Entity<TimeCategory>(e => {
- e.ToTable("time_categories");
- });
-
- modelBuilder.Entity<TimeLabel>(e => {
- e.ToTable("time_labels");
- });
-
- modelBuilder.Entity<TimeEntry>(e => {
- e.HasOne(c => c.Category);
- e.HasMany(c => c.Labels);
- e.ToTable("time_entries");
- });
-
- modelBuilder.Entity<ApiAccessToken>(e => {
- e.ToTable("api_access_tokens");
- });
-
- modelBuilder.Entity<Tenant>(e => {
- e.ToTable("tenants");
- });
-
- base.OnModelCreating(modelBuilder);
- }
-}
diff --git a/server/src/Data/Database/ApiAccessToken.cs b/server/src/Data/Database/ApiAccessToken.cs
deleted file mode 100644
index 9582869..0000000
--- a/server/src/Data/Database/ApiAccessToken.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class ApiAccessToken : Base
-{
- public User User { get; set; }
- public DateTime ExpiryDate { get; set; }
- public bool AllowRead { get; set; }
- public bool AllowCreate { get; set; }
- public bool AllowUpdate { get; set; }
- public bool AllowDelete { get; set; }
- public bool HasExpired => ExpiryDate < AppDateTime.UtcNow;
- public ApiAccessTokenDto AsDto => new(this);
-
- public class ApiAccessTokenDto
- {
- public ApiAccessTokenDto(ApiAccessToken source) {
- ExpiryDate = source.ExpiryDate;
- AllowRead = source.AllowRead;
- AllowCreate = source.AllowCreate;
- AllowUpdate = source.AllowUpdate;
- AllowDelete = source.AllowDelete;
- }
-
- public DateTime ExpiryDate { get; set; }
- public bool AllowRead { get; set; }
- public bool AllowCreate { get; set; }
- public bool AllowUpdate { get; set; }
- public bool AllowDelete { get; set; }
- public bool HasExpired => ExpiryDate < AppDateTime.UtcNow;
- }
-} \ No newline at end of file
diff --git a/server/src/Data/Database/Base.cs b/server/src/Data/Database/Base.cs
deleted file mode 100644
index ae9efa2..0000000
--- a/server/src/Data/Database/Base.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class Base
-{
- protected Base() {
- Id = Guid.NewGuid();
- CreatedAt = AppDateTime.UtcNow;
- }
-
- public Guid Id { get; init; }
- public DateTime CreatedAt { get; init; }
- public DateTime? ModifiedAt { get; private set; }
- public bool Deleted { get; set; }
- public void Modified() => ModifiedAt = AppDateTime.UtcNow;
-} \ No newline at end of file
diff --git a/server/src/Data/Database/BaseWithOwner.cs b/server/src/Data/Database/BaseWithOwner.cs
deleted file mode 100644
index 1eb99f4..0000000
--- a/server/src/Data/Database/BaseWithOwner.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-/// <summary>
-/// Base class for all entities.
-/// </summary>
-public class BaseWithOwner : Base
-{
- protected BaseWithOwner() { }
-
- protected BaseWithOwner(Guid userId) {
- UserId = userId;
- }
-
- public Guid? UserId { get; set; }
- public Guid? TenantId { get; init; }
- public Guid? ModifiedById { get; init; }
- public Guid? CreatedById { get; init; }
- public Guid? DeletedById { get; init; }
-} \ No newline at end of file
diff --git a/server/src/Data/Database/Customer.cs b/server/src/Data/Database/Customer.cs
deleted file mode 100644
index c6b06a4..0000000
--- a/server/src/Data/Database/Customer.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class Customer : BaseWithOwner
-{
- public string Name { get; set; }
-} \ No newline at end of file
diff --git a/server/src/Data/Database/CustomerContact.cs b/server/src/Data/Database/CustomerContact.cs
deleted file mode 100644
index f5a951d..0000000
--- a/server/src/Data/Database/CustomerContact.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class CustomerContact : BaseWithOwner
-{
- public Customer Customer { get; set; }
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public string Email { get; set; }
- public string Phone { get; set; }
- public string WorkTitle { get; set; }
- public string Note { get; set; }
-}
diff --git a/server/src/Data/Database/CustomerEvent.cs b/server/src/Data/Database/CustomerEvent.cs
deleted file mode 100644
index da3e3ed..0000000
--- a/server/src/Data/Database/CustomerEvent.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class CustomerEvent : BaseWithOwner
-{
- public Customer Customer { get; set; }
- public string Name { get; set; }
-}
diff --git a/server/src/Data/Database/ForgotPasswordRequest.cs b/server/src/Data/Database/ForgotPasswordRequest.cs
deleted file mode 100644
index 1510a35..0000000
--- a/server/src/Data/Database/ForgotPasswordRequest.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class ForgotPasswordRequest
-{
- public ForgotPasswordRequest() { }
-
- public ForgotPasswordRequest(User user) {
- CreatedAt = AppDateTime.UtcNow;
- Id = Guid.NewGuid();
- User = user;
- }
-
- public Guid Id { get; set; }
- public Guid UserId { get; set; }
- public User User { get; set; }
- public DateTime CreatedAt { get; set; }
-
- [NotMapped]
- public DateTime ExpirationDate => CreatedAt.AddMinutes(15);
-
- [NotMapped]
- public bool IsExpired => DateTime.Compare(ExpirationDate, AppDateTime.UtcNow) < 0;
-}
diff --git a/server/src/Data/Database/Project.cs b/server/src/Data/Database/Project.cs
deleted file mode 100644
index 7e694ee..0000000
--- a/server/src/Data/Database/Project.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class Project : BaseWithOwner
-{
- public string Name { get; set; }
- public Guid? CustomerId { get; set; }
-}
diff --git a/server/src/Data/Database/Tenant.cs b/server/src/Data/Database/Tenant.cs
deleted file mode 100644
index b185c7a..0000000
--- a/server/src/Data/Database/Tenant.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class Tenant : BaseWithOwner
-{
- public string Name { get; set; }
- public string Description { get; set; }
- public string ContactEmail { get; set; }
- public Guid MasterUserId { get; set; }
- public string MasterUserPassword { get; set; }
- public ICollection<User> Users { get; set; }
-}
diff --git a/server/src/Data/Database/TimeCategory.cs b/server/src/Data/Database/TimeCategory.cs
deleted file mode 100644
index 69c6957..0000000
--- a/server/src/Data/Database/TimeCategory.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class TimeCategory : BaseWithOwner
-{
- public TimeCategory() { }
- public TimeCategory(Guid userId) : base(userId) { }
- public string Name { get; set; }
- public string Color { get; set; }
- public TimeCategoryDto AsDto => new(this);
-
- public class TimeCategoryDto
- {
- public TimeCategoryDto() { }
-
- public TimeCategoryDto(TimeCategory sourceEntry = default) {
- if (sourceEntry == default) {
- return;
- }
-
- Id = sourceEntry.Id;
- ModifiedAt = sourceEntry.ModifiedAt;
- Name = sourceEntry.Name;
- Color = sourceEntry.Color;
- }
-
- public Guid Id { get; set; }
- public DateTime? ModifiedAt { get; set; }
- public string Name { get; set; }
- public string Color { get; set; }
- }
-}
diff --git a/server/src/Data/Database/TimeEntry.cs b/server/src/Data/Database/TimeEntry.cs
deleted file mode 100644
index 46c62e1..0000000
--- a/server/src/Data/Database/TimeEntry.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class TimeEntry : BaseWithOwner
-{
- public TimeEntry() { }
- public TimeEntry(Guid userId) : base(userId) { }
- public DateTime Start { get; set; }
- public DateTime Stop { get; set; }
- public string Description { get; set; }
- public ICollection<TimeLabel> Labels { get; set; }
- public TimeCategory Category { get; set; }
- public TimeEntryDto AsDto => new(this);
-
- public class TimeEntryDto
- {
- public TimeEntryDto() { }
-
- public TimeEntryDto(TimeEntry sourceEntry = default) {
- if (sourceEntry == default) {
- return;
- }
-
- Id = sourceEntry.Id;
- ModifiedAt = sourceEntry.ModifiedAt;
- Stop = sourceEntry.Stop;
- Start = sourceEntry.Start;
- Description = sourceEntry.Description;
- if (sourceEntry.Labels != default) {
- Labels = sourceEntry.Labels
- .Select(t => t.AsDto)
- .ToList();
- }
-
- Category = sourceEntry.Category.AsDto;
- }
-
- public Guid? Id { get; set; }
- public DateTime? ModifiedAt { get; set; }
- public DateTime Start { get; set; }
- public DateTime Stop { get; set; }
- public string Description { get; set; }
- public List<TimeLabel.TimeLabelDto> Labels { get; set; }
- public TimeCategory.TimeCategoryDto Category { get; set; }
- }
-}
diff --git a/server/src/Data/Database/TimeLabel.cs b/server/src/Data/Database/TimeLabel.cs
deleted file mode 100644
index 55e20b0..0000000
--- a/server/src/Data/Database/TimeLabel.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class TimeLabel : BaseWithOwner
-{
- public TimeLabel() { }
- public TimeLabel(Guid userId) : base(userId) { }
- public string Name { get; set; }
- public string Color { get; set; }
-
- [NotMapped]
- public TimeLabelDto AsDto => new(this);
-
- public class TimeLabelDto
- {
- public TimeLabelDto() { }
-
- public TimeLabelDto(TimeLabel sourceEntry) {
- Id = sourceEntry.Id;
- CreatedAt = sourceEntry.CreatedAt;
- ModifiedAt = sourceEntry.ModifiedAt;
- Name = sourceEntry.Name;
- Color = sourceEntry.Color;
- }
-
- public Guid Id { get; set; }
- public DateTime CreatedAt { get; set; }
- public DateTime? ModifiedAt { get; set; }
- public string Name { get; set; }
- public string Color { get; set; }
- }
-}
diff --git a/server/src/Data/Database/Todo.cs b/server/src/Data/Database/Todo.cs
deleted file mode 100644
index 5fe3c9a..0000000
--- a/server/src/Data/Database/Todo.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class Todo : BaseWithOwner
-{
- public int PublicId { get; set; }
- public TodoStatus Status { get; set; }
- public TodoProject Project { get; set; }
- public Guid? AssignedUserId { get; set; }
- public string Title { get; set; }
- public string Description { get; set; }
- public ICollection<TodoLabel> Labels { get; set; }
- public ICollection<TodoComment> Comments { get; set; }
-}
diff --git a/server/src/Data/Database/TodoComment.cs b/server/src/Data/Database/TodoComment.cs
deleted file mode 100644
index 44dcbed..0000000
--- a/server/src/Data/Database/TodoComment.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class TodoComment : BaseWithOwner
-{
- public string Value { get; set; }
- public Todo Todo { get; set; }
-}
diff --git a/server/src/Data/Database/TodoLabel.cs b/server/src/Data/Database/TodoLabel.cs
deleted file mode 100644
index 7753ade..0000000
--- a/server/src/Data/Database/TodoLabel.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class TodoLabel : BaseWithOwner
-{
- public string Name { get; set; }
- public string Color { get; set; }
- public Todo Todo { get; set; }
-}
diff --git a/server/src/Data/Database/TodoProject.cs b/server/src/Data/Database/TodoProject.cs
deleted file mode 100644
index 0a4a7be..0000000
--- a/server/src/Data/Database/TodoProject.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class TodoProject : BaseWithOwner
-{
- public string Name { get; set; }
- public TodoVisibility Visibility { get; set; }
- public Guid? ProjectId { get; set; }
-}
-
-public enum TodoVisibility
-{
- PRIVATE = 0,
- UNLISTED = 1,
- TENANT_WIDE = 2,
- PUBLIC = 3,
-}
diff --git a/server/src/Data/Database/TodoProjectAccessControl.cs b/server/src/Data/Database/TodoProjectAccessControl.cs
deleted file mode 100644
index 964f831..0000000
--- a/server/src/Data/Database/TodoProjectAccessControl.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class TodoProjectAccessControl
-{
- public TodoProject Project { get; set; }
- public Guid? UserId { get; set; }
- public bool Browse { get; set; }
- public bool Submit { get; set; }
- public bool Comment { get; set; }
- public bool Edit { get; set; }
-}
diff --git a/server/src/Data/Database/TodoStatus.cs b/server/src/Data/Database/TodoStatus.cs
deleted file mode 100644
index 416212d..0000000
--- a/server/src/Data/Database/TodoStatus.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class TodoStatus : BaseWithOwner
-{
- public string Name { get; set; }
- public string Color { get; set; }
- public Todo Todo { get; set; }
-
- public static List<TodoStatus> GetDefaultStatusSetForTenant(Guid tenantId) {
- return new List<TodoStatus>() {
- new() {
- Name = "Reported",
- TenantId = tenantId
- },
- new() {
- Name = "Resolved",
- TenantId = tenantId
- },
- new() {
- Name = "Fixed",
- TenantId = tenantId
- },
- new() {
- Name = "Implemented",
- TenantId = tenantId
- },
- new() {
- Name = "Won't fix",
- TenantId = tenantId
- },
- new() {
- Name = "By design",
- TenantId = tenantId
- },
- new() {
- Name = "Invalid",
- TenantId = tenantId
- },
- new() {
- Name = "Duplicate",
- TenantId = tenantId
- }
- };
- }
-}
diff --git a/server/src/Data/Database/User.cs b/server/src/Data/Database/User.cs
deleted file mode 100644
index 9db5d35..0000000
--- a/server/src/Data/Database/User.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Database;
-
-public class User : Base
-{
- public User() { }
-
- public User(string username) {
- Username = username;
- }
-
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public string Email { get; set; }
- public string Username { get; set; }
- public string Password { get; set; }
- public ICollection<Tenant> Tenants { get; set; }
-
- public string DisplayName() {
- if (FirstName.HasValue() && LastName.HasValue()) return FirstName + " " + LastName;
- return FirstName.HasValue() ? FirstName : Email;
- }
-
- public void HashAndSetPassword(string password) {
- Password = PasswordHelper.HashPassword(password);
- }
-
- public bool VerifyPassword(string password) {
- return PasswordHelper.Verify(password, Password);
- }
-
- public IEnumerable<Claim> DefaultClaims() {
- return new Claim[] {
- new(AppClaims.USER_ID, Id.ToString()),
- new(AppClaims.NAME, Username),
- };
- }
-} \ No newline at end of file
diff --git a/server/src/Data/Dtos/TimeQueryDto.cs b/server/src/Data/Dtos/TimeQueryDto.cs
deleted file mode 100644
index f734cb1..0000000
--- a/server/src/Data/Dtos/TimeQueryDto.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-
-namespace IOL.GreatOffice.Api.Data.Dtos;
-
-public class TimeQueryDto
-{
- public TimeQueryDto() {
- Results = new List<TimeEntry.TimeEntryDto>();
- }
-
- /// <summary>
- /// List of entries.
- /// </summary>
- public List<TimeEntry.TimeEntryDto> Results { get; set; }
-
- /// <summary>
- /// Curren page.
- /// </summary>
- public int Page { get; set; }
-
- /// <summary>
- /// Maximum count of entries in a page.
- /// </summary>
- public int PageSize { get; set; }
-
- /// <summary>
- /// Total count of entries.
- /// </summary>
- public int TotalSize { get; set; }
-
- /// <summary>
- /// Total count of pages.
- /// </summary>
- public int TotalPageCount { get; set; }
-}
diff --git a/server/src/Data/Dtos/UserArchiveDto.cs b/server/src/Data/Dtos/UserArchiveDto.cs
deleted file mode 100644
index 42e0600..0000000
--- a/server/src/Data/Dtos/UserArchiveDto.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-
-namespace IOL.GreatOffice.Api.Data.Dtos;
-
-/// <summary>
-/// Represents a user archive as it is provided to users.
-/// </summary>
-public class UserArchiveDto
-{
- /// <inheritdoc cref="UserArchiveDto"/>
- public UserArchiveDto(User user) {
- Meta = new MetaDto {
- GeneratedAt = AppDateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ")
- };
- User = new UserDto(user);
- Entries = new List<EntryDto>();
- }
-
- /// <summary>
- /// Metadata for the user archive.
- /// </summary>
- public MetaDto Meta { get; }
-
- /// <summary>
- /// Relevant user data for the archive.
- /// </summary>
- public UserDto User { get; }
-
- /// <summary>
- /// List of entries that the user has created.
- /// </summary>
- public List<EntryDto> Entries { get; }
-
- public void CountEntries() {
- Meta.EntryCount = Entries.Count;
- }
-
- /// <summary>
- /// Represents a time entry in the data archive.
- /// </summary>
- public class EntryDto
- {
- public string CreatedAt { get; init; }
-
- [JsonIgnore]
- public DateTime StartDateTime { get; init; }
-
- /// <summary>
- /// ISO 8601 string of the UTC date the time entry started.
- /// </summary>
- public string Start => StartDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ");
-
- [JsonIgnore]
- public DateTime StopDateTime { get; init; }
-
- /// <summary>
- /// ISO 8601 string of the UTC date the time entry stopped.
- /// </summary>
- public string Stop => StopDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ");
-
- /// <summary>
- /// Total amount of minutes elapsed from start to stop on this time entry.
- /// </summary>
- public double Minutes => StopDateTime.Subtract(StartDateTime).TotalMinutes;
-
- public string Description { get; init; }
-
- /// <summary>
- /// Archive spesific category for this time entry.
- /// </summary>
- public CategoryDto Category { get; init; }
-
- /// <summary>
- /// Archive spesific list of labels for this time entry.
- /// </summary>
- public List<LabelDto> Labels { get; init; }
- }
-
- /// <summary>
- /// Time entry category as it is written to the user archive.
- /// </summary>
- public class CategoryDto
- {
- public string Name { get; init; }
- public string Color { get; init; }
- }
-
- /// <summary>
- /// Time entry label as it is written to the user archive.
- /// </summary>
- public class LabelDto
- {
- public string Name { get; init; }
- public string Color { get; init; }
- }
-
-
- /// <summary>
- /// Represents the user who this archive's data is based on.
- /// </summary>
- public class UserDto
- {
- /// <inheritdoc cref="UserDto"/>
- public UserDto(User user) {
- Username = user.Username;
- CreatedAt = user.CreatedAt;
- }
-
- /// <summary>
- /// UTC date this user was created.
- /// </summary>
- public DateTime CreatedAt { get; }
-
- public string Username { get; }
- }
-
- /// <summary>
- /// Represents the meta object which contains metdata for this archive.
- /// </summary>
- public class MetaDto
- {
- /// <summary>
- /// ISO 8601 UTC date string for when this archive was created.
- /// </summary>
- public string GeneratedAt { get; init; }
-
- /// <summary>
- /// Amount of entries in the archive.
- /// </summary>
- public int EntryCount { get; set; }
- }
-}
diff --git a/server/src/Data/Enums/TimeEntryQueryDuration.cs b/server/src/Data/Enums/TimeEntryQueryDuration.cs
deleted file mode 100644
index af70ca6..0000000
--- a/server/src/Data/Enums/TimeEntryQueryDuration.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Enums;
-
-/// <summary>
-/// Specify a duration filter for time entry queries.
-/// </summary>
-public enum TimeEntryQueryDuration
-{
- /// <summary>
- /// Only query entries created today.
- /// </summary>
- TODAY = 0,
-
- /// <summary>
- /// Only query entries created this week.
- /// </summary>
- THIS_WEEK = 1,
-
- /// <summary>
- /// Only query entries created this month.
- /// </summary>
- THIS_MONTH = 2,
-
- /// <summary>
- /// Only query entries created this year.
- /// </summary>
- THIS_YEAR = 3,
-
- /// <summary>
- /// Only query entries created at a spesific date.
- /// </summary>
- SPECIFIC_DATE = 4,
-
- /// <summary>
- /// Only query entries created between two dates.
- /// </summary>
- DATE_RANGE = 5,
-}
diff --git a/server/src/Data/Exceptions/ForgotPasswordRequestNotFoundException.cs b/server/src/Data/Exceptions/ForgotPasswordRequestNotFoundException.cs
deleted file mode 100644
index 02474b4..0000000
--- a/server/src/Data/Exceptions/ForgotPasswordRequestNotFoundException.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Exceptions;
-
-[Serializable]
-public class ForgotPasswordRequestNotFoundException : Exception
-{
- //
- // For guidelines regarding the creation of new exception types, see
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
- // and
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
- //
-
- public ForgotPasswordRequestNotFoundException() { }
- public ForgotPasswordRequestNotFoundException(string message) : base(message) { }
- public ForgotPasswordRequestNotFoundException(string message, Exception inner) : base(message, inner) { }
-
- protected ForgotPasswordRequestNotFoundException(
- SerializationInfo info,
- StreamingContext context
- ) : base(info, context) { }
-}
diff --git a/server/src/Data/Exceptions/UserNotFoundException.cs b/server/src/Data/Exceptions/UserNotFoundException.cs
deleted file mode 100644
index 06b57a9..0000000
--- a/server/src/Data/Exceptions/UserNotFoundException.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Exceptions;
-
-[Serializable]
-public class UserNotFoundException : Exception
-{
- // For guidelines regarding the creation of new exception types, see
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
- // and
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
-
- public UserNotFoundException() { }
- public UserNotFoundException(string message) : base(message) { }
- public UserNotFoundException(string message, Exception inner) : base(message, inner) { }
-
- protected UserNotFoundException(
- SerializationInfo info,
- StreamingContext context
- ) : base(info, context) { }
-}
diff --git a/server/src/Data/Models/ApiSpecDocument.cs b/server/src/Data/Models/ApiSpecDocument.cs
deleted file mode 100644
index 1c7d936..0000000
--- a/server/src/Data/Models/ApiSpecDocument.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Models;
-
-public class ApiSpecDocument
-{
- public string VersionName { get; set; }
- public string SwaggerPath { get; set; }
- public ApiVersion Version { get; set; }
- public OpenApiInfo OpenApiInfo { get; set; }
-}
diff --git a/server/src/Data/Models/AppPath.cs b/server/src/Data/Models/AppPath.cs
deleted file mode 100644
index e47e48c..0000000
--- a/server/src/Data/Models/AppPath.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Models;
-
-public sealed record AppPath
-{
- public string HostPath { get; init; }
- public string WebPath { get; init; }
-
- public string GetHostPathForFilename(string filename, string fallback = "") {
- if (filename.IsNullOrWhiteSpace()) {
- return fallback;
- }
-
- return Path.Combine(HostPath, filename);
- }
-
- public string GetWebPathForFilename(string filename, string fallback = "") {
- if (filename.IsNullOrWhiteSpace()) {
- return fallback;
- }
-
- return Path.Combine(WebPath, filename);
- }
-}
diff --git a/server/src/Data/Models/LoggedInUserModel.cs b/server/src/Data/Models/LoggedInUserModel.cs
deleted file mode 100644
index d802b77..0000000
--- a/server/src/Data/Models/LoggedInUserModel.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Models;
-
-public class LoggedInUserModel
-{
- public Guid Id { get; set; }
- public string Username { get; set; }
-}
diff --git a/server/src/Data/Results/ErrorResult.cs b/server/src/Data/Results/ErrorResult.cs
deleted file mode 100644
index fd2fd6a..0000000
--- a/server/src/Data/Results/ErrorResult.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Results;
-
-public class ErrorResult
-{
- public ErrorResult(string title = default, string text = default) {
- Title = title;
- Text = text;
- }
-
- public string Title { get; set; }
- public string Text { get; set; }
-}
diff --git a/server/src/Data/Static/AppClaims.cs b/server/src/Data/Static/AppClaims.cs
deleted file mode 100644
index 8b6d3a8..0000000
--- a/server/src/Data/Static/AppClaims.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Static;
-
-public static class AppClaims
-{
- public const string USER_ID = "user_id";
- public const string NAME = "name";
- public const string GITHUB_ACCESS_TOKEN = "";
-}
diff --git a/server/src/Data/Static/AppConfiguration.cs b/server/src/Data/Static/AppConfiguration.cs
deleted file mode 100644
index 4ee7a8e..0000000
--- a/server/src/Data/Static/AppConfiguration.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System.Security.Cryptography.X509Certificates;
-
-namespace IOL.GreatOffice.Api.Data.Static;
-
-public class AppConfiguration
-{
- public string DB_HOST { get; set; }
- public string DB_PORT { get; set; }
- public string DB_USER { get; set; }
- public string DB_PASSWORD { get; set; }
- public string DB_NAME { get; set; }
- public string QUARTZ_DB_HOST { get; set; }
- public string QUARTZ_DB_PORT { get; set; }
- public string QUARTZ_DB_USER { get; set; }
- public string QUARTZ_DB_PASSWORD { get; set; }
- public string QUARTZ_DB_NAME { get; set; }
- public string SEQ_API_KEY { get; set; }
- public string SEQ_API_URL { get; set; }
- public string SMTP_HOST { get; set; }
- public string SMTP_PORT { get; set; }
- public string SMTP_USER { get; set; }
- public string SMTP_PASSWORD { get; set; }
- public string EMAIL_FROM_ADDRESS { get; set; }
- public string EMAIL_FROM_DISPLAY_NAME { get; set; }
- public string PORTAL_URL { get; set; }
- public string GITHUB_CLIENT_ID { get; set; }
- public string GITHUB_CLIENT_SECRET { get; set; }
- public string APP_AES_KEY { get; set; }
- public string APP_CERT { get; set; }
-
- public X509Certificate2 CERT1() => new (Convert.FromBase64String(APP_CERT));
-
- public object GetPublicVersion() {
- return new {
- DB_HOST,
- DB_PORT,
- DB_USER,
- DB_PASSWORD = DB_PASSWORD.Obfuscate() ?? "",
- QUARTZ_DB_HOST,
- QUARTZ_DB_PORT,
- QUARTZ_DB_USER,
- QUARTZ_DB_PASSWORD = QUARTZ_DB_PASSWORD.Obfuscate() ?? "",
- SEQ_API_KEY = SEQ_API_KEY.Obfuscate() ?? "",
- SEQ_API_URL,
- SMTP_HOST,
- SMTP_PORT,
- SMTP_USER = SMTP_USER.Obfuscate() ?? "",
- SMTP_PASSWORD = SMTP_PASSWORD.Obfuscate() ?? "",
- EMAIL_FROM_ADDRESS,
- EMAIL_FROM_DISPLAY_NAME,
- PORTAL_URL,
- GITHUB_CLIENT_ID = GITHUB_CLIENT_ID.Obfuscate() ?? "",
- GITHUB_CLIENT_SECRET = GITHUB_CLIENT_SECRET.Obfuscate() ?? "",
- APP_AES_KEY = APP_AES_KEY.Obfuscate() ?? "",
- CERT1 = CERT1().PublicKey.Oid.FriendlyName
- };
- }
-}
diff --git a/server/src/Data/Static/AppConstants.cs b/server/src/Data/Static/AppConstants.cs
deleted file mode 100644
index 461317b..0000000
--- a/server/src/Data/Static/AppConstants.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Static;
-
-public static class AppConstants
-{
- public const string API_NAME = "Great Office API";
- public const string BASIC_AUTH_SCHEME = "BasicAuthenticationScheme";
- public const string TOKEN_ALLOW_READ = "TOKEN_ALLOW_READ";
- public const string TOKEN_ALLOW_CREATE = "TOKEN_ALLOW_CREATE";
- public const string TOKEN_ALLOW_UPDATE = "TOKEN_ALLOW_UPDATE";
- public const string TOKEN_ALLOW_DELETE = "TOKEN_ALLOW_DELETE";
- public const string VAULT_CACHE_KEY = "VAULT_CACHE_KEY";
-}
diff --git a/server/src/Data/Static/AppDateTime.cs b/server/src/Data/Static/AppDateTime.cs
deleted file mode 100644
index 880d2a8..0000000
--- a/server/src/Data/Static/AppDateTime.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Static;
-
-public static class AppDateTime
-{
- private static DateTime? dateTime;
-
- public static DateTime UtcNow => dateTime ?? DateTime.UtcNow;
-
- public static void Set(DateTime setDateTime) {
- dateTime = setDateTime;
- }
-
- public static void Reset() {
- dateTime = null;
- }
-}
diff --git a/server/src/Data/Static/AppEnvironmentVariables.cs b/server/src/Data/Static/AppEnvironmentVariables.cs
deleted file mode 100644
index c3f821d..0000000
--- a/server/src/Data/Static/AppEnvironmentVariables.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Static;
-
-public static class AppEnvironmentVariables
-{
- /// <summary>
- /// An access token that can be used to access the Hashicorp Vault instance that is available at VAULT_URL
- /// </summary>
- public const string VAULT_TOKEN = "VAULT_TOKEN";
- /// <summary>
- /// An url pointing to the Hashicorp Vault instance the app should use
- /// </summary>
- public const string VAULT_URL = "VAULT_URL";
- /// <summary>
- /// The duration of which to keep a local cached version of the configuration
- /// </summary>
- public const string VAULT_CACHE_TTL = "VAULT_CACHE_TTL";
- /// <summary>
- /// The vault key name for the main configuration json object, described by <see cref="AppConfiguration"/>
- /// </summary>
- public const string MAIN_CONFIG_SHEET = "MAIN_CONFIG_SHEET";
-}
diff --git a/server/src/Data/Static/AppHeaders.cs b/server/src/Data/Static/AppHeaders.cs
deleted file mode 100644
index 7912418..0000000
--- a/server/src/Data/Static/AppHeaders.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Static;
-
-public static class AppHeaders
-{
- public const string BROWSER_TIME_ZONE = "X-TimeZone";
- public const string VAULT_TOKEN = "X-Vault-Token";
-}
diff --git a/server/src/Data/Static/AppPaths.cs b/server/src/Data/Static/AppPaths.cs
deleted file mode 100644
index a24f5af..0000000
--- a/server/src/Data/Static/AppPaths.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-
-namespace IOL.GreatOffice.Api.Data.Static;
-
-public static class AppPaths
-{
- public static AppPath AppData => new() {
- HostPath = Path.Combine(Directory.GetCurrentDirectory(), "AppData")
- };
-
- public static AppPath DataProtectionKeys => new() {
- HostPath = Path.Combine(Directory.GetCurrentDirectory(), "AppData", "dp-keys")
- };
-
- public static AppPath Frontend => new() {
- HostPath = Path.Combine(Directory.GetCurrentDirectory(), "Frontend")
- };
-}
diff --git a/server/src/Data/Static/JsonSettings.cs b/server/src/Data/Static/JsonSettings.cs
deleted file mode 100644
index a163c11..0000000
--- a/server/src/Data/Static/JsonSettings.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace IOL.GreatOffice.Api.Data.Static;
-
-public static class JsonSettings
-{
- public static Action<JsonOptions> Default { get; } = options => {
- options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
- options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
- options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString;
- options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
- };
-}