From f274f96b4d317946c9c341597c4bc9db54eed251 Mon Sep 17 00:00:00 2001 From: Maksym Sadovnychyy Date: Fri, 25 Nov 2022 00:06:32 +0100 Subject: [PATCH] (refactor): code fix and migrate to .net7 --- src/DomainObjects/Documents/UserDocument.cs | 10 +++------- src/DomainObjects/DomainObjects.csproj | 2 +- src/EmailProvider/EmailProvider.csproj | 2 +- webapi/Core/Core.csproj | 2 +- webapi/CryptoProvider/CryptoProvider.csproj | 2 +- webapi/DataProviders/DataProviders.csproj | 2 +- webapi/Extensions/Extensions.csproj | 2 +- webapi/Extensions/StringExtensions.cs | 2 ++ webapi/ImageProvider/ImageProvider.csproj | 2 +- webapi/ReverseProxy/ReverseProxy.csproj | 2 +- .../FileSecurityService/FileSecurityService.csproj | 2 +- webapi/Services/JWTService/JWTService.csproj | 2 +- webapi/Tests/Core/CoreTests.csproj | 2 +- webapi/Tests/Extensions/ExtensionsTests.csproj | 2 +- .../WeatherForecast/Controllers/AccountController.cs | 3 --- .../Models/BlogItem/Requests/BlogItemRequestModel.cs | 2 +- .../Policies/CategoryAuthorizationHandler.cs | 2 +- .../Policies/FileAuthorisationHandler.cs | 1 + webapi/WeatherForecast/Services/BlogItemsService.cs | 1 + webapi/WeatherForecast/Services/CategoryItemService.cs | 1 + .../WeatherForecast/Services/CategoryItemsService.cs | 1 + webapi/WeatherForecast/Services/ShopItemsService.cs | 1 + webapi/WeatherForecast/WeatherForecast.csproj | 2 +- 23 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/DomainObjects/Documents/UserDocument.cs b/src/DomainObjects/Documents/UserDocument.cs index 1ebb628..f8154ec 100644 --- a/src/DomainObjects/Documents/UserDocument.cs +++ b/src/DomainObjects/Documents/UserDocument.cs @@ -27,15 +27,11 @@ public class UserDocument : DomainObjectDocumentBase { public Roles Role { get; set; } - - public void SetPassword (string password) { + if (Passwords.Password != null) + Passwords.Expired.Add(Passwords.Password.Prototype()); - - - var old = Passwords.Password.Prototype(); - - + Passwords.Password = new Password(password); } public override int GetHashCode() { diff --git a/src/DomainObjects/DomainObjects.csproj b/src/DomainObjects/DomainObjects.csproj index ec6ccd7..535d503 100644 --- a/src/DomainObjects/DomainObjects.csproj +++ b/src/DomainObjects/DomainObjects.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable diff --git a/src/EmailProvider/EmailProvider.csproj b/src/EmailProvider/EmailProvider.csproj index 9d97abd..968de17 100644 --- a/src/EmailProvider/EmailProvider.csproj +++ b/src/EmailProvider/EmailProvider.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable diff --git a/webapi/Core/Core.csproj b/webapi/Core/Core.csproj index 6e4001c..0bb0489 100644 --- a/webapi/Core/Core.csproj +++ b/webapi/Core/Core.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 enable enable diff --git a/webapi/CryptoProvider/CryptoProvider.csproj b/webapi/CryptoProvider/CryptoProvider.csproj index e6e43bc..f30dff6 100644 --- a/webapi/CryptoProvider/CryptoProvider.csproj +++ b/webapi/CryptoProvider/CryptoProvider.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 enable enable diff --git a/webapi/DataProviders/DataProviders.csproj b/webapi/DataProviders/DataProviders.csproj index 412c245..db96c11 100644 --- a/webapi/DataProviders/DataProviders.csproj +++ b/webapi/DataProviders/DataProviders.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable diff --git a/webapi/Extensions/Extensions.csproj b/webapi/Extensions/Extensions.csproj index e6bfcab..d19ba2f 100644 --- a/webapi/Extensions/Extensions.csproj +++ b/webapi/Extensions/Extensions.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 enable enable $(MSBuildProjectName.Replace(" ", "_")) diff --git a/webapi/Extensions/StringExtensions.cs b/webapi/Extensions/StringExtensions.cs index 133cd77..274e39b 100644 --- a/webapi/Extensions/StringExtensions.cs +++ b/webapi/Extensions/StringExtensions.cs @@ -171,6 +171,8 @@ namespace ExtensionMethods { public static DateTime ToDateTime(this string s, string[] formats) { if (s == "Now") return DateTime.Now; + else if (s == "UtcNow") + return DateTime.UtcNow; else if (s == "Today") return DateTime.Today; diff --git a/webapi/ImageProvider/ImageProvider.csproj b/webapi/ImageProvider/ImageProvider.csproj index c4bd933..9e91a62 100644 --- a/webapi/ImageProvider/ImageProvider.csproj +++ b/webapi/ImageProvider/ImageProvider.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 enable enable diff --git a/webapi/ReverseProxy/ReverseProxy.csproj b/webapi/ReverseProxy/ReverseProxy.csproj index 861f987..4ad9845 100644 --- a/webapi/ReverseProxy/ReverseProxy.csproj +++ b/webapi/ReverseProxy/ReverseProxy.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable ..\docker-compose.dcproj diff --git a/webapi/Services/FileSecurityService/FileSecurityService.csproj b/webapi/Services/FileSecurityService/FileSecurityService.csproj index e8dc104..5c219bf 100644 --- a/webapi/Services/FileSecurityService/FileSecurityService.csproj +++ b/webapi/Services/FileSecurityService/FileSecurityService.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable diff --git a/webapi/Services/JWTService/JWTService.csproj b/webapi/Services/JWTService/JWTService.csproj index 3550de9..b4ec1a4 100644 --- a/webapi/Services/JWTService/JWTService.csproj +++ b/webapi/Services/JWTService/JWTService.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 enable enable diff --git a/webapi/Tests/Core/CoreTests.csproj b/webapi/Tests/Core/CoreTests.csproj index caf0f16..623460c 100644 --- a/webapi/Tests/Core/CoreTests.csproj +++ b/webapi/Tests/Core/CoreTests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 enable enable $(MSBuildProjectName.Replace(" ", "_")) diff --git a/webapi/Tests/Extensions/ExtensionsTests.csproj b/webapi/Tests/Extensions/ExtensionsTests.csproj index 310858a..91922b7 100644 --- a/webapi/Tests/Extensions/ExtensionsTests.csproj +++ b/webapi/Tests/Extensions/ExtensionsTests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 enable false diff --git a/webapi/WeatherForecast/Controllers/AccountController.cs b/webapi/WeatherForecast/Controllers/AccountController.cs index 243b90f..72e7911 100644 --- a/webapi/WeatherForecast/Controllers/AccountController.cs +++ b/webapi/WeatherForecast/Controllers/AccountController.cs @@ -1,7 +1,6 @@ using DomainObjects; using DataProviders.Collections; using DomainResults.Mvc; -using ExtensionMethods; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using WeatherForecast.Models.Account.Requests; @@ -85,7 +84,6 @@ public class AccountController : ControllerBase { } #endregion - /// /// For authenticated users that want to change their password the PUT request can be performed immediately without the email /// (the account for which we are updating the password is known to the server). In such case the form will submit two fields @@ -109,5 +107,4 @@ public class AccountController : ControllerBase { return Unauthorized(); } - } diff --git a/webapi/WeatherForecast/Models/BlogItem/Requests/BlogItemRequestModel.cs b/webapi/WeatherForecast/Models/BlogItem/Requests/BlogItemRequestModel.cs index 982e317..3f175e9 100644 --- a/webapi/WeatherForecast/Models/BlogItem/Requests/BlogItemRequestModel.cs +++ b/webapi/WeatherForecast/Models/BlogItem/Requests/BlogItemRequestModel.cs @@ -1,4 +1,4 @@ -using Core.DomainObjects.Documents; +using DomainObjects.Documents; using Core.Enumerations; using Extensions; using System.ComponentModel.DataAnnotations; diff --git a/webapi/WeatherForecast/Policies/CategoryAuthorizationHandler.cs b/webapi/WeatherForecast/Policies/CategoryAuthorizationHandler.cs index 501b800..5916616 100644 --- a/webapi/WeatherForecast/Policies/CategoryAuthorizationHandler.cs +++ b/webapi/WeatherForecast/Policies/CategoryAuthorizationHandler.cs @@ -1,6 +1,6 @@ using Core.Enumerations; using DataProviders.Collections; - +using DomainObjects.Enumerations; using Microsoft.AspNetCore.Authorization; using WeatherForecast.Policies.Abstractions; using WeatherForecast.Services; diff --git a/webapi/WeatherForecast/Policies/FileAuthorisationHandler.cs b/webapi/WeatherForecast/Policies/FileAuthorisationHandler.cs index d9114c8..f43c719 100644 --- a/webapi/WeatherForecast/Policies/FileAuthorisationHandler.cs +++ b/webapi/WeatherForecast/Policies/FileAuthorisationHandler.cs @@ -1,6 +1,7 @@ using Core.Enumerations; using DataProviders; using DataProviders.Collections; +using DomainObjects.Enumerations; using FileSecurityService; using Microsoft.AspNetCore.Authorization; using WeatherForecast.Policies.Abstractions; diff --git a/webapi/WeatherForecast/Services/BlogItemsService.cs b/webapi/WeatherForecast/Services/BlogItemsService.cs index c3026ab..97ba6ac 100644 --- a/webapi/WeatherForecast/Services/BlogItemsService.cs +++ b/webapi/WeatherForecast/Services/BlogItemsService.cs @@ -6,6 +6,7 @@ using DataProviders.Collections; using WeatherForecast.Models.Responses; using WeatherForecast.Models.Blog.Responses; +using DomainObjects.Enumerations; namespace WeatherForecast.Services { diff --git a/webapi/WeatherForecast/Services/CategoryItemService.cs b/webapi/WeatherForecast/Services/CategoryItemService.cs index f0d3d6a..bf150d4 100644 --- a/webapi/WeatherForecast/Services/CategoryItemService.cs +++ b/webapi/WeatherForecast/Services/CategoryItemService.cs @@ -7,6 +7,7 @@ using Core.Abstractions; using WeatherForecast.Models.Category.Requests; using WeatherForecast.Models.Category.Responses; +using DomainObjects.Enumerations; namespace WeatherForecast.Services { diff --git a/webapi/WeatherForecast/Services/CategoryItemsService.cs b/webapi/WeatherForecast/Services/CategoryItemsService.cs index b4d95db..f3c2f1a 100644 --- a/webapi/WeatherForecast/Services/CategoryItemsService.cs +++ b/webapi/WeatherForecast/Services/CategoryItemsService.cs @@ -7,6 +7,7 @@ using Core.Enumerations; using WeatherForecast.Models.Responses; using WeatherForecast.Models.Category.Responses; +using DomainObjects.Enumerations; namespace WeatherForecast.Services { diff --git a/webapi/WeatherForecast/Services/ShopItemsService.cs b/webapi/WeatherForecast/Services/ShopItemsService.cs index 3824717..508dd92 100644 --- a/webapi/WeatherForecast/Services/ShopItemsService.cs +++ b/webapi/WeatherForecast/Services/ShopItemsService.cs @@ -8,6 +8,7 @@ using Core.Enumerations; using WeatherForecast.Models; using WeatherForecast.Models.Responses; using WeatherForecast.Models.Shop.Responses; +using DomainObjects.Enumerations; namespace WeatherForecast.Services { diff --git a/webapi/WeatherForecast/WeatherForecast.csproj b/webapi/WeatherForecast/WeatherForecast.csproj index fa5e719..7f06b96 100644 --- a/webapi/WeatherForecast/WeatherForecast.csproj +++ b/webapi/WeatherForecast/WeatherForecast.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 enable enable WeatherForecast