From e7ca87f25dae2f806469043ee556d4790d9ebcae Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 10 Mar 2020 03:04:23 +0800 Subject: ... --- .../ErrorResponseCodeGenerator.csproj | 2 +- ErrorResponseCodeGenerator/Program.cs | 2 +- Timeline.ErrorCodes/ErrorCodes.cs | 2 +- Timeline.ErrorCodes/Timeline.ErrorCodes.csproj | 7 - Timeline.ErrorCodes/TimelineApp.ErrorCodes.csproj | 7 + Timeline.Tests/ErrorCodeTest.cs | 4 +- .../Helpers/AsyncFunctionAssertionsExtensions.cs | 2 +- Timeline.Tests/Helpers/HttpClientExtensions.cs | 2 +- Timeline.Tests/Helpers/ImageHelper.cs | 2 +- Timeline.Tests/Helpers/ParameterInfoAssertions.cs | 2 +- Timeline.Tests/Helpers/ReflectionHelper.cs | 2 +- Timeline.Tests/Helpers/ResponseAssertions.cs | 6 +- Timeline.Tests/Helpers/TestApplication.cs | 6 +- .../IntegratedTests/AuthorizationTest.cs | 4 +- .../IntegratedTests/IntegratedTestBase.cs | 8 +- .../IntegratedTests/PersonalTimelineTest.cs | 6 +- Timeline.Tests/IntegratedTests/TimelineTest.cs | 6 +- Timeline.Tests/IntegratedTests/TokenTest.cs | 8 +- Timeline.Tests/IntegratedTests/UserAvatarTest.cs | 8 +- Timeline.Tests/IntegratedTests/UserTest.cs | 6 +- Timeline.Tests/PasswordGenerator.cs | 4 +- Timeline.Tests/Timeline.Tests.csproj | 33 -- Timeline.Tests/TimelineApp.Tests.csproj | 33 ++ Timeline.Tests/UsernameValidatorUnitTest.cs | 6 +- Timeline.sln | 8 +- Timeline/Auth/Attribute.cs | 4 +- Timeline/Auth/MyAuthenticationHandler.cs | 6 +- Timeline/Auth/PrincipalExtensions.cs | 4 +- Timeline/Configs/JwtConfiguration.cs | 2 +- Timeline/Controllers/ControllerAuthExtensions.cs | 6 +- Timeline/Controllers/PersonalTimelineController.cs | 10 +- .../Controllers/Testing/TestingAuthController.cs | 4 +- Timeline/Controllers/TimelineController.cs | 43 +- Timeline/Controllers/TokenController.cs | 10 +- Timeline/Controllers/UserAvatarController.cs | 18 +- Timeline/Controllers/UserController.cs | 16 +- Timeline/Entities/DataEntity.cs | 2 +- Timeline/Entities/DatabaseContext.cs | 2 +- Timeline/Entities/JwtTokenEntity.cs | 2 +- Timeline/Entities/TimelineEntity.cs | 4 +- Timeline/Entities/TimelineMemberEntity.cs | 2 +- Timeline/Entities/TimelinePostEntity.cs | 2 +- Timeline/Entities/UserAvatarEntity.cs | 2 +- Timeline/Entities/UserEntity.cs | 2 +- Timeline/Filters/Header.cs | 4 +- Timeline/Filters/Timeline.cs | 6 +- Timeline/Formatters/StringInputFormatter.cs | 2 +- Timeline/Helpers/InvalidModelResponseFactory.cs | 4 +- Timeline/Helpers/LanguageHelper.cs | 2 +- Timeline/Helpers/Log.cs | 2 +- .../Helpers/StringLocalizerFactoryExtensions.cs | 2 +- .../20200105150407_Initialize.Designer.cs | 4 +- Timeline/Migrations/20200105150407_Initialize.cs | 2 +- .../20200131100517_RefactorUser.Designer.cs | 4 +- Timeline/Migrations/20200131100517_RefactorUser.cs | 2 +- .../20200221064341_AddJwtToken.Designer.cs | 4 +- Timeline/Migrations/20200221064341_AddJwtToken.cs | 2 +- .../20200229103848_AddPostLocalId.Designer.cs | 4 +- .../Migrations/20200229103848_AddPostLocalId.cs | 2 +- .../20200306110049_AddDataTable.Designer.cs | 4 +- Timeline/Migrations/20200306110049_AddDataTable.cs | 2 +- .../20200306111553_DropUserDetails.Designer.cs | 4 +- .../Migrations/20200306111553_DropUserDetails.cs | 2 +- .../Migrations/DatabaseContextModelSnapshot.cs | 4 +- .../Models/Converters/JsonDateTimeConverter.cs | 2 +- Timeline/Models/Http/Common.cs | 4 +- Timeline/Models/Http/ErrorResponse.cs | 4 +- Timeline/Models/Http/Timeline.cs | 119 +++++ Timeline/Models/Http/TimelineCommon.cs | 116 ----- Timeline/Models/Http/TimelineController.cs | 4 +- Timeline/Models/Http/TokenController.cs | 2 +- Timeline/Models/Http/UserController.cs | 6 +- Timeline/Models/Http/UserInfo.cs | 18 +- Timeline/Models/Timeline.cs | 74 +++ Timeline/Models/User.cs | 18 + Timeline/Models/Validation/NameValidator.cs | 4 +- Timeline/Models/Validation/NicknameValidator.cs | 4 +- .../Models/Validation/TimelineNameValidator.cs | 2 +- Timeline/Models/Validation/UsernameValidator.cs | 2 +- Timeline/Models/Validation/Validator.cs | 6 +- Timeline/Program.cs | 4 +- .../Authentication/AuthHandler.Designer.cs | 4 +- .../ControllerAuthExtensions.Designer.cs | 4 +- .../Controllers/TimelineController.Designer.cs | 4 +- .../Controllers/TokenController.Designer.cs | 4 +- .../Controllers/UserAvatarController.Designer.cs | 4 +- .../Controllers/UserController.Designer.cs | 4 +- Timeline/Resources/Filters.Designer.cs | 4 +- Timeline/Resources/Messages.Designer.cs | 4 +- Timeline/Resources/Models/Http/Common.Designer.cs | 4 +- .../Models/Validation/NameValidator.Designer.cs | 4 +- .../Validation/NicknameValidator.Designer.cs | 4 +- .../Models/Validation/Validator.Designer.cs | 4 +- .../Resources/Services/DataManager.Designer.cs | 4 +- Timeline/Resources/Services/Exception.Designer.cs | 4 +- .../Resources/Services/TimelineService.Designer.cs | 4 +- .../Services/UserAvatarService.Designer.cs | 4 +- .../Resources/Services/UserService.Designer.cs | 4 +- .../Services/UserTokenService.Designer.cs | 4 +- Timeline/Services/BadPasswordException.cs | 4 +- Timeline/Services/Clock.cs | 2 +- Timeline/Services/ConflictException.cs | 2 +- Timeline/Services/DataManager.cs | 4 +- Timeline/Services/DatabaseCorruptedException.cs | 2 +- Timeline/Services/ETagGenerator.cs | 2 +- Timeline/Services/ImageException.cs | 2 +- Timeline/Services/ImageValidator.cs | 2 +- .../Services/JwtUserTokenBadFormatException.cs | 4 +- Timeline/Services/PasswordBadFormatException.cs | 2 +- Timeline/Services/PasswordService.cs | 2 +- Timeline/Services/PathProvider.cs | 2 +- Timeline/Services/TimelineNotExistException.cs | 2 +- Timeline/Services/TimelinePostNotExistException.cs | 2 +- Timeline/Services/TimelineService.cs | 494 ++++++++++++--------- Timeline/Services/User.cs | 18 - Timeline/Services/UserAvatarService.cs | 6 +- Timeline/Services/UserNotExistException.cs | 4 +- Timeline/Services/UserRoleConvert.cs | 4 +- Timeline/Services/UserService.cs | 11 +- Timeline/Services/UserTokenException.cs | 2 +- Timeline/Services/UserTokenManager.cs | 3 +- Timeline/Services/UserTokenService.cs | 6 +- Timeline/Startup.cs | 20 +- Timeline/Timeline.csproj | 211 --------- Timeline/TimelineApp.csproj | 211 +++++++++ 125 files changed, 1015 insertions(+), 849 deletions(-) delete mode 100644 Timeline.ErrorCodes/Timeline.ErrorCodes.csproj create mode 100644 Timeline.ErrorCodes/TimelineApp.ErrorCodes.csproj delete mode 100644 Timeline.Tests/Timeline.Tests.csproj create mode 100644 Timeline.Tests/TimelineApp.Tests.csproj create mode 100644 Timeline/Models/Http/Timeline.cs delete mode 100644 Timeline/Models/Http/TimelineCommon.cs create mode 100644 Timeline/Models/Timeline.cs create mode 100644 Timeline/Models/User.cs delete mode 100644 Timeline/Services/User.cs delete mode 100644 Timeline/Timeline.csproj create mode 100644 Timeline/TimelineApp.csproj diff --git a/ErrorResponseCodeGenerator/ErrorResponseCodeGenerator.csproj b/ErrorResponseCodeGenerator/ErrorResponseCodeGenerator.csproj index 8524b2e4..a4ce64e6 100644 --- a/ErrorResponseCodeGenerator/ErrorResponseCodeGenerator.csproj +++ b/ErrorResponseCodeGenerator/ErrorResponseCodeGenerator.csproj @@ -10,7 +10,7 @@ - + diff --git a/ErrorResponseCodeGenerator/Program.cs b/ErrorResponseCodeGenerator/Program.cs index 5ea8aaca..0d2b2a3e 100644 --- a/ErrorResponseCodeGenerator/Program.cs +++ b/ErrorResponseCodeGenerator/Program.cs @@ -45,7 +45,7 @@ namespace ErrorResponseCodeGenerator "; } - RecursiveAddErrorCode(typeof(Timeline.Models.Http.ErrorCodes), true); + RecursiveAddErrorCode(typeof(TimelineApp.Models.Http.ErrorCodes), true); code = @" using static Timeline.Resources.Messages; diff --git a/Timeline.ErrorCodes/ErrorCodes.cs b/Timeline.ErrorCodes/ErrorCodes.cs index eca0e18b..b60a96ac 100644 --- a/Timeline.ErrorCodes/ErrorCodes.cs +++ b/Timeline.ErrorCodes/ErrorCodes.cs @@ -1,4 +1,4 @@ -namespace Timeline.Models.Http +namespace TimelineApp.Models.Http { /// /// All error code constants. diff --git a/Timeline.ErrorCodes/Timeline.ErrorCodes.csproj b/Timeline.ErrorCodes/Timeline.ErrorCodes.csproj deleted file mode 100644 index 01ca2568..00000000 --- a/Timeline.ErrorCodes/Timeline.ErrorCodes.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - netcoreapp3.1 - - - diff --git a/Timeline.ErrorCodes/TimelineApp.ErrorCodes.csproj b/Timeline.ErrorCodes/TimelineApp.ErrorCodes.csproj new file mode 100644 index 00000000..01ca2568 --- /dev/null +++ b/Timeline.ErrorCodes/TimelineApp.ErrorCodes.csproj @@ -0,0 +1,7 @@ + + + + netcoreapp3.1 + + + diff --git a/Timeline.Tests/ErrorCodeTest.cs b/Timeline.Tests/ErrorCodeTest.cs index 258ebf4e..3f8c855c 100644 --- a/Timeline.Tests/ErrorCodeTest.cs +++ b/Timeline.Tests/ErrorCodeTest.cs @@ -3,11 +3,11 @@ using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -using Timeline.Models.Http; +using TimelineApp.Models.Http; using Xunit; using Xunit.Abstractions; -namespace Timeline.Tests +namespace TimelineApp.Tests { public class ErrorCodeTest { diff --git a/Timeline.Tests/Helpers/AsyncFunctionAssertionsExtensions.cs b/Timeline.Tests/Helpers/AsyncFunctionAssertionsExtensions.cs index b78309c0..516c34e9 100644 --- a/Timeline.Tests/Helpers/AsyncFunctionAssertionsExtensions.cs +++ b/Timeline.Tests/Helpers/AsyncFunctionAssertionsExtensions.cs @@ -4,7 +4,7 @@ using FluentAssertions.Specialized; using System; using System.Threading.Tasks; -namespace Timeline.Tests.Helpers +namespace TimelineApp.Tests.Helpers { public static class AsyncFunctionAssertionsExtensions { diff --git a/Timeline.Tests/Helpers/HttpClientExtensions.cs b/Timeline.Tests/Helpers/HttpClientExtensions.cs index 6513bbe7..952266b3 100644 --- a/Timeline.Tests/Helpers/HttpClientExtensions.cs +++ b/Timeline.Tests/Helpers/HttpClientExtensions.cs @@ -6,7 +6,7 @@ using System.Net.Mime; using System.Text; using System.Threading.Tasks; -namespace Timeline.Tests.Helpers +namespace TimelineApp.Tests.Helpers { public static class HttpClientExtensions { diff --git a/Timeline.Tests/Helpers/ImageHelper.cs b/Timeline.Tests/Helpers/ImageHelper.cs index 9bed0917..ffbb38ae 100644 --- a/Timeline.Tests/Helpers/ImageHelper.cs +++ b/Timeline.Tests/Helpers/ImageHelper.cs @@ -3,7 +3,7 @@ using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.PixelFormats; using System.IO; -namespace Timeline.Tests.Helpers +namespace TimelineApp.Tests.Helpers { public static class ImageHelper { diff --git a/Timeline.Tests/Helpers/ParameterInfoAssertions.cs b/Timeline.Tests/Helpers/ParameterInfoAssertions.cs index d3e5a41e..a714f410 100644 --- a/Timeline.Tests/Helpers/ParameterInfoAssertions.cs +++ b/Timeline.Tests/Helpers/ParameterInfoAssertions.cs @@ -5,7 +5,7 @@ using FluentAssertions.Primitives; using System; using System.Reflection; -namespace Timeline.Tests.Helpers +namespace TimelineApp.Tests.Helpers { public class ParameterInfoValueFormatter : IValueFormatter { diff --git a/Timeline.Tests/Helpers/ReflectionHelper.cs b/Timeline.Tests/Helpers/ReflectionHelper.cs index 3f6036e3..16d68bb1 100644 --- a/Timeline.Tests/Helpers/ReflectionHelper.cs +++ b/Timeline.Tests/Helpers/ReflectionHelper.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Reflection; -namespace Timeline.Tests.Helpers +namespace TimelineApp.Tests.Helpers { public static class ReflectionHelper { diff --git a/Timeline.Tests/Helpers/ResponseAssertions.cs b/Timeline.Tests/Helpers/ResponseAssertions.cs index f01a0677..4984d224 100644 --- a/Timeline.Tests/Helpers/ResponseAssertions.cs +++ b/Timeline.Tests/Helpers/ResponseAssertions.cs @@ -9,10 +9,10 @@ using System.Net.Http; using System.Text; using System.Text.Json; using System.Text.Json.Serialization; -using Timeline.Models.Converters; -using Timeline.Models.Http; +using TimelineApp.Models.Converters; +using TimelineApp.Models.Http; -namespace Timeline.Tests.Helpers +namespace TimelineApp.Tests.Helpers { public class HttpResponseMessageValueFormatter : IValueFormatter { diff --git a/Timeline.Tests/Helpers/TestApplication.cs b/Timeline.Tests/Helpers/TestApplication.cs index 52c2f2e2..c655d337 100644 --- a/Timeline.Tests/Helpers/TestApplication.cs +++ b/Timeline.Tests/Helpers/TestApplication.cs @@ -6,10 +6,10 @@ using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.IO; -using Timeline.Entities; -using Timeline.Migrations; +using TimelineApp.Entities; +using TimelineApp.Migrations; -namespace Timeline.Tests.Helpers +namespace TimelineApp.Tests.Helpers { public class TestApplication : IDisposable { diff --git a/Timeline.Tests/IntegratedTests/AuthorizationTest.cs b/Timeline.Tests/IntegratedTests/AuthorizationTest.cs index 4aa6b3ae..69be9187 100644 --- a/Timeline.Tests/IntegratedTests/AuthorizationTest.cs +++ b/Timeline.Tests/IntegratedTests/AuthorizationTest.cs @@ -2,10 +2,10 @@ using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; using System.Net; using System.Threading.Tasks; -using Timeline.Tests.Helpers; +using TimelineApp.Tests.Helpers; using Xunit; -namespace Timeline.Tests.IntegratedTests +namespace TimelineApp.Tests.IntegratedTests { public class AuthorizationTest : IntegratedTestBase { diff --git a/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs b/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs index dfde2ea5..e265c16e 100644 --- a/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs +++ b/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs @@ -5,12 +5,12 @@ using System; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; -using Timeline.Models.Http; -using Timeline.Services; -using Timeline.Tests.Helpers; +using TimelineApp.Models.Http; +using TimelineApp.Services; +using TimelineApp.Tests.Helpers; using Xunit; -namespace Timeline.Tests.IntegratedTests +namespace TimelineApp.Tests.IntegratedTests { public abstract class IntegratedTestBase : IClassFixture>, IDisposable { diff --git a/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs b/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs index 7d0a68e8..b6d3e827 100644 --- a/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs +++ b/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs @@ -5,11 +5,11 @@ using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Threading.Tasks; -using Timeline.Models.Http; -using Timeline.Tests.Helpers; +using TimelineApp.Models.Http; +using TimelineApp.Tests.Helpers; using Xunit; -namespace Timeline.Tests.IntegratedTests +namespace TimelineApp.Tests.IntegratedTests { public class PersonalTimelineTest : IntegratedTestBase { diff --git a/Timeline.Tests/IntegratedTests/TimelineTest.cs b/Timeline.Tests/IntegratedTests/TimelineTest.cs index 14a0a59e..cad74e6c 100644 --- a/Timeline.Tests/IntegratedTests/TimelineTest.cs +++ b/Timeline.Tests/IntegratedTests/TimelineTest.cs @@ -6,11 +6,11 @@ using System.Linq; using System.Net; using System.Net.Http; using System.Threading.Tasks; -using Timeline.Models.Http; -using Timeline.Tests.Helpers; +using TimelineApp.Models.Http; +using TimelineApp.Tests.Helpers; using Xunit; -namespace Timeline.Tests.IntegratedTests +namespace TimelineApp.Tests.IntegratedTests { public class TimelineTest : IntegratedTestBase { diff --git a/Timeline.Tests/IntegratedTests/TokenTest.cs b/Timeline.Tests/IntegratedTests/TokenTest.cs index 928d546c..10af46af 100644 --- a/Timeline.Tests/IntegratedTests/TokenTest.cs +++ b/Timeline.Tests/IntegratedTests/TokenTest.cs @@ -4,12 +4,12 @@ using Microsoft.Extensions.DependencyInjection; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; -using Timeline.Models.Http; -using Timeline.Services; -using Timeline.Tests.Helpers; +using TimelineApp.Models.Http; +using TimelineApp.Services; +using TimelineApp.Tests.Helpers; using Xunit; -namespace Timeline.Tests.IntegratedTests +namespace TimelineApp.Tests.IntegratedTests { public class TokenTest : IntegratedTestBase { diff --git a/Timeline.Tests/IntegratedTests/UserAvatarTest.cs b/Timeline.Tests/IntegratedTests/UserAvatarTest.cs index fa0120f1..8fd1d687 100644 --- a/Timeline.Tests/IntegratedTests/UserAvatarTest.cs +++ b/Timeline.Tests/IntegratedTests/UserAvatarTest.cs @@ -13,12 +13,12 @@ using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; -using Timeline.Models.Http; -using Timeline.Services; -using Timeline.Tests.Helpers; +using TimelineApp.Models.Http; +using TimelineApp.Services; +using TimelineApp.Tests.Helpers; using Xunit; -namespace Timeline.Tests.IntegratedTests +namespace TimelineApp.Tests.IntegratedTests { public class UserAvatarTest : IntegratedTestBase { diff --git a/Timeline.Tests/IntegratedTests/UserTest.cs b/Timeline.Tests/IntegratedTests/UserTest.cs index 8ce76299..eed13565 100644 --- a/Timeline.Tests/IntegratedTests/UserTest.cs +++ b/Timeline.Tests/IntegratedTests/UserTest.cs @@ -4,11 +4,11 @@ using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Threading.Tasks; -using Timeline.Models.Http; -using Timeline.Tests.Helpers; +using TimelineApp.Models.Http; +using TimelineApp.Tests.Helpers; using Xunit; -namespace Timeline.Tests.IntegratedTests +namespace TimelineApp.Tests.IntegratedTests { public class UserTest : IntegratedTestBase { diff --git a/Timeline.Tests/PasswordGenerator.cs b/Timeline.Tests/PasswordGenerator.cs index 6c07836b..bb6c538d 100644 --- a/Timeline.Tests/PasswordGenerator.cs +++ b/Timeline.Tests/PasswordGenerator.cs @@ -1,9 +1,9 @@ using System; -using Timeline.Services; +using TimelineApp.Services; using Xunit; using Xunit.Abstractions; -namespace Timeline.Tests +namespace TimelineApp.Tests { public class PasswordGenerator { diff --git a/Timeline.Tests/Timeline.Tests.csproj b/Timeline.Tests/Timeline.Tests.csproj deleted file mode 100644 index 00c1e103..00000000 --- a/Timeline.Tests/Timeline.Tests.csproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - netcoreapp3.1 - - 8.0 - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - all - runtime; build; native; contentfiles; analyzers - - - - - - - diff --git a/Timeline.Tests/TimelineApp.Tests.csproj b/Timeline.Tests/TimelineApp.Tests.csproj new file mode 100644 index 00000000..1f445f8b --- /dev/null +++ b/Timeline.Tests/TimelineApp.Tests.csproj @@ -0,0 +1,33 @@ + + + + netcoreapp3.1 + + 8.0 + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + diff --git a/Timeline.Tests/UsernameValidatorUnitTest.cs b/Timeline.Tests/UsernameValidatorUnitTest.cs index 8824362b..f436c091 100644 --- a/Timeline.Tests/UsernameValidatorUnitTest.cs +++ b/Timeline.Tests/UsernameValidatorUnitTest.cs @@ -1,9 +1,9 @@ using FluentAssertions; -using Timeline.Models.Validation; -using Timeline.Tests.Helpers; +using TimelineApp.Models.Validation; +using TimelineApp.Tests.Helpers; using Xunit; -namespace Timeline.Tests +namespace TimelineApp.Tests { public class UsernameValidatorUnitTest : IClassFixture { diff --git a/Timeline.sln b/Timeline.sln index 0e01871a..fc6e0d50 100644 --- a/Timeline.sln +++ b/Timeline.sln @@ -2,13 +2,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29709.97 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Timeline", "Timeline\Timeline.csproj", "{A34D323C-5233-4754-B14F-4819CE9C27CA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TimelineApp", "Timeline\TimelineApp.csproj", "{A34D323C-5233-4754-B14F-4819CE9C27CA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Timeline.Tests", "Timeline.Tests\Timeline.Tests.csproj", "{3D76D578-37BC-43C2-97BF-9C6DD3825F10}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TimelineApp.Tests", "Timeline.Tests\TimelineApp.Tests.csproj", "{3D76D578-37BC-43C2-97BF-9C6DD3825F10}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ErrorResponseCodeGenerator", "ErrorResponseCodeGenerator\ErrorResponseCodeGenerator.csproj", "{F325F802-75DE-4527-A299-F668281B0E4D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ErrorResponseCodeGenerator", "ErrorResponseCodeGenerator\ErrorResponseCodeGenerator.csproj", "{F325F802-75DE-4527-A299-F668281B0E4D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Timeline.ErrorCodes", "Timeline.ErrorCodes\Timeline.ErrorCodes.csproj", "{1044E3B0-1010-47CA-956E-B6E8FE87055B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TimelineApp.ErrorCodes", "Timeline.ErrorCodes\TimelineApp.ErrorCodes.csproj", "{1044E3B0-1010-47CA-956E-B6E8FE87055B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Timeline/Auth/Attribute.cs b/Timeline/Auth/Attribute.cs index 86d0109b..51e20bdf 100644 --- a/Timeline/Auth/Attribute.cs +++ b/Timeline/Auth/Attribute.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Authorization; -using Timeline.Entities; +using TimelineApp.Entities; -namespace Timeline.Auth +namespace TimelineApp.Auth { public class AdminAuthorizeAttribute : AuthorizeAttribute { diff --git a/Timeline/Auth/MyAuthenticationHandler.cs b/Timeline/Auth/MyAuthenticationHandler.cs index 3c97c329..5e119b69 100644 --- a/Timeline/Auth/MyAuthenticationHandler.cs +++ b/Timeline/Auth/MyAuthenticationHandler.cs @@ -8,10 +8,10 @@ using System.Linq; using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Timeline.Services; -using static Timeline.Resources.Authentication.AuthHandler; +using TimelineApp.Services; +using static TimelineApp.Resources.Authentication.AuthHandler; -namespace Timeline.Auth +namespace TimelineApp.Auth { public static class AuthenticationConstants { diff --git a/Timeline/Auth/PrincipalExtensions.cs b/Timeline/Auth/PrincipalExtensions.cs index ad7a887f..e7eb04b7 100644 --- a/Timeline/Auth/PrincipalExtensions.cs +++ b/Timeline/Auth/PrincipalExtensions.cs @@ -1,7 +1,7 @@ using System.Security.Principal; -using Timeline.Entities; +using TimelineApp.Entities; -namespace Timeline.Auth +namespace TimelineApp.Auth { internal static class PrincipalExtensions { diff --git a/Timeline/Configs/JwtConfiguration.cs b/Timeline/Configs/JwtConfiguration.cs index af8052de..ce8dd48b 100644 --- a/Timeline/Configs/JwtConfiguration.cs +++ b/Timeline/Configs/JwtConfiguration.cs @@ -1,4 +1,4 @@ -namespace Timeline.Configs +namespace TimelineApp.Configs { public class JwtConfiguration { diff --git a/Timeline/Controllers/ControllerAuthExtensions.cs b/Timeline/Controllers/ControllerAuthExtensions.cs index 00a65454..9c7ea601 100644 --- a/Timeline/Controllers/ControllerAuthExtensions.cs +++ b/Timeline/Controllers/ControllerAuthExtensions.cs @@ -1,10 +1,10 @@ using Microsoft.AspNetCore.Mvc; using System; using System.Security.Claims; -using Timeline.Auth; -using static Timeline.Resources.Controllers.ControllerAuthExtensions; +using TimelineApp.Auth; +using static TimelineApp.Resources.Controllers.ControllerAuthExtensions; -namespace Timeline.Controllers +namespace TimelineApp.Controllers { public static class ControllerAuthExtensions { diff --git a/Timeline/Controllers/PersonalTimelineController.cs b/Timeline/Controllers/PersonalTimelineController.cs index cef04a97..0c0694cb 100644 --- a/Timeline/Controllers/PersonalTimelineController.cs +++ b/Timeline/Controllers/PersonalTimelineController.cs @@ -4,12 +4,12 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading.Tasks; -using Timeline.Filters; -using Timeline.Models.Http; -using Timeline.Models.Validation; -using Timeline.Services; +using TimelineApp.Filters; +using TimelineApp.Models.Http; +using TimelineApp.Models.Validation; +using TimelineApp.Services; -namespace Timeline.Controllers +namespace TimelineApp.Controllers { [ApiController] [CatchTimelineNotExistException] diff --git a/Timeline/Controllers/Testing/TestingAuthController.cs b/Timeline/Controllers/Testing/TestingAuthController.cs index 4d3b3ec7..6061f003 100644 --- a/Timeline/Controllers/Testing/TestingAuthController.cs +++ b/Timeline/Controllers/Testing/TestingAuthController.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Timeline.Auth; +using TimelineApp.Auth; -namespace Timeline.Controllers.Testing +namespace TimelineApp.Controllers.Testing { [Route("testing/auth")] [ApiController] diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index 85ccb5c1..00e9a860 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Authorization; +using AutoMapper; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; @@ -6,12 +7,13 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; -using Timeline.Filters; -using Timeline.Models.Http; -using Timeline.Models.Validation; -using Timeline.Services; +using TimelineApp.Filters; +using TimelineApp.Models; +using TimelineApp.Models.Http; +using TimelineApp.Models.Validation; +using TimelineApp.Services; -namespace Timeline.Controllers +namespace TimelineApp.Controllers { [ApiController] [CatchTimelineNotExistException] @@ -22,11 +24,14 @@ namespace Timeline.Controllers private readonly IUserService _userService; private readonly ITimelineService _service; - public TimelineController(ILogger logger, IUserService userService, ITimelineService service) + private readonly IMapper _mapper; + + public TimelineController(ILogger logger, IUserService userService, ITimelineService service, IMapper mapper) { _logger = logger; _userService = userService; _service = service; + _mapper = mapper; } [HttpGet("timelines")] @@ -81,27 +86,31 @@ namespace Timeline.Controllers } } - var result = await _service.GetTimelines(relationship, visibilityFilter); - result.ForEach(t => t.FillLinks(Url)); - return Ok(result); + var timelines = await _service.GetTimelines(relationship, visibilityFilter); + var result = _mapper.Map>(timelines); + return result; } [HttpGet("timelines/{name}")] public async Task> TimelineGet([FromRoute][TimelineName] string name) { - var result = (await _service.GetTimeline(name)).FillLinks(Url); - return Ok(result); + var timeline = await _service.GetTimeline(name); + var result = _mapper.Map(timeline); + return result; } [HttpGet("timelines/{name}/posts")] - public async Task>> PostListGet([FromRoute][TimelineName] string name) + public async Task>> PostListGet([FromRoute][TimelineName] string name) { if (!this.IsAdministrator() && !await _service.HasReadPermission(name, this.GetOptionalUserId())) { return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid()); } - return await _service.GetPosts(name); + var posts = await _service.GetPosts(name); + var result = _mapper.Map>(posts); + + return result; } [HttpPost("timelines/{name}/posts")] @@ -120,7 +129,7 @@ namespace Timeline.Controllers [HttpDelete("timelines/{name}/posts/{id}")] [Authorize] - public async Task PostDelete([FromRoute][TimelineName] string name, [FromRoute] long id) + public async Task> PostDelete([FromRoute][TimelineName] string name, [FromRoute] long id) { try { @@ -129,11 +138,11 @@ namespace Timeline.Controllers return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid()); } await _service.DeletePost(name, id); - return Ok(CommonDeleteResponse.Delete()); + return CommonDeleteResponse.Delete(); } catch (TimelinePostNotExistException) { - return Ok(CommonDeleteResponse.NotExist()); + return CommonDeleteResponse.NotExist(); } } diff --git a/Timeline/Controllers/TokenController.cs b/Timeline/Controllers/TokenController.cs index 1fb0b17a..47dcc0aa 100644 --- a/Timeline/Controllers/TokenController.cs +++ b/Timeline/Controllers/TokenController.cs @@ -5,12 +5,12 @@ using Microsoft.Extensions.Logging; using System; using System.Globalization; using System.Threading.Tasks; -using Timeline.Helpers; -using Timeline.Models.Http; -using Timeline.Services; -using static Timeline.Resources.Controllers.TokenController; +using TimelineApp.Helpers; +using TimelineApp.Models.Http; +using TimelineApp.Services; +using static TimelineApp.Resources.Controllers.TokenController; -namespace Timeline.Controllers +namespace TimelineApp.Controllers { [Route("token")] [ApiController] diff --git a/Timeline/Controllers/UserAvatarController.cs b/Timeline/Controllers/UserAvatarController.cs index f4f3db3e..089cef94 100644 --- a/Timeline/Controllers/UserAvatarController.cs +++ b/Timeline/Controllers/UserAvatarController.cs @@ -6,15 +6,15 @@ using Microsoft.Net.Http.Headers; using System; using System.Linq; using System.Threading.Tasks; -using Timeline.Auth; -using Timeline.Filters; -using Timeline.Helpers; -using Timeline.Models.Http; -using Timeline.Models.Validation; -using Timeline.Services; -using static Timeline.Resources.Controllers.UserAvatarController; - -namespace Timeline.Controllers +using TimelineApp.Auth; +using TimelineApp.Filters; +using TimelineApp.Helpers; +using TimelineApp.Models.Http; +using TimelineApp.Models.Validation; +using TimelineApp.Services; +using static TimelineApp.Resources.Controllers.UserAvatarController; + +namespace TimelineApp.Controllers { [ApiController] public class UserAvatarController : Controller diff --git a/Timeline/Controllers/UserController.cs b/Timeline/Controllers/UserController.cs index a3e8d816..4106c750 100644 --- a/Timeline/Controllers/UserController.cs +++ b/Timeline/Controllers/UserController.cs @@ -5,15 +5,15 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System.Linq; using System.Threading.Tasks; -using Timeline.Auth; -using Timeline.Helpers; -using Timeline.Models.Http; -using Timeline.Models.Validation; -using Timeline.Services; -using static Timeline.Resources.Controllers.UserController; -using static Timeline.Resources.Messages; +using TimelineApp.Auth; +using TimelineApp.Helpers; +using TimelineApp.Models.Http; +using TimelineApp.Models.Validation; +using TimelineApp.Services; +using static TimelineApp.Resources.Controllers.UserController; +using static TimelineApp.Resources.Messages; -namespace Timeline.Controllers +namespace TimelineApp.Controllers { [ApiController] public class UserController : Controller diff --git a/Timeline/Entities/DataEntity.cs b/Timeline/Entities/DataEntity.cs index b21e2dbf..dd8a8ae7 100644 --- a/Timeline/Entities/DataEntity.cs +++ b/Timeline/Entities/DataEntity.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Timeline.Entities +namespace TimelineApp.Entities { [Table("data")] public class DataEntity diff --git a/Timeline/Entities/DatabaseContext.cs b/Timeline/Entities/DatabaseContext.cs index 8899308c..5c074d2c 100644 --- a/Timeline/Entities/DatabaseContext.cs +++ b/Timeline/Entities/DatabaseContext.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore; -namespace Timeline.Entities +namespace TimelineApp.Entities { public class DatabaseContext : DbContext { diff --git a/Timeline/Entities/JwtTokenEntity.cs b/Timeline/Entities/JwtTokenEntity.cs index 40cb230a..6e5ae9a8 100644 --- a/Timeline/Entities/JwtTokenEntity.cs +++ b/Timeline/Entities/JwtTokenEntity.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Timeline.Entities +namespace TimelineApp.Entities { [Table("jwt_token")] public class JwtTokenEntity diff --git a/Timeline/Entities/TimelineEntity.cs b/Timeline/Entities/TimelineEntity.cs index 56b36d4e..c902a690 100644 --- a/Timeline/Entities/TimelineEntity.cs +++ b/Timeline/Entities/TimelineEntity.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using Timeline.Models.Http; +using TimelineApp.Models.Http; -namespace Timeline.Entities +namespace TimelineApp.Entities { #pragma warning disable CA2227 // Collection properties should be read only // TODO: Create index for this table. diff --git a/Timeline/Entities/TimelineMemberEntity.cs b/Timeline/Entities/TimelineMemberEntity.cs index e76f2099..e421ca2e 100644 --- a/Timeline/Entities/TimelineMemberEntity.cs +++ b/Timeline/Entities/TimelineMemberEntity.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Timeline.Entities +namespace TimelineApp.Entities { [Table("timeline_members")] public class TimelineMemberEntity diff --git a/Timeline/Entities/TimelinePostEntity.cs b/Timeline/Entities/TimelinePostEntity.cs index 24bfc7a3..8cdecef5 100644 --- a/Timeline/Entities/TimelinePostEntity.cs +++ b/Timeline/Entities/TimelinePostEntity.cs @@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Timeline.Entities +namespace TimelineApp.Entities { [Table("timeline_posts")] public class TimelinePostEntity diff --git a/Timeline/Entities/UserAvatarEntity.cs b/Timeline/Entities/UserAvatarEntity.cs index 3c2720f7..b32faf06 100644 --- a/Timeline/Entities/UserAvatarEntity.cs +++ b/Timeline/Entities/UserAvatarEntity.cs @@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Timeline.Entities +namespace TimelineApp.Entities { [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1819:Properties should not return arrays", Justification = "This is data base entity.")] [Table("user_avatars")] diff --git a/Timeline/Entities/UserEntity.cs b/Timeline/Entities/UserEntity.cs index 1ef3f98c..6c193da8 100644 --- a/Timeline/Entities/UserEntity.cs +++ b/Timeline/Entities/UserEntity.cs @@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Timeline.Entities +namespace TimelineApp.Entities { public static class UserRoles { diff --git a/Timeline/Filters/Header.cs b/Timeline/Filters/Header.cs index 0db11faf..3892e451 100644 --- a/Timeline/Filters/Header.cs +++ b/Timeline/Filters/Header.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; -using Timeline.Models.Http; +using TimelineApp.Models.Http; -namespace Timeline.Filters +namespace TimelineApp.Filters { public class RequireContentTypeAttribute : ActionFilterAttribute { diff --git a/Timeline/Filters/Timeline.cs b/Timeline/Filters/Timeline.cs index e133c9d6..28ac8818 100644 --- a/Timeline/Filters/Timeline.cs +++ b/Timeline/Filters/Timeline.cs @@ -1,9 +1,9 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; -using Timeline.Models.Http; -using Timeline.Services; +using TimelineApp.Models.Http; +using TimelineApp.Services; -namespace Timeline.Filters +namespace TimelineApp.Filters { public class CatchTimelineNotExistExceptionAttribute : ExceptionFilterAttribute { diff --git a/Timeline/Formatters/StringInputFormatter.cs b/Timeline/Formatters/StringInputFormatter.cs index b1924268..e6831d0a 100644 --- a/Timeline/Formatters/StringInputFormatter.cs +++ b/Timeline/Formatters/StringInputFormatter.cs @@ -5,7 +5,7 @@ using System.Net.Mime; using System.Text; using System.Threading.Tasks; -namespace Timeline.Formatters +namespace TimelineApp.Formatters { public class StringInputFormatter : TextInputFormatter { diff --git a/Timeline/Helpers/InvalidModelResponseFactory.cs b/Timeline/Helpers/InvalidModelResponseFactory.cs index 9b253e7d..09273657 100644 --- a/Timeline/Helpers/InvalidModelResponseFactory.cs +++ b/Timeline/Helpers/InvalidModelResponseFactory.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc; using System.Text; -using Timeline.Models.Http; +using TimelineApp.Models.Http; -namespace Timeline.Helpers +namespace TimelineApp.Helpers { public static class InvalidModelResponseFactory { diff --git a/Timeline/Helpers/LanguageHelper.cs b/Timeline/Helpers/LanguageHelper.cs index b0156b8b..c5272253 100644 --- a/Timeline/Helpers/LanguageHelper.cs +++ b/Timeline/Helpers/LanguageHelper.cs @@ -1,6 +1,6 @@ using System.Linq; -namespace Timeline.Helpers +namespace TimelineApp.Helpers { public static class LanguageHelper { diff --git a/Timeline/Helpers/Log.cs b/Timeline/Helpers/Log.cs index 68c975fa..bc122e76 100644 --- a/Timeline/Helpers/Log.cs +++ b/Timeline/Helpers/Log.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Text; -namespace Timeline.Helpers +namespace TimelineApp.Helpers { public static class Log { diff --git a/Timeline/Helpers/StringLocalizerFactoryExtensions.cs b/Timeline/Helpers/StringLocalizerFactoryExtensions.cs index c2252b2c..45994c36 100644 --- a/Timeline/Helpers/StringLocalizerFactoryExtensions.cs +++ b/Timeline/Helpers/StringLocalizerFactoryExtensions.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Localization; using System.Reflection; -namespace Timeline.Helpers +namespace TimelineApp.Helpers { internal static class StringLocalizerFactoryExtensions { diff --git a/Timeline/Migrations/20200105150407_Initialize.Designer.cs b/Timeline/Migrations/20200105150407_Initialize.Designer.cs index 99e4eaac..46670fa5 100644 --- a/Timeline/Migrations/20200105150407_Initialize.Designer.cs +++ b/Timeline/Migrations/20200105150407_Initialize.Designer.cs @@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Timeline.Entities; +using TimelineApp.Entities; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { [DbContext(typeof(DatabaseContext))] [Migration("20200105150407_Initialize")] diff --git a/Timeline/Migrations/20200105150407_Initialize.cs b/Timeline/Migrations/20200105150407_Initialize.cs index 4e12ef83..0013259c 100644 --- a/Timeline/Migrations/20200105150407_Initialize.cs +++ b/Timeline/Migrations/20200105150407_Initialize.cs @@ -1,7 +1,7 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { public partial class Initialize : Migration { diff --git a/Timeline/Migrations/20200131100517_RefactorUser.Designer.cs b/Timeline/Migrations/20200131100517_RefactorUser.Designer.cs index 9b78eb15..02fde575 100644 --- a/Timeline/Migrations/20200131100517_RefactorUser.Designer.cs +++ b/Timeline/Migrations/20200131100517_RefactorUser.Designer.cs @@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Timeline.Entities; +using TimelineApp.Entities; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { [DbContext(typeof(DatabaseContext))] [Migration("20200131100517_RefactorUser")] diff --git a/Timeline/Migrations/20200131100517_RefactorUser.cs b/Timeline/Migrations/20200131100517_RefactorUser.cs index 8597ed50..af6235e1 100644 --- a/Timeline/Migrations/20200131100517_RefactorUser.cs +++ b/Timeline/Migrations/20200131100517_RefactorUser.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { public partial class RefactorUser : Migration { diff --git a/Timeline/Migrations/20200221064341_AddJwtToken.Designer.cs b/Timeline/Migrations/20200221064341_AddJwtToken.Designer.cs index eb328b52..7c5b26b8 100644 --- a/Timeline/Migrations/20200221064341_AddJwtToken.Designer.cs +++ b/Timeline/Migrations/20200221064341_AddJwtToken.Designer.cs @@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Timeline.Entities; +using TimelineApp.Entities; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { [DbContext(typeof(DatabaseContext))] [Migration("20200221064341_AddJwtToken")] diff --git a/Timeline/Migrations/20200221064341_AddJwtToken.cs b/Timeline/Migrations/20200221064341_AddJwtToken.cs index 628970c6..00d23d0f 100644 --- a/Timeline/Migrations/20200221064341_AddJwtToken.cs +++ b/Timeline/Migrations/20200221064341_AddJwtToken.cs @@ -2,7 +2,7 @@ using System.Security.Cryptography; using Microsoft.EntityFrameworkCore.Migrations; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { public static class JwtTokenGenerateHelper { diff --git a/Timeline/Migrations/20200229103848_AddPostLocalId.Designer.cs b/Timeline/Migrations/20200229103848_AddPostLocalId.Designer.cs index cf6ae8a3..3abac60e 100644 --- a/Timeline/Migrations/20200229103848_AddPostLocalId.Designer.cs +++ b/Timeline/Migrations/20200229103848_AddPostLocalId.Designer.cs @@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Timeline.Entities; +using TimelineApp.Entities; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { [DbContext(typeof(DatabaseContext))] [Migration("20200229103848_AddPostLocalId")] diff --git a/Timeline/Migrations/20200229103848_AddPostLocalId.cs b/Timeline/Migrations/20200229103848_AddPostLocalId.cs index 497b38a1..029498ba 100644 --- a/Timeline/Migrations/20200229103848_AddPostLocalId.cs +++ b/Timeline/Migrations/20200229103848_AddPostLocalId.cs @@ -1,7 +1,7 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { public partial class AddPostLocalId : Migration { diff --git a/Timeline/Migrations/20200306110049_AddDataTable.Designer.cs b/Timeline/Migrations/20200306110049_AddDataTable.Designer.cs index 336ffc18..e7fdd35a 100644 --- a/Timeline/Migrations/20200306110049_AddDataTable.Designer.cs +++ b/Timeline/Migrations/20200306110049_AddDataTable.Designer.cs @@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Timeline.Entities; +using TimelineApp.Entities; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { [DbContext(typeof(DatabaseContext))] [Migration("20200306110049_AddDataTable")] diff --git a/Timeline/Migrations/20200306110049_AddDataTable.cs b/Timeline/Migrations/20200306110049_AddDataTable.cs index e33bf4c9..81a1b67f 100644 --- a/Timeline/Migrations/20200306110049_AddDataTable.cs +++ b/Timeline/Migrations/20200306110049_AddDataTable.cs @@ -1,7 +1,7 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { public partial class AddDataTable : Migration { diff --git a/Timeline/Migrations/20200306111553_DropUserDetails.Designer.cs b/Timeline/Migrations/20200306111553_DropUserDetails.Designer.cs index f0c4dc08..775665ac 100644 --- a/Timeline/Migrations/20200306111553_DropUserDetails.Designer.cs +++ b/Timeline/Migrations/20200306111553_DropUserDetails.Designer.cs @@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Timeline.Entities; +using TimelineApp.Entities; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { [DbContext(typeof(DatabaseContext))] [Migration("20200306111553_DropUserDetails")] diff --git a/Timeline/Migrations/20200306111553_DropUserDetails.cs b/Timeline/Migrations/20200306111553_DropUserDetails.cs index 0a176461..d5d74cce 100644 --- a/Timeline/Migrations/20200306111553_DropUserDetails.cs +++ b/Timeline/Migrations/20200306111553_DropUserDetails.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { public partial class DropUserDetails : Migration { diff --git a/Timeline/Migrations/DatabaseContextModelSnapshot.cs b/Timeline/Migrations/DatabaseContextModelSnapshot.cs index 8170b2f0..50094f3e 100644 --- a/Timeline/Migrations/DatabaseContextModelSnapshot.cs +++ b/Timeline/Migrations/DatabaseContextModelSnapshot.cs @@ -3,9 +3,9 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Timeline.Entities; +using TimelineApp.Entities; -namespace Timeline.Migrations +namespace TimelineApp.Migrations { [DbContext(typeof(DatabaseContext))] partial class DatabaseContextModelSnapshot : ModelSnapshot diff --git a/Timeline/Models/Converters/JsonDateTimeConverter.cs b/Timeline/Models/Converters/JsonDateTimeConverter.cs index ef129a01..057186de 100644 --- a/Timeline/Models/Converters/JsonDateTimeConverter.cs +++ b/Timeline/Models/Converters/JsonDateTimeConverter.cs @@ -4,7 +4,7 @@ using System.Globalization; using System.Text.Json; using System.Text.Json.Serialization; -namespace Timeline.Models.Converters +namespace TimelineApp.Models.Converters { public class JsonDateTimeConverter : JsonConverter { diff --git a/Timeline/Models/Http/Common.cs b/Timeline/Models/Http/Common.cs index a9fc8a79..f30fdb0d 100644 --- a/Timeline/Models/Http/Common.cs +++ b/Timeline/Models/Http/Common.cs @@ -1,6 +1,6 @@ -using static Timeline.Resources.Models.Http.Common; +using static TimelineApp.Resources.Models.Http.Common; -namespace Timeline.Models.Http +namespace TimelineApp.Models.Http { public class CommonResponse { diff --git a/Timeline/Models/Http/ErrorResponse.cs b/Timeline/Models/Http/ErrorResponse.cs index 9f7e70e1..d6cb5ca0 100644 --- a/Timeline/Models/Http/ErrorResponse.cs +++ b/Timeline/Models/Http/ErrorResponse.cs @@ -1,7 +1,7 @@  -using static Timeline.Resources.Messages; +using static TimelineApp.Resources.Messages; -namespace Timeline.Models.Http +namespace TimelineApp.Models.Http { public static class ErrorResponse diff --git a/Timeline/Models/Http/Timeline.cs b/Timeline/Models/Http/Timeline.cs new file mode 100644 index 00000000..144cca7c --- /dev/null +++ b/Timeline/Models/Http/Timeline.cs @@ -0,0 +1,119 @@ +using AutoMapper; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Infrastructure; +using Microsoft.AspNetCore.Mvc.Routing; +using System; +using System.Collections.Generic; +using TimelineApp.Controllers; + +namespace TimelineApp.Models.Http +{ + public class TimelinePostContentInfo + { + public string Type { get; set; } = default!; + public string? Text { get; set; } + public string? Url { get; set; } + } + + public class TimelinePostInfo + { + public long Id { get; set; } + public TimelinePostContentInfo Content { get; set; } = default!; + public DateTime Time { get; set; } + public UserInfo Author { get; set; } = default!; + public DateTime LastUpdated { get; set; } = default!; + } + + public class TimelineInfo + { + public string? Name { get; set; } + public string Description { get; set; } = default!; + public UserInfo Owner { get; set; } = default!; + public TimelineVisibility Visibility { get; set; } +#pragma warning disable CA2227 // Collection properties should be read only + public List Members { get; set; } = default!; +#pragma warning restore CA2227 // Collection properties should be read only + +#pragma warning disable CA1707 // Identifiers should not contain underscores + public TimelineInfoLinks _links { get; set; } = default!; +#pragma warning restore CA1707 // Identifiers should not contain underscores + } + + public class TimelineInfoLinks + { + public string Self { get; set; } = default!; + public string Posts { get; set; } = default!; + } + + public class TimelineInfoLinksValueResolver : IValueResolver + { + private readonly IActionContextAccessor _actionContextAccessor; + private readonly IUrlHelperFactory _urlHelperFactory; + + public TimelineInfoLinksValueResolver(IActionContextAccessor actionContextAccessor, IUrlHelperFactory urlHelperFactory) + { + _actionContextAccessor = actionContextAccessor; + _urlHelperFactory = urlHelperFactory; + } + + public TimelineInfoLinks Resolve(Timeline source, TimelineInfo destination, TimelineInfoLinks destMember, ResolutionContext context) + { + if (_actionContextAccessor.ActionContext == null) + throw new InvalidOperationException("No action context, can't fill urls."); + + var urlHelper = _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext); + + + return new TimelineInfoLinks + { + Self = urlHelper.ActionLink(nameof(TimelineController.TimelineGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { source.Name }), + Posts = urlHelper.ActionLink(nameof(TimelineController.PostListGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { source.Name }) + }; + } + } + + public class TimelinePostConverter : ITypeConverter + { + private readonly IActionContextAccessor _actionContextAccessor; + private readonly IUrlHelperFactory _urlHelperFactory; + + public TimelinePostConverter(IActionContextAccessor actionContextAccessor, IUrlHelperFactory urlHelperFactory) + { + _actionContextAccessor = actionContextAccessor; + _urlHelperFactory = urlHelperFactory; + } + + public TimelinePostContentInfo Convert(ITimelinePostContent source, TimelinePostContentInfo destination, ResolutionContext context) + { + if (_actionContextAccessor.ActionContext == null) + throw new InvalidOperationException("No action context, can't fill urls."); + + var urlHelper = _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext); + + if (source is TextTimelinePostContent textContent) + { + return new TimelinePostContentInfo + { + Type = TimelinePostContentTypes.Text, + Text = textContent.Text + }; + } + else if (source is ImageTimelinePostContent imageContent) + { + return new TimelinePostContentInfo + { + Type = TimelinePostContentTypes.Image, + Url = urlHelper.ActionLink(action: "PostDataGet", nameof(TimelineController)[0..^nameof(Controller).Length], new { source.Name }) + }; + } + } + } + + public class TimelineInfoAutoMapperProfile : Profile + { + public TimelineInfoAutoMapperProfile() + { + CreateMap().ForMember(u => u._links, opt => opt.MapFrom()); + } + } +} diff --git a/Timeline/Models/Http/TimelineCommon.cs b/Timeline/Models/Http/TimelineCommon.cs deleted file mode 100644 index 3be4f895..00000000 --- a/Timeline/Models/Http/TimelineCommon.cs +++ /dev/null @@ -1,116 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using System; -using System.Collections.Generic; -using System.Text.Json.Serialization; -using Timeline.Controllers; - -namespace Timeline.Models.Http -{ - public enum TimelineVisibility - { - /// - /// All people including those without accounts. - /// - Public, - /// - /// Only people signed in. - /// - Register, - /// - /// Only member. - /// - Private - } - - public static class TimelinePostContentTypes - { - public const string Text = "text"; - public const string Image = "image"; - } - - public interface ITimelinePostContent - { - public string Type { get; } - } - - public class TextTimelinePostContent : ITimelinePostContent - { - public TextTimelinePostContent() { } - public TextTimelinePostContent(string text) { Text = text; } - - public string Type { get; } = TimelinePostContentTypes.Text; - public string Text { get; set; } = ""; - } - - public class ImageTimelinePostContent : ITimelinePostContent - { - public ImageTimelinePostContent() { } - public ImageTimelinePostContent(string dataTag) { DataTag = dataTag; } - - public string Type { get; } = TimelinePostContentTypes.Image; - [JsonIgnore] - public string DataTag { get; set; } = ""; - public string? Url { get; set; } = null; - } - - public class TimelinePostInfo - { - public long Id { get; set; } - // use object to make json serializer use the runtime type - public object Content { get; set; } = default!; - public DateTime Time { get; set; } - public UserInfo Author { get; set; } = default!; - public DateTime LastUpdated { get; set; } = default!; - } - - public class TimelineInfo - { - public string? Name { get; set; } - public string Description { get; set; } = default!; - public UserInfo Owner { get; set; } = default!; - public TimelineVisibility Visibility { get; set; } -#pragma warning disable CA2227 // Collection properties should be read only - public List Members { get; set; } = default!; -#pragma warning restore CA2227 // Collection properties should be read only - -#pragma warning disable CA1707 // Identifiers should not contain underscores - public TimelineInfoLinks? _links { get; set; } -#pragma warning restore CA1707 // Identifiers should not contain underscores - } - - public class TimelineInfoLinks - { - public string Self { get; set; } = default!; - public string Posts { get; set; } = default!; - } - - public static class TimelineInfoExtensions - { - public static TimelineInfo FillLinks(this TimelineInfo info, IUrlHelper urlHelper) - { - if (info == null) - throw new ArgumentNullException(nameof(info)); - if (urlHelper == null) - throw new ArgumentNullException(nameof(urlHelper)); - - if (string.IsNullOrEmpty(info.Name)) - { - info._links = new TimelineInfoLinks - { - Self = urlHelper.ActionLink(nameof(PersonalTimelineController.TimelineGet), nameof(PersonalTimelineController)[0..^nameof(Controller).Length], new { info.Owner.Username }), - Posts = urlHelper.ActionLink(nameof(PersonalTimelineController.PostListGet), nameof(PersonalTimelineController)[0..^nameof(Controller).Length], new { info.Owner.Username }) - }; - } - else - { - info._links = new TimelineInfoLinks - { - Self = urlHelper.ActionLink(nameof(TimelineController.TimelineGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { info.Name }), - Posts = urlHelper.ActionLink(nameof(TimelineController.PostListGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { info.Name }) - }; - } - - return info; - } - } -} diff --git a/Timeline/Models/Http/TimelineController.cs b/Timeline/Models/Http/TimelineController.cs index ce5f3b98..b389c549 100644 --- a/Timeline/Models/Http/TimelineController.cs +++ b/Timeline/Models/Http/TimelineController.cs @@ -1,8 +1,8 @@ using System; using System.ComponentModel.DataAnnotations; -using Timeline.Models.Validation; +using TimelineApp.Models.Validation; -namespace Timeline.Models.Http +namespace TimelineApp.Models.Http { public class TimelinePostCreateRequestContent { diff --git a/Timeline/Models/Http/TokenController.cs b/Timeline/Models/Http/TokenController.cs index ea8b59ed..3376fb61 100644 --- a/Timeline/Models/Http/TokenController.cs +++ b/Timeline/Models/Http/TokenController.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace Timeline.Models.Http +namespace TimelineApp.Models.Http { public class CreateTokenRequest { diff --git a/Timeline/Models/Http/UserController.cs b/Timeline/Models/Http/UserController.cs index e4c95cbd..c024c757 100644 --- a/Timeline/Models/Http/UserController.cs +++ b/Timeline/Models/Http/UserController.cs @@ -1,9 +1,9 @@ using AutoMapper; using System.ComponentModel.DataAnnotations; -using Timeline.Models.Validation; -using Timeline.Services; +using TimelineApp.Models.Validation; +using TimelineApp.Services; -namespace Timeline.Models.Http +namespace TimelineApp.Models.Http { public class UserPatchRequest { diff --git a/Timeline/Models/Http/UserInfo.cs b/Timeline/Models/Http/UserInfo.cs index 68c6d8bd..fcbbe7c9 100644 --- a/Timeline/Models/Http/UserInfo.cs +++ b/Timeline/Models/Http/UserInfo.cs @@ -2,19 +2,19 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.AspNetCore.Mvc.Routing; -using Timeline.Controllers; -using Timeline.Services; +using System; +using TimelineApp.Controllers; -namespace Timeline.Models.Http +namespace TimelineApp.Models.Http { public class UserInfo { public string Username { get; set; } = default!; public string Nickname { get; set; } = default!; public bool? Administrator { get; set; } = default!; -#pragma warning disable CA1707 - public UserInfoLinks? _links { get; set; } -#pragma warning restore CA1707 +#pragma warning disable CA1707 // Identifiers should not contain underscores + public UserInfoLinks _links { get; set; } = default!; +#pragma warning restore CA1707 // Identifiers should not contain underscores } public class UserInfoLinks @@ -24,7 +24,7 @@ namespace Timeline.Models.Http public string Timeline { get; set; } = default!; } - public class UserInfoLinksValueResolver : IValueResolver + public class UserInfoLinksValueResolver : IValueResolver { private readonly IActionContextAccessor _actionContextAccessor; private readonly IUrlHelperFactory _urlHelperFactory; @@ -35,10 +35,10 @@ namespace Timeline.Models.Http _urlHelperFactory = urlHelperFactory; } - public UserInfoLinks? Resolve(User source, UserInfo destination, UserInfoLinks? destMember, ResolutionContext context) + public UserInfoLinks Resolve(User source, UserInfo destination, UserInfoLinks destMember, ResolutionContext context) { if (_actionContextAccessor.ActionContext == null) - return null; + throw new InvalidOperationException("No action context, can't fill urls."); var urlHelper = _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext); var result = new UserInfoLinks diff --git a/Timeline/Models/Timeline.cs b/Timeline/Models/Timeline.cs new file mode 100644 index 00000000..52f38e42 --- /dev/null +++ b/Timeline/Models/Timeline.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; + +namespace TimelineApp.Models +{ + public enum TimelineVisibility + { + /// + /// All people including those without accounts. + /// + Public, + /// + /// Only people signed in. + /// + Register, + /// + /// Only member. + /// + Private + } + + public static class TimelinePostContentTypes + { + public const string Text = "text"; + public const string Image = "image"; + } + + public interface ITimelinePostContent + { + public string Type { get; } + } + + public class TextTimelinePostContent : ITimelinePostContent + { + public TextTimelinePostContent(string text) { Text = text; } + + public string Type { get; } = TimelinePostContentTypes.Text; + public string Text { get; set; } + } + + public class ImageTimelinePostContent : ITimelinePostContent + { + public ImageTimelinePostContent(string dataTag) { DataTag = dataTag; } + + public string Type { get; } = TimelinePostContentTypes.Image; + public string DataTag { get; set; } + } + + public class TimelinePost + { + public long Id { get; set; } + public ITimelinePostContent Content { get; set; } = default!; + public DateTime Time { get; set; } + public User Author { get; set; } = default!; + public DateTime LastUpdated { get; set; } = default!; + } + + public class Timeline + { + public string Name { get; set; } = default!; + public string Description { get; set; } = default!; + public User Owner { get; set; } = default!; + public TimelineVisibility Visibility { get; set; } +#pragma warning disable CA2227 // Collection properties should be read only + public List Members { get; set; } = default!; +#pragma warning restore CA2227 // Collection properties should be read only + } + + public class TimelineChangePropertyRequest + { + public string? Description { get; set; } + public TimelineVisibility? Visibility { get; set; } + } +} diff --git a/Timeline/Models/User.cs b/Timeline/Models/User.cs new file mode 100644 index 00000000..3b88a1b3 --- /dev/null +++ b/Timeline/Models/User.cs @@ -0,0 +1,18 @@ +namespace TimelineApp.Models +{ + public class User + { + public string? Username { get; set; } + public string? Nickname { get; set; } + + #region adminsecret + public bool? Administrator { get; set; } + #endregion adminsecret + + #region secret + public long? Id { get; set; } + public string? Password { get; set; } + public long? Version { get; set; } + #endregion secret + } +} diff --git a/Timeline/Models/Validation/NameValidator.cs b/Timeline/Models/Validation/NameValidator.cs index dec2b872..cf276309 100644 --- a/Timeline/Models/Validation/NameValidator.cs +++ b/Timeline/Models/Validation/NameValidator.cs @@ -1,7 +1,7 @@ using System.Linq; -using static Timeline.Resources.Models.Validation.NameValidator; +using static TimelineApp.Resources.Models.Validation.NameValidator; -namespace Timeline.Models.Validation +namespace TimelineApp.Models.Validation { public class NameValidator : Validator { diff --git a/Timeline/Models/Validation/NicknameValidator.cs b/Timeline/Models/Validation/NicknameValidator.cs index 1d6ab163..cef80b9f 100644 --- a/Timeline/Models/Validation/NicknameValidator.cs +++ b/Timeline/Models/Validation/NicknameValidator.cs @@ -1,7 +1,7 @@ using System; -using static Timeline.Resources.Models.Validation.NicknameValidator; +using static TimelineApp.Resources.Models.Validation.NicknameValidator; -namespace Timeline.Models.Validation +namespace TimelineApp.Models.Validation { public class NicknameValidator : Validator { diff --git a/Timeline/Models/Validation/TimelineNameValidator.cs b/Timeline/Models/Validation/TimelineNameValidator.cs index f1ab54e8..68110466 100644 --- a/Timeline/Models/Validation/TimelineNameValidator.cs +++ b/Timeline/Models/Validation/TimelineNameValidator.cs @@ -1,6 +1,6 @@ using System; -namespace Timeline.Models.Validation +namespace TimelineApp.Models.Validation { public class TimelineNameValidator : NameValidator { diff --git a/Timeline/Models/Validation/UsernameValidator.cs b/Timeline/Models/Validation/UsernameValidator.cs index 87bbf85f..bc0a9fe4 100644 --- a/Timeline/Models/Validation/UsernameValidator.cs +++ b/Timeline/Models/Validation/UsernameValidator.cs @@ -1,6 +1,6 @@ using System; -namespace Timeline.Models.Validation +namespace TimelineApp.Models.Validation { public class UsernameValidator : NameValidator { diff --git a/Timeline/Models/Validation/Validator.cs b/Timeline/Models/Validation/Validator.cs index ead7dbef..2c61705e 100644 --- a/Timeline/Models/Validation/Validator.cs +++ b/Timeline/Models/Validation/Validator.cs @@ -2,10 +2,10 @@ using Microsoft.Extensions.Localization; using System; using System.ComponentModel.DataAnnotations; -using Timeline.Helpers; -using static Timeline.Resources.Models.Validation.Validator; +using TimelineApp.Helpers; +using static TimelineApp.Resources.Models.Validation.Validator; -namespace Timeline.Models.Validation +namespace TimelineApp.Models.Validation { /// /// A validator to validate value. diff --git a/Timeline/Program.cs b/Timeline/Program.cs index c49f74b0..70c67d87 100644 --- a/Timeline/Program.cs +++ b/Timeline/Program.cs @@ -4,11 +4,11 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using System.Resources; -using Timeline.Entities; +using TimelineApp.Entities; [assembly: NeutralResourcesLanguage("en")] -namespace Timeline +namespace TimelineApp { public static class Program { diff --git a/Timeline/Resources/Authentication/AuthHandler.Designer.cs b/Timeline/Resources/Authentication/AuthHandler.Designer.cs index fd4540ea..6005e2cd 100644 --- a/Timeline/Resources/Authentication/AuthHandler.Designer.cs +++ b/Timeline/Resources/Authentication/AuthHandler.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Authentication { +namespace TimelineApp.Resources.Authentication { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Authentication { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Authentication.AuthHandler", typeof(AuthHandler).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Authentication.AuthHandler", typeof(AuthHandler).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Controllers/ControllerAuthExtensions.Designer.cs b/Timeline/Resources/Controllers/ControllerAuthExtensions.Designer.cs index 70a1d605..019699d9 100644 --- a/Timeline/Resources/Controllers/ControllerAuthExtensions.Designer.cs +++ b/Timeline/Resources/Controllers/ControllerAuthExtensions.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Controllers { +namespace TimelineApp.Resources.Controllers { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Controllers { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Controllers.ControllerAuthExtensions", typeof(ControllerAuthExtensions).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Controllers.ControllerAuthExtensions", typeof(ControllerAuthExtensions).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Controllers/TimelineController.Designer.cs b/Timeline/Resources/Controllers/TimelineController.Designer.cs index ae6414e6..0560dd08 100644 --- a/Timeline/Resources/Controllers/TimelineController.Designer.cs +++ b/Timeline/Resources/Controllers/TimelineController.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Controllers { +namespace TimelineApp.Resources.Controllers { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Controllers { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Controllers.TimelineController", typeof(TimelineController).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Controllers.TimelineController", typeof(TimelineController).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Controllers/TokenController.Designer.cs b/Timeline/Resources/Controllers/TokenController.Designer.cs index a7c2864b..a4ea9657 100644 --- a/Timeline/Resources/Controllers/TokenController.Designer.cs +++ b/Timeline/Resources/Controllers/TokenController.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Controllers { +namespace TimelineApp.Resources.Controllers { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Controllers { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Controllers.TokenController", typeof(TokenController).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Controllers.TokenController", typeof(TokenController).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Controllers/UserAvatarController.Designer.cs b/Timeline/Resources/Controllers/UserAvatarController.Designer.cs index e6eeb1e8..0165c4f0 100644 --- a/Timeline/Resources/Controllers/UserAvatarController.Designer.cs +++ b/Timeline/Resources/Controllers/UserAvatarController.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Controllers { +namespace TimelineApp.Resources.Controllers { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Controllers { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Controllers.UserAvatarController", typeof(UserAvatarController).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Controllers.UserAvatarController", typeof(UserAvatarController).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Controllers/UserController.Designer.cs b/Timeline/Resources/Controllers/UserController.Designer.cs index c8067614..277b85e0 100644 --- a/Timeline/Resources/Controllers/UserController.Designer.cs +++ b/Timeline/Resources/Controllers/UserController.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Controllers { +namespace TimelineApp.Resources.Controllers { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Controllers { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Controllers.UserController", typeof(UserController).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Controllers.UserController", typeof(UserController).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Filters.Designer.cs b/Timeline/Resources/Filters.Designer.cs index dedfe498..3e29398d 100644 --- a/Timeline/Resources/Filters.Designer.cs +++ b/Timeline/Resources/Filters.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources { +namespace TimelineApp.Resources { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Filters", typeof(Filters).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Filters", typeof(Filters).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Messages.Designer.cs b/Timeline/Resources/Messages.Designer.cs index 4123cb8b..d85f5399 100644 --- a/Timeline/Resources/Messages.Designer.cs +++ b/Timeline/Resources/Messages.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources { +namespace TimelineApp.Resources { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Messages", typeof(Messages).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Messages", typeof(Messages).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Models/Http/Common.Designer.cs b/Timeline/Resources/Models/Http/Common.Designer.cs index 5165463e..fbbdeeca 100644 --- a/Timeline/Resources/Models/Http/Common.Designer.cs +++ b/Timeline/Resources/Models/Http/Common.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Models.Http { +namespace TimelineApp.Resources.Models.Http { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Models.Http { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Models.Http.Common", typeof(Common).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Models.Http.Common", typeof(Common).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Models/Validation/NameValidator.Designer.cs b/Timeline/Resources/Models/Validation/NameValidator.Designer.cs index 5b869226..af8ceeb7 100644 --- a/Timeline/Resources/Models/Validation/NameValidator.Designer.cs +++ b/Timeline/Resources/Models/Validation/NameValidator.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Models.Validation { +namespace TimelineApp.Resources.Models.Validation { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Models.Validation { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Models.Validation.NameValidator", typeof(NameValidator).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Models.Validation.NameValidator", typeof(NameValidator).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Models/Validation/NicknameValidator.Designer.cs b/Timeline/Resources/Models/Validation/NicknameValidator.Designer.cs index 522f305a..04d616b8 100644 --- a/Timeline/Resources/Models/Validation/NicknameValidator.Designer.cs +++ b/Timeline/Resources/Models/Validation/NicknameValidator.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Models.Validation { +namespace TimelineApp.Resources.Models.Validation { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Models.Validation { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Models.Validation.NicknameValidator", typeof(NicknameValidator).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Models.Validation.NicknameValidator", typeof(NicknameValidator).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Models/Validation/Validator.Designer.cs b/Timeline/Resources/Models/Validation/Validator.Designer.cs index 74d4c169..442c874b 100644 --- a/Timeline/Resources/Models/Validation/Validator.Designer.cs +++ b/Timeline/Resources/Models/Validation/Validator.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Models.Validation { +namespace TimelineApp.Resources.Models.Validation { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Models.Validation { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Models.Validation.Validator", typeof(Validator).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Models.Validation.Validator", typeof(Validator).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Services/DataManager.Designer.cs b/Timeline/Resources/Services/DataManager.Designer.cs index 0872059a..e5d5539a 100644 --- a/Timeline/Resources/Services/DataManager.Designer.cs +++ b/Timeline/Resources/Services/DataManager.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Services { +namespace TimelineApp.Resources.Services { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Services { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Services.DataManager", typeof(DataManager).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Services.DataManager", typeof(DataManager).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Services/Exception.Designer.cs b/Timeline/Resources/Services/Exception.Designer.cs index 0c721d92..2fd350f9 100644 --- a/Timeline/Resources/Services/Exception.Designer.cs +++ b/Timeline/Resources/Services/Exception.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Services { +namespace TimelineApp.Resources.Services { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Services { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Services.Exception", typeof(Exception).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Services.Exception", typeof(Exception).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Services/TimelineService.Designer.cs b/Timeline/Resources/Services/TimelineService.Designer.cs index 4c3de1cd..65f98577 100644 --- a/Timeline/Resources/Services/TimelineService.Designer.cs +++ b/Timeline/Resources/Services/TimelineService.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Services { +namespace TimelineApp.Resources.Services { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Services { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Services.TimelineService", typeof(TimelineService).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Services.TimelineService", typeof(TimelineService).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Services/UserAvatarService.Designer.cs b/Timeline/Resources/Services/UserAvatarService.Designer.cs index c72d4215..1bed55f3 100644 --- a/Timeline/Resources/Services/UserAvatarService.Designer.cs +++ b/Timeline/Resources/Services/UserAvatarService.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Services { +namespace TimelineApp.Resources.Services { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Services { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Services.UserAvatarService", typeof(UserAvatarService).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Services.UserAvatarService", typeof(UserAvatarService).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Services/UserService.Designer.cs b/Timeline/Resources/Services/UserService.Designer.cs index cdf7f390..73cd7bcd 100644 --- a/Timeline/Resources/Services/UserService.Designer.cs +++ b/Timeline/Resources/Services/UserService.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Services { +namespace TimelineApp.Resources.Services { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Services { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Services.UserService", typeof(UserService).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Services.UserService", typeof(UserService).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Resources/Services/UserTokenService.Designer.cs b/Timeline/Resources/Services/UserTokenService.Designer.cs index 3c3c7e41..6cdca6a9 100644 --- a/Timeline/Resources/Services/UserTokenService.Designer.cs +++ b/Timeline/Resources/Services/UserTokenService.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Timeline.Resources.Services { +namespace TimelineApp.Resources.Services { using System; @@ -39,7 +39,7 @@ namespace Timeline.Resources.Services { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Services.UserTokenService", typeof(UserTokenService).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimelineApp.Resources.Services.UserTokenService", typeof(UserTokenService).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Timeline/Services/BadPasswordException.cs b/Timeline/Services/BadPasswordException.cs index f609371d..93251055 100644 --- a/Timeline/Services/BadPasswordException.cs +++ b/Timeline/Services/BadPasswordException.cs @@ -1,7 +1,7 @@ using System; -using Timeline.Helpers; +using TimelineApp.Helpers; -namespace Timeline.Services +namespace TimelineApp.Services { [Serializable] public class BadPasswordException : Exception diff --git a/Timeline/Services/Clock.cs b/Timeline/Services/Clock.cs index 0499c0c6..68441e92 100644 --- a/Timeline/Services/Clock.cs +++ b/Timeline/Services/Clock.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace Timeline.Services +namespace TimelineApp.Services { /// /// Convenient for unit test. diff --git a/Timeline/Services/ConflictException.cs b/Timeline/Services/ConflictException.cs index 6ede183a..be9ec2c0 100644 --- a/Timeline/Services/ConflictException.cs +++ b/Timeline/Services/ConflictException.cs @@ -1,6 +1,6 @@ using System; -namespace Timeline.Services +namespace TimelineApp.Services { /// /// Thrown when a resource already exists and conflicts with the given resource. diff --git a/Timeline/Services/DataManager.cs b/Timeline/Services/DataManager.cs index d447b0d5..a4241c1b 100644 --- a/Timeline/Services/DataManager.cs +++ b/Timeline/Services/DataManager.cs @@ -2,9 +2,9 @@ using System; using System.Linq; using System.Threading.Tasks; -using Timeline.Entities; +using TimelineApp.Entities; -namespace Timeline.Services +namespace TimelineApp.Services { /// /// A data manager controlling data. diff --git a/Timeline/Services/DatabaseCorruptedException.cs b/Timeline/Services/DatabaseCorruptedException.cs index 9988e0ad..f5bd0c85 100644 --- a/Timeline/Services/DatabaseCorruptedException.cs +++ b/Timeline/Services/DatabaseCorruptedException.cs @@ -1,6 +1,6 @@ using System; -namespace Timeline.Services +namespace TimelineApp.Services { [Serializable] public class DatabaseCorruptedException : Exception diff --git a/Timeline/Services/ETagGenerator.cs b/Timeline/Services/ETagGenerator.cs index d328ea20..b7efd037 100644 --- a/Timeline/Services/ETagGenerator.cs +++ b/Timeline/Services/ETagGenerator.cs @@ -2,7 +2,7 @@ using System.Security.Cryptography; using System.Threading.Tasks; -namespace Timeline.Services +namespace TimelineApp.Services { public interface IETagGenerator { diff --git a/Timeline/Services/ImageException.cs b/Timeline/Services/ImageException.cs index c6126aa3..f3f3b010 100644 --- a/Timeline/Services/ImageException.cs +++ b/Timeline/Services/ImageException.cs @@ -1,7 +1,7 @@ using System; using System.Globalization; -namespace Timeline.Services +namespace TimelineApp.Services { [Serializable] public class ImageException : Exception diff --git a/Timeline/Services/ImageValidator.cs b/Timeline/Services/ImageValidator.cs index c331d912..f10bb4d0 100644 --- a/Timeline/Services/ImageValidator.cs +++ b/Timeline/Services/ImageValidator.cs @@ -4,7 +4,7 @@ using System; using System.Linq; using System.Threading.Tasks; -namespace Timeline.Services +namespace TimelineApp.Services { public interface IImageValidator { diff --git a/Timeline/Services/JwtUserTokenBadFormatException.cs b/Timeline/Services/JwtUserTokenBadFormatException.cs index c528c3e3..81450486 100644 --- a/Timeline/Services/JwtUserTokenBadFormatException.cs +++ b/Timeline/Services/JwtUserTokenBadFormatException.cs @@ -1,8 +1,8 @@ using System; using System.Globalization; -using static Timeline.Resources.Services.Exception; +using static TimelineApp.Resources.Services.Exception; -namespace Timeline.Services +namespace TimelineApp.Services { [Serializable] public class JwtUserTokenBadFormatException : UserTokenBadFormatException diff --git a/Timeline/Services/PasswordBadFormatException.cs b/Timeline/Services/PasswordBadFormatException.cs index 2029ebb4..4db52092 100644 --- a/Timeline/Services/PasswordBadFormatException.cs +++ b/Timeline/Services/PasswordBadFormatException.cs @@ -1,6 +1,6 @@ using System; -namespace Timeline.Services +namespace TimelineApp.Services { [Serializable] diff --git a/Timeline/Services/PasswordService.cs b/Timeline/Services/PasswordService.cs index e04a861b..b08fe14d 100644 --- a/Timeline/Services/PasswordService.cs +++ b/Timeline/Services/PasswordService.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.CompilerServices; using System.Security.Cryptography; -namespace Timeline.Services +namespace TimelineApp.Services { /// /// Hashed password is of bad format. diff --git a/Timeline/Services/PathProvider.cs b/Timeline/Services/PathProvider.cs index 15e66972..79f309a1 100644 --- a/Timeline/Services/PathProvider.cs +++ b/Timeline/Services/PathProvider.cs @@ -5,7 +5,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; -namespace Timeline.Services +namespace TimelineApp.Services { public interface IPathProvider { diff --git a/Timeline/Services/TimelineNotExistException.cs b/Timeline/Services/TimelineNotExistException.cs index 6dfd0bab..b5bb0580 100644 --- a/Timeline/Services/TimelineNotExistException.cs +++ b/Timeline/Services/TimelineNotExistException.cs @@ -1,6 +1,6 @@ using System; -namespace Timeline.Services +namespace TimelineApp.Services { [Serializable] public class TimelineNotExistException : Exception diff --git a/Timeline/Services/TimelinePostNotExistException.cs b/Timeline/Services/TimelinePostNotExistException.cs index c542e63e..488bfe2b 100644 --- a/Timeline/Services/TimelinePostNotExistException.cs +++ b/Timeline/Services/TimelinePostNotExistException.cs @@ -1,6 +1,6 @@ using System; -namespace Timeline.Services +namespace TimelineApp.Services { [Serializable] public class TimelinePostNotExistException : Exception diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs index a2b7b5ea..8c1e62d4 100644 --- a/Timeline/Services/TimelineService.cs +++ b/Timeline/Services/TimelineService.cs @@ -1,5 +1,4 @@ -using AutoMapper; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using SixLabors.ImageSharp; using System; @@ -7,12 +6,12 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Threading.Tasks; -using Timeline.Entities; -using Timeline.Models.Http; -using Timeline.Models.Validation; -using static Timeline.Resources.Services.TimelineService; +using TimelineApp.Entities; +using TimelineApp.Models; +using TimelineApp.Models.Validation; +using static TimelineApp.Resources.Services.TimelineService; -namespace Timeline.Services +namespace TimelineApp.Services { public enum TimelineUserRelationshipType { @@ -42,70 +41,63 @@ namespace Timeline.Services } /// - /// This define the common interface of both personal timeline - /// and normal timeline. + /// This define the common interface of both personal timeline and normal timeline. /// /// - /// The "name" parameter in method means name of timeline in - /// while username of the owner - /// of the personal timeline in . + /// The "name" parameter in each method has different meaning. + /// => name of the ordinary timeline + /// => username of the owner of the personal timeline + /// => username if begin with '@' otherwise timeline name + /// + /// is thrown when name is illegal. + /// For ordinary timeline, it means the name is not a valid timeline name. + /// For personal timeline, it means the name is not a valid username. + /// + /// is thrown when timeline does not exist. + /// For ordinary timeline, it means the timeline of the name does not exist. + /// For personal timeline, it means the user with the username does not exist and the inner exception should be a . /// public interface IBaseTimelineService { /// /// Get the timeline info. /// - /// Username or the timeline name. See remarks of . + /// See remarks of . /// The timeline info. /// Thrown when is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). - /// - /// Thrown when timeline does not exist. - /// For normal timeline, it means the name does not exist. - /// For personal timeline, it means the user of that username does not exist - /// and the inner exception should be a . - /// - Task GetTimeline(string name); + /// See remarks of . + /// See remarks of . + Task GetTimeline(string name); /// /// Set the properties of a timeline. /// - /// Username or the timeline name. See remarks of . + /// See remarks of . /// The new properties. Null member means not to change. - /// The timeline info. - /// Thrown when is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). - /// - /// Thrown when timeline does not exist. - /// For normal timeline, it means the name does not exist. - /// For personal timeline, it means the user of that username does not exist - /// and the inner exception should be a . - /// - Task ChangeProperty(string name, TimelinePatchRequest newProperties); + /// Thrown when or is null. + /// See remarks of . + /// See remarks of . + Task ChangeProperty(string name, TimelineChangePropertyRequest newProperties); /// /// Get all the posts in the timeline. /// - /// Username or the timeline name. See remarks of . + /// See remarks of . /// A list of all posts. /// Thrown when is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). - /// - /// Thrown when timeline does not exist. - /// For normal timeline, it means the name does not exist. - /// For personal timeline, it means the user of that username does not exist - /// and the inner exception should be a . - /// - Task> GetPosts(string name); + /// See remarks of . + /// See remarks of . + Task> GetPosts(string name); /// /// Get the data of a post. /// - /// Username or the timeline name. See remarks of . + /// See remarks of . /// The id of the post. /// The data and its type. /// Thrown when is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). + /// See remarks of . + /// See remarks of . /// Thrown when post of does not exist or has been deleted. /// Thrown when post has no data. See remarks. /// @@ -116,55 +108,40 @@ namespace Timeline.Services /// /// Create a new text post in timeline. /// - /// Username or the timeline name. See remarks of . - /// The author's id. + /// See remarks of . + /// The author's user id. /// The content text. /// The time of the post. If null, then use current time. /// The info of the created post. /// Thrown when or is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). - /// - /// Thrown when timeline does not exist. - /// For normal timeline, it means the name does not exist. - /// For personal timeline, it means the user of that username does not exist - /// and the inner exception should be a . - /// + /// See remarks of . + /// See remarks of . /// Thrown if user with does not exist. - Task CreateTextPost(string name, long authorId, string text, DateTime? time); + Task CreateTextPost(string name, long authorId, string text, DateTime? time); /// /// Create a new image post in timeline. /// - /// Username or the timeline name. See remarks of . - /// The author's id. + /// See remarks of . + /// The author's user id. /// The image data. /// The time of the post. If null, then use current time. /// The info of the created post. - /// Thrown when or is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). - /// - /// Thrown when timeline does not exist. - /// For normal timeline, it means the name does not exist. - /// For personal timeline, it means the user of that username does not exist - /// and the inner exception should be a . - /// + /// Thrown when or is null. + /// See remarks of . + /// See remarks of . /// Thrown if user with does not exist. /// Thrown if data is not a image. Validated by . - Task CreateImagePost(string name, long authorId, byte[] data, DateTime? time); + Task CreateImagePost(string name, long authorId, byte[] data, DateTime? time); /// - /// Delete a post + /// Delete a post. /// - /// Username or the timeline name. See remarks of . + /// See remarks of . /// The id of the post to delete. - /// Thrown when or is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). - /// - /// Thrown when timeline does not exist. - /// For normal timeline, it means the name does not exist. - /// For personal timeline, it means the user of that username does not exist - /// and the inner exception should be a . - /// + /// Thrown when is null. + /// See remarks of . + /// See remarks of . /// /// Thrown when the post with given id does not exist or is deleted already. /// @@ -177,18 +154,13 @@ namespace Timeline.Services /// /// Remove members to a timeline. /// - /// Username or the timeline name. See remarks of . + /// See remarks of . /// A list of usernames of members to add. May be null. /// A list of usernames of members to remove. May be null. /// Thrown when is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). + /// See remarks of . + /// See remarks of . /// Thrown when names in or is not a valid username. - /// - /// Thrown when timeline does not exist. - /// For normal timeline, it means the name does not exist. - /// For personal timeline, it means the user of that username does not exist - /// and the inner exception should be a . - /// /// /// Thrown when one of the user to change does not exist. /// @@ -204,17 +176,12 @@ namespace Timeline.Services /// /// Check whether a user can manage(change timeline info, member, ...) a timeline. /// - /// - /// + /// See remarks of . + /// The user id. /// True if the user can manage the timeline, otherwise false. /// Thrown when is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). - /// - /// Thrown when timeline does not exist. - /// For normal timeline, it means the name does not exist. - /// For personal timeline, it means the user of that username does not exist - /// and the inner exception should be a . - /// + /// See remarks of . + /// See remarks of . /// /// This method does not check whether visitor is administrator. /// Return false if user with user id does not exist. @@ -224,17 +191,12 @@ namespace Timeline.Services /// /// Verify whether a visitor has the permission to read a timeline. /// - /// Username or the timeline name. See remarks of . + /// See remarks of . /// The id of the user to check on. Null means visitor without account. /// True if can read, false if can't read. /// Thrown when is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). - /// - /// Thrown when timeline does not exist. - /// For normal timeline, it means the name does not exist. - /// For personal timeline, it means the user of that username does not exist - /// and the inner exception should be a . - /// + /// See remarks of . + /// See remarks of . /// /// This method does not check whether visitor is administrator. /// Return false if user with visitor id does not exist. @@ -244,17 +206,12 @@ namespace Timeline.Services /// /// Verify whether a user has the permission to modify a post. /// - /// Username or the timeline name. See remarks of . + /// See remarks of . /// The id of the user to check on. /// True if can modify, false if can't modify. /// Thrown when is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). - /// - /// Thrown when timeline does not exist. - /// For normal timeline, it means the name does not exist. - /// For personal timeline, it means the user of that username does not exist - /// and the inner exception should be a . - /// + /// See remarks of . + /// See remarks of . /// /// Thrown when the post with given id does not exist or is deleted already. /// @@ -268,17 +225,12 @@ namespace Timeline.Services /// /// Verify whether a user is member of a timeline. /// - /// Username or the timeline name. See remarks of . + /// See remarks of . /// The id of user to check on. /// True if it is a member, false if not. /// Thrown when is null. - /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). - /// - /// Thrown when timeline does not exist. - /// For normal timeline, it means the name does not exist. - /// For personal timeline, it means the user of that username does not exist - /// and the inner exception should be a . - /// + /// See remarks of . + /// See remarks of . /// /// Timeline owner is also considered as a member. /// Return false when user with user id does not exist. @@ -300,7 +252,7 @@ namespace Timeline.Services /// /// If user with related user id does not exist, empty list will be returned. /// - Task> GetTimelines(TimelineUserRelationship? relate = null, List? visibility = null); + Task> GetTimelines(TimelineUserRelationship? relate = null, List? visibility = null); /// /// Create a timeline. @@ -312,7 +264,7 @@ namespace Timeline.Services /// Thrown when timeline name is invalid. /// Thrown when the timeline already exists. /// Thrown when the owner user does not exist. - Task CreateTimeline(string name, long owner); + Task CreateTimeline(string name, long owner); /// /// Delete a timeline. @@ -324,25 +276,29 @@ namespace Timeline.Services Task DeleteTimeline(string name); } + public interface IOrdinaryTimelineService : IBaseTimelineService + { + + } + public interface IPersonalTimelineService : IBaseTimelineService { } - public abstract class BaseTimelineService : IBaseTimelineService + public abstract class BaseTimelineManager : IBaseTimelineService { - protected BaseTimelineService(ILoggerFactory loggerFactory, DatabaseContext database, IImageValidator imageValidator, IDataManager dataManager, IUserService userService, IMapper mapper, IClock clock) + protected BaseTimelineManager(ILoggerFactory loggerFactory, DatabaseContext database, IImageValidator imageValidator, IDataManager dataManager, IUserService userService, IClock clock) { - _logger = loggerFactory.CreateLogger(); + _logger = loggerFactory.CreateLogger(); Clock = clock; Database = database; ImageValidator = imageValidator; DataManager = dataManager; UserService = userService; - Mapper = mapper; } - private ILogger _logger; + private ILogger _logger; protected IClock Clock { get; } @@ -354,20 +310,6 @@ namespace Timeline.Services protected IDataManager DataManager { get; } protected IUserService UserService { get; } - protected IMapper Mapper { get; } - - protected TimelineEntity CreateNewEntity(string? name, long owner) - { - return new TimelineEntity - { - CurrentPostLocalId = 0, - Name = name, - OwnerId = owner, - Visibility = TimelineVisibility.Register, - CreateTime = Clock.GetCurrentTime() - }; - } - /// /// Find the timeline id by the name. /// For details, see remarks. @@ -392,7 +334,7 @@ namespace Timeline.Services /// protected abstract Task FindTimelineId(string name); - public async Task GetTimeline(string name) + public async Task GetTimeline(string name) { if (name == null) throw new ArgumentNullException(nameof(name)); @@ -403,17 +345,17 @@ namespace Timeline.Services var timelineMemberEntities = await Database.TimelineMembers.Where(m => m.TimelineId == timelineId).Select(m => new { m.UserId }).ToListAsync(); - var owner = Mapper.Map(await UserService.GetUserById(timelineEntity.OwnerId)); + var owner = await UserService.GetUserById(timelineEntity.OwnerId); - var members = new List(); + var members = new List(); foreach (var memberEntity in timelineMemberEntities) { - members.Add(Mapper.Map(await UserService.GetUserById(memberEntity.UserId))); + members.Add(await UserService.GetUserById(memberEntity.UserId)); } - return new TimelineInfo + return new Timeline { - Name = timelineEntity.Name, + Name = timelineEntity.Name ?? ("@" + owner.Username), Description = timelineEntity.Description ?? "", Owner = owner, Visibility = timelineEntity.Visibility, @@ -421,7 +363,7 @@ namespace Timeline.Services }; } - public async Task> GetPosts(string name) + public async Task> GetPosts(string name) { if (name == null) throw new ArgumentNullException(nameof(name)); @@ -429,12 +371,12 @@ namespace Timeline.Services var timelineId = await FindTimelineId(name); var postEntities = await Database.TimelinePosts.OrderBy(p => p.Time).Where(p => p.TimelineId == timelineId && p.Content != null).ToListAsync(); - var posts = new List(); + var posts = new List(); foreach (var entity in postEntities) { if (entity.Content != null) // otherwise it is deleted { - var author = Mapper.Map(await UserService.GetUserById(entity.AuthorId)); + var author = await UserService.GetUserById(entity.AuthorId); var type = entity.ContentType; @@ -445,7 +387,7 @@ namespace Timeline.Services _ => throw new DatabaseCorruptedException(string.Format(CultureInfo.InvariantCulture, ExceptionDatabaseUnknownContentType, type)) }; - posts.Add(new TimelinePostInfo + posts.Add(new TimelinePost { Id = entity.LocalId, Content = content, @@ -502,7 +444,7 @@ namespace Timeline.Services }; } - public async Task CreateTextPost(string name, long authorId, string text, DateTime? time) + public async Task CreateTextPost(string name, long authorId, string text, DateTime? time) { if (name == null) throw new ArgumentNullException(nameof(name)); @@ -512,7 +454,7 @@ namespace Timeline.Services var timelineId = await FindTimelineId(name); var timelineEntity = await Database.Timelines.Where(t => t.Id == timelineId).SingleAsync(); - var author = Mapper.Map(await UserService.GetUserById(authorId)); + var author = await UserService.GetUserById(authorId); var currentTime = Clock.GetCurrentTime(); var finalTime = time ?? currentTime; @@ -532,7 +474,7 @@ namespace Timeline.Services Database.TimelinePosts.Add(postEntity); await Database.SaveChangesAsync(); - return new TimelinePostInfo + return new TimelinePost { Id = postEntity.LocalId, Content = new TextTimelinePostContent(text), @@ -542,7 +484,7 @@ namespace Timeline.Services }; } - public async Task CreateImagePost(string name, long authorId, byte[] data, DateTime? time) + public async Task CreateImagePost(string name, long authorId, byte[] data, DateTime? time) { if (name == null) throw new ArgumentNullException(nameof(name)); @@ -552,7 +494,7 @@ namespace Timeline.Services var timelineId = await FindTimelineId(name); var timelineEntity = await Database.Timelines.Where(t => t.Id == timelineId).SingleAsync(); - var author = Mapper.Map(await UserService.GetUserById(authorId)); + var author = await UserService.GetUserById(authorId); var imageFormat = await ImageValidator.Validate(data); @@ -579,7 +521,7 @@ namespace Timeline.Services Database.TimelinePosts.Add(postEntity); await Database.SaveChangesAsync(); - return new TimelinePostInfo + return new TimelinePost { Id = postEntity.LocalId, Content = new ImageTimelinePostContent(tag), @@ -619,7 +561,7 @@ namespace Timeline.Services } } - public async Task ChangeProperty(string name, TimelinePatchRequest newProperties) + public async Task ChangeProperty(string name, TimelineChangePropertyRequest newProperties) { if (name == null) throw new ArgumentNullException(nameof(name)); @@ -789,7 +731,7 @@ namespace Timeline.Services } } - public class TimelineService : BaseTimelineService, ITimelineService + public class OrdinaryTimelineService : BaseTimelineManager, IOrdinaryTimelineService { private readonly TimelineNameValidator _timelineNameValidator = new TimelineNameValidator(); @@ -801,8 +743,8 @@ namespace Timeline.Services } } - public TimelineService(ILoggerFactory loggerFactory, DatabaseContext database, IImageValidator imageValidator, IDataManager dataManager, IUserService userService, IMapper mapper, IClock clock) - : base(loggerFactory, database, imageValidator, dataManager, userService, mapper, clock) + public OrdinaryTimelineService(ILoggerFactory loggerFactory, DatabaseContext database, IImageValidator imageValidator, IDataManager dataManager, IUserService userService, IClock clock) + : base(loggerFactory, database, imageValidator, dataManager, userService, clock) { } @@ -825,8 +767,89 @@ namespace Timeline.Services return timelineEntity.Id; } } + } + + public class PersonalTimelineService : BaseTimelineManager, IPersonalTimelineService + { + public PersonalTimelineService(ILoggerFactory loggerFactory, DatabaseContext database, IImageValidator imageValidator, IDataManager dataManager, IUserService userService, IClock clock) + : base(loggerFactory, database, imageValidator, dataManager, userService, clock) + { + + } - public async Task> GetTimelines(TimelineUserRelationship? relate = null, List? visibility = null) + protected override async Task FindTimelineId(string name) + { + if (name == null) + throw new ArgumentNullException(nameof(name)); + + long userId; + try + { + userId = await UserService.GetUserIdByUsername(name); + } + catch (ArgumentException e) + { + throw new ArgumentException(ExceptionFindTimelineUsernameBadFormat, nameof(name), e); + } + catch (UserNotExistException e) + { + throw new TimelineNotExistException(name, e); + } + + var timelineEntity = await Database.Timelines.Where(t => t.OwnerId == userId && t.Name == null).Select(t => new { t.Id }).SingleOrDefaultAsync(); + + if (timelineEntity != null) + { + return timelineEntity.Id; + } + else + { + var newTimelineEntity = new TimelineEntity + { + CurrentPostLocalId = 0, + Name = null, + OwnerId = userId, + Visibility = TimelineVisibility.Register, + CreateTime = Clock.GetCurrentTime() + }; + Database.Timelines.Add(newTimelineEntity); + await Database.SaveChangesAsync(); + + return newTimelineEntity.Id; + } + } + } + + public class TimelineService : ITimelineService + { + private readonly TimelineNameValidator _timelineNameValidator = new TimelineNameValidator(); + + private readonly DatabaseContext _database; + + private readonly IUserService _userService; + private readonly IClock _clock; + + private readonly IOrdinaryTimelineService _ordinaryTimelineService; + private readonly IPersonalTimelineService _personalTimelineService; + + public TimelineService(DatabaseContext database, IUserService userService, IClock clock, IOrdinaryTimelineService ordinaryTimelineService, IPersonalTimelineService personalTimelineService) + { + _database = database; + _userService = userService; + _clock = clock; + _ordinaryTimelineService = ordinaryTimelineService; + _personalTimelineService = personalTimelineService; + } + + private void ValidateTimelineName(string name, string paramName) + { + if (!_timelineNameValidator.Validate(name, out var message)) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, ExceptionTimelineNameBadFormat, message), paramName); + } + } + + public async Task> GetTimelines(TimelineUserRelationship? relate = null, List? visibility = null) { List entities; @@ -843,7 +866,7 @@ namespace Timeline.Services if (relate == null) { - entities = await ApplyTimelineVisibilityFilter(Database.Timelines).Include(t => t.Members).ToListAsync(); + entities = await ApplyTimelineVisibilityFilter(_database.Timelines).Include(t => t.Members).ToListAsync(); } else { @@ -851,31 +874,32 @@ namespace Timeline.Services if ((relate.Type & TimelineUserRelationshipType.Own) != 0) { - entities.AddRange(await ApplyTimelineVisibilityFilter(Database.Timelines.Where(t => t.OwnerId == relate.UserId)).Include(t => t.Members).ToListAsync()); + entities.AddRange(await ApplyTimelineVisibilityFilter(_database.Timelines.Where(t => t.OwnerId == relate.UserId)).Include(t => t.Members).ToListAsync()); } if ((relate.Type & TimelineUserRelationshipType.Join) != 0) { - entities.AddRange(await ApplyTimelineVisibilityFilter(Database.TimelineMembers.Where(m => m.UserId == relate.UserId).Include(m => m.Timeline).ThenInclude(t => t.Members).Select(m => m.Timeline)).ToListAsync()); + entities.AddRange(await ApplyTimelineVisibilityFilter(_database.TimelineMembers.Where(m => m.UserId == relate.UserId).Include(m => m.Timeline).ThenInclude(t => t.Members).Select(m => m.Timeline)).ToListAsync()); } } - var result = new List(); + var result = new List(); foreach (var entity in entities) { - var timeline = new TimelineInfo + var owner = await _userService.GetUserById(entity.OwnerId); + var timeline = new Timeline { - Name = entity.Name, + Name = entity.Name ?? ("@" + owner.Username), Description = entity.Description ?? "", - Owner = Mapper.Map(await UserService.GetUserById(entity.OwnerId)), + Owner = owner, Visibility = entity.Visibility, - Members = new List() + Members = new List() }; foreach (var m in entity.Members) { - timeline.Members.Add(Mapper.Map(await UserService.GetUserById(m.UserId))); + timeline.Members.Add(await _userService.GetUserById(m.UserId)); } result.Add(timeline); @@ -884,31 +908,39 @@ namespace Timeline.Services return result; } - public async Task CreateTimeline(string name, long owner) + public async Task CreateTimeline(string name, long owner) { if (name == null) throw new ArgumentNullException(nameof(name)); ValidateTimelineName(name, nameof(name)); - var user = await UserService.GetUserById(owner); + var user = await _userService.GetUserById(owner); - var conflict = await Database.Timelines.AnyAsync(t => t.Name == name); + var conflict = await _database.Timelines.AnyAsync(t => t.Name == name); if (conflict) throw new ConflictException(ExceptionTimelineNameConflict); - var newEntity = CreateNewEntity(name, owner); - Database.Timelines.Add(newEntity); - await Database.SaveChangesAsync(); + var newEntity = new TimelineEntity + { + CurrentPostLocalId = 0, + Name = name, + OwnerId = owner, + Visibility = TimelineVisibility.Register, + CreateTime = _clock.GetCurrentTime() + }; + + _database.Timelines.Add(newEntity); + await _database.SaveChangesAsync(); - return new TimelineInfo + return new Timeline { Name = name, Description = "", - Owner = Mapper.Map(user), + Owner = user, Visibility = newEntity.Visibility, - Members = new List() + Members = new List() }; } @@ -919,57 +951,103 @@ namespace Timeline.Services ValidateTimelineName(name, nameof(name)); - var entity = await Database.Timelines.Where(t => t.Name == name).SingleOrDefaultAsync(); + var entity = await _database.Timelines.Where(t => t.Name == name).SingleOrDefaultAsync(); if (entity == null) throw new TimelineNotExistException(name); - Database.Timelines.Remove(entity); - await Database.SaveChangesAsync(); + _database.Timelines.Remove(entity); + await _database.SaveChangesAsync(); } - } - - public class PersonalTimelineService : BaseTimelineService, IPersonalTimelineService - { - public PersonalTimelineService(ILoggerFactory loggerFactory, DatabaseContext database, IImageValidator imageValidator, IDataManager dataManager, IUserService userService, IMapper mapper, IClock clock) - : base(loggerFactory, database, imageValidator, dataManager, userService, mapper, clock) - { - } - protected override async Task FindTimelineId(string name) + private IBaseTimelineService BranchName(string name, out string realName) { if (name == null) throw new ArgumentNullException(nameof(name)); - long userId; - try - { - userId = await UserService.GetUserIdByUsername(name); - } - catch (ArgumentException e) + if (name.StartsWith('@')) { - throw new ArgumentException(ExceptionFindTimelineUsernameBadFormat, nameof(name), e); + realName = name.Substring(1); + return _personalTimelineService; } - catch (UserNotExistException e) + else { - throw new TimelineNotExistException(name, e); + realName = name; + return _ordinaryTimelineService; } + } - var timelineEntity = await Database.Timelines.Where(t => t.OwnerId == userId && t.Name == null).Select(t => new { t.Id }).SingleOrDefaultAsync(); + public Task GetTimeline(string name) + { + var s = BranchName(name, out var realName); + return s.GetTimeline(realName); + } - if (timelineEntity != null) - { - return timelineEntity.Id; - } - else - { - var newTimelineEntity = CreateNewEntity(null, userId); - Database.Timelines.Add(newTimelineEntity); - await Database.SaveChangesAsync(); + public Task ChangeProperty(string name, TimelineChangePropertyRequest newProperties) + { + var s = BranchName(name, out var realName); + return s.ChangeProperty(realName, newProperties); + } - return newTimelineEntity.Id; - } + public Task> GetPosts(string name) + { + var s = BranchName(name, out var realName); + return s.GetPosts(realName); + } + + public Task GetPostData(string name, long postId) + { + var s = BranchName(name, out var realName); + return s.GetPostData(realName, postId); + } + + public Task CreateTextPost(string name, long authorId, string text, DateTime? time) + { + var s = BranchName(name, out var realName); + return s.CreateTextPost(realName, authorId, text, time); + } + + public Task CreateImagePost(string name, long authorId, byte[] data, DateTime? time) + { + var s = BranchName(name, out var realName); + return s.CreateImagePost(realName, authorId, data, time); + } + + public Task DeletePost(string name, long id) + { + var s = BranchName(name, out var realName); + return s.DeletePost(realName, id); + } + + public Task ChangeMember(string name, IList? add, IList? remove) + { + var s = BranchName(name, out var realName); + return s.ChangeMember(realName, add, remove); + } + + public Task HasManagePermission(string name, long userId) + { + var s = BranchName(name, out var realName); + return s.HasManagePermission(realName, userId); + } + + public Task HasReadPermission(string name, long? visitorId) + { + var s = BranchName(name, out var realName); + return s.HasReadPermission(realName, visitorId); + } + + public Task HasPostModifyPermission(string name, long id, long modifierId) + { + var s = BranchName(name, out var realName); + return s.HasPostModifyPermission(realName, id, modifierId); + } + + public Task IsMemberOf(string name, long userId) + { + var s = BranchName(name, out var realName); + return s.IsMemberOf(realName, userId); } } } diff --git a/Timeline/Services/User.cs b/Timeline/Services/User.cs deleted file mode 100644 index 09a472e5..00000000 --- a/Timeline/Services/User.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Timeline.Services -{ - public class User - { - public string? Username { get; set; } - public string? Nickname { get; set; } - - #region adminsecret - public bool? Administrator { get; set; } - #endregion adminsecret - - #region secret - public long? Id { get; set; } - public string? Password { get; set; } - public long? Version { get; set; } - #endregion secret - } -} diff --git a/Timeline/Services/UserAvatarService.cs b/Timeline/Services/UserAvatarService.cs index 1b1be698..5f2ce4ed 100644 --- a/Timeline/Services/UserAvatarService.cs +++ b/Timeline/Services/UserAvatarService.cs @@ -6,10 +6,10 @@ using System; using System.IO; using System.Linq; using System.Threading.Tasks; -using Timeline.Entities; -using Timeline.Helpers; +using TimelineApp.Entities; +using TimelineApp.Helpers; -namespace Timeline.Services +namespace TimelineApp.Services { public class Avatar { diff --git a/Timeline/Services/UserNotExistException.cs b/Timeline/Services/UserNotExistException.cs index fd0b5ecf..b51378ed 100644 --- a/Timeline/Services/UserNotExistException.cs +++ b/Timeline/Services/UserNotExistException.cs @@ -1,7 +1,7 @@ using System; -using Timeline.Helpers; +using TimelineApp.Helpers; -namespace Timeline.Services +namespace TimelineApp.Services { /// /// The user requested does not exist. diff --git a/Timeline/Services/UserRoleConvert.cs b/Timeline/Services/UserRoleConvert.cs index f27ee1bb..78c52ae3 100644 --- a/Timeline/Services/UserRoleConvert.cs +++ b/Timeline/Services/UserRoleConvert.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using Timeline.Entities; +using TimelineApp.Entities; -namespace Timeline.Services +namespace TimelineApp.Services { public static class UserRoleConvert { diff --git a/Timeline/Services/UserService.cs b/Timeline/Services/UserService.cs index 7dc7159d..3279d2bd 100644 --- a/Timeline/Services/UserService.cs +++ b/Timeline/Services/UserService.cs @@ -4,12 +4,13 @@ using System; using System.Globalization; using System.Linq; using System.Threading.Tasks; -using Timeline.Entities; -using Timeline.Helpers; -using Timeline.Models.Validation; -using static Timeline.Resources.Services.UserService; +using TimelineApp.Entities; +using TimelineApp.Helpers; +using TimelineApp.Models; +using TimelineApp.Models.Validation; +using static TimelineApp.Resources.Services.UserService; -namespace Timeline.Services +namespace TimelineApp.Services { public interface IUserService { diff --git a/Timeline/Services/UserTokenException.cs b/Timeline/Services/UserTokenException.cs index ed0bae1a..99d26dec 100644 --- a/Timeline/Services/UserTokenException.cs +++ b/Timeline/Services/UserTokenException.cs @@ -1,6 +1,6 @@ using System; -namespace Timeline.Services +namespace TimelineApp.Services { [Serializable] diff --git a/Timeline/Services/UserTokenManager.cs b/Timeline/Services/UserTokenManager.cs index 4e54c4cd..4a044353 100644 --- a/Timeline/Services/UserTokenManager.cs +++ b/Timeline/Services/UserTokenManager.cs @@ -1,8 +1,9 @@ using Microsoft.Extensions.Logging; using System; using System.Threading.Tasks; +using TimelineApp.Models; -namespace Timeline.Services +namespace TimelineApp.Services { public class UserTokenCreateResult { diff --git a/Timeline/Services/UserTokenService.cs b/Timeline/Services/UserTokenService.cs index 86f3a0f7..76501ce3 100644 --- a/Timeline/Services/UserTokenService.cs +++ b/Timeline/Services/UserTokenService.cs @@ -5,10 +5,10 @@ using System.Globalization; using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Security.Claims; -using Timeline.Configs; -using Timeline.Entities; +using TimelineApp.Configs; +using TimelineApp.Entities; -namespace Timeline.Services +namespace TimelineApp.Services { public class UserTokenInfo { diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs index 873d2d3b..d34bee25 100644 --- a/Timeline/Startup.cs +++ b/Timeline/Startup.cs @@ -10,15 +10,15 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; using System; using System.Text.Json.Serialization; -using Timeline.Auth; -using Timeline.Configs; -using Timeline.Entities; -using Timeline.Formatters; -using Timeline.Helpers; -using Timeline.Models.Converters; -using Timeline.Services; - -namespace Timeline +using TimelineApp.Auth; +using TimelineApp.Configs; +using TimelineApp.Entities; +using TimelineApp.Formatters; +using TimelineApp.Helpers; +using TimelineApp.Models.Converters; +using TimelineApp.Services; + +namespace TimelineApp { [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static")] public class Startup @@ -101,7 +101,7 @@ namespace Timeline services.AddUserAvatarService(); - services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.TryAddSingleton(); diff --git a/Timeline/Timeline.csproj b/Timeline/Timeline.csproj deleted file mode 100644 index e993c0b3..00000000 --- a/Timeline/Timeline.csproj +++ /dev/null @@ -1,211 +0,0 @@ - - - netcoreapp3.1 - 1f6fb74d-4277-4bc0-aeea-b1fc5ffb0b43 - crupest - - 8.0 - enable - - - - - - - - - PreserveNewest - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - True - True - AuthHandler.resx - - - True - True - ControllerAuthExtensions.resx - - - True - True - TimelineController.resx - - - True - True - TokenController.resx - - - True - True - UserAvatarController.resx - - - True - True - UserController.resx - - - True - True - Filters.resx - - - True - True - Messages.resx - - - True - True - Common.resx - - - True - True - NicknameValidator.resx - - - True - True - NameValidator.resx - - - True - True - Validator.resx - - - True - True - DataManager.resx - - - True - True - Exception.resx - - - True - True - TimelineService.resx - - - True - True - UserAvatarService.resx - - - True - True - UserService.resx - - - True - True - UserTokenService.resx - - - - - - ResXFileCodeGenerator - AuthHandler.Designer.cs - - - ResXFileCodeGenerator - ControllerAuthExtensions.Designer.cs - - - ResXFileCodeGenerator - TimelineController.Designer.cs - - - Designer - ResXFileCodeGenerator - TokenController.Designer.cs - - - ResXFileCodeGenerator - UserAvatarController.Designer.cs - - - ResXFileCodeGenerator - UserController.Designer.cs - - - ResXFileCodeGenerator - Filters.Designer.cs - - - ResXFileCodeGenerator - Messages.Designer.cs - - - ResXFileCodeGenerator - Common.Designer.cs - - - ResXFileCodeGenerator - NicknameValidator.Designer.cs - - - ResXFileCodeGenerator - NameValidator.Designer.cs - - - ResXFileCodeGenerator - Validator.Designer.cs - - - ResXFileCodeGenerator - DataManager.Designer.cs - - - ResXFileCodeGenerator - Exception.Designer.cs - - - ResXFileCodeGenerator - TimelineService.Designer.cs - - - ResXFileCodeGenerator - UserAvatarService.Designer.cs - - - ResXFileCodeGenerator - UserService.Designer.cs - - - ResXFileCodeGenerator - UserTokenService.Designer.cs - - - diff --git a/Timeline/TimelineApp.csproj b/Timeline/TimelineApp.csproj new file mode 100644 index 00000000..6fb88ae9 --- /dev/null +++ b/Timeline/TimelineApp.csproj @@ -0,0 +1,211 @@ + + + netcoreapp3.1 + 1f6fb74d-4277-4bc0-aeea-b1fc5ffb0b43 + crupest + + 8.0 + enable + + + + + + + + + PreserveNewest + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + True + True + AuthHandler.resx + + + True + True + ControllerAuthExtensions.resx + + + True + True + TimelineController.resx + + + True + True + TokenController.resx + + + True + True + UserAvatarController.resx + + + True + True + UserController.resx + + + True + True + Filters.resx + + + True + True + Messages.resx + + + True + True + Common.resx + + + True + True + NicknameValidator.resx + + + True + True + NameValidator.resx + + + True + True + Validator.resx + + + True + True + DataManager.resx + + + True + True + Exception.resx + + + True + True + TimelineService.resx + + + True + True + UserAvatarService.resx + + + True + True + UserService.resx + + + True + True + UserTokenService.resx + + + + + + ResXFileCodeGenerator + AuthHandler.Designer.cs + + + ResXFileCodeGenerator + ControllerAuthExtensions.Designer.cs + + + ResXFileCodeGenerator + TimelineController.Designer.cs + + + Designer + ResXFileCodeGenerator + TokenController.Designer.cs + + + ResXFileCodeGenerator + UserAvatarController.Designer.cs + + + ResXFileCodeGenerator + UserController.Designer.cs + + + ResXFileCodeGenerator + Filters.Designer.cs + + + ResXFileCodeGenerator + Messages.Designer.cs + + + ResXFileCodeGenerator + Common.Designer.cs + + + ResXFileCodeGenerator + NicknameValidator.Designer.cs + + + ResXFileCodeGenerator + NameValidator.Designer.cs + + + ResXFileCodeGenerator + Validator.Designer.cs + + + ResXFileCodeGenerator + DataManager.Designer.cs + + + ResXFileCodeGenerator + Exception.Designer.cs + + + ResXFileCodeGenerator + TimelineService.Designer.cs + + + ResXFileCodeGenerator + UserAvatarService.Designer.cs + + + ResXFileCodeGenerator + UserService.Designer.cs + + + ResXFileCodeGenerator + UserTokenService.Designer.cs + + + -- cgit v1.2.3