├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── OneLine.sln ├── README.md ├── Src ├── OneLine.Server │ ├── Bases │ │ ├── ApiContextService │ │ │ ├── ApiContextService.cs │ │ │ └── ApiContextServiceAuditTrails.cs │ │ └── BlobStorageService │ │ │ └── IBlobStorageService.cs │ ├── Extensions │ │ ├── BlobDataCollectionExtensions.cs │ │ ├── DataReaderExtensions.cs │ │ ├── HttpContextExtensions.cs │ │ ├── IAuditTrailsExtensions.cs │ │ └── IQueryableExtensions.cs │ └── OneLine.Server.csproj ├── OneLine.SqlServer │ ├── FrameworkTables.sql │ ├── FrameworkTablesData.sql │ └── OneLine.SqlServer.sqlproj └── OneLine │ ├── Bases │ ├── Contextable │ │ └── BaseContext.cs │ ├── WorkFlowManager │ │ └── WorkFlowManager.cs │ └── WorkFlowStateProcess │ │ └── WorkFlowStateProcess.cs │ ├── Constants │ ├── ClaimTypes.cs │ ├── DefaultRoutes.cs │ ├── JwtAuthenticationSchemes.cs │ └── MimeTypes.cs │ ├── Contracts │ ├── ApiResponseable │ │ └── IApiResponseable.cs │ ├── ApiResponseableCollectionable │ │ └── IApiResponseableCollectionable.cs │ ├── ApiResponseablePageable │ │ └── IApiResponseablePageable.cs │ ├── ApplicationConfiguration │ │ ├── ApplicationConfiguration.cs │ │ └── IApplicationConfiguration.cs │ ├── ApplicationConfigurationSource │ │ ├── ApplicationConfigurationSource.cs │ │ └── IApplicationConfigurationSource.cs │ ├── ApplicationLocale │ │ ├── ApplicationLocale.cs │ │ └── IApplicationLocale.cs │ ├── ApplicationState │ │ ├── ApplicationState.cs │ │ └── IApplicationState.cs │ ├── CancelableEventable │ │ └── ICancelableEventable.cs │ ├── CollectionAppendableReplaceableModeable │ │ └── ICollectionAppendableReplaceableModeable.cs │ ├── CollectionFilterableSortable │ │ └── ICollectionFilterableSortable.cs │ ├── Contextable │ │ └── IContextable.cs │ ├── CoreView │ │ └── ICoreView.cs │ ├── DeletableEventable │ │ └── IDeletableEventable.cs │ ├── Device │ │ ├── Device.cs │ │ └── IDevice.cs │ ├── DeviceStorage │ │ ├── DeviceStorage.cs │ │ └── IDeviceStorage.cs │ ├── FormModeable │ │ └── IFormModeable.cs │ ├── FormStateable │ │ └── IFormStateable.cs │ ├── HttpCrudExtendedService │ │ └── IHttpCrudExtendedService.cs │ ├── HttpCrudService │ │ └── IHttpCrudService.cs │ ├── HttpService │ │ └── IHttpService.cs │ ├── HttpServiceable │ │ └── IHttpServiceable.cs │ ├── HttpUserBlobsService │ │ └── IHttpUserBlobsService.cs │ ├── LoadableEventable │ │ └── ILoadableEventable.cs │ ├── Modelable │ │ └── IModelable.cs │ ├── MutableBlobDataCollectionableValidatable │ │ └── IMutableBlobDataCollectionableValidatable.cs │ ├── Notification │ │ ├── INotification.cs │ │ └── Notification.cs │ ├── Pageable │ │ └── IPageable.cs │ ├── PageableNavigable │ │ └── IPageableNavigable.cs │ ├── PropertySortable │ │ └── IPropertySortable.cs │ ├── ResettableEventable │ │ └── IResettableEventable.cs │ ├── ResourceManagerLocalizer │ │ ├── IResourceManagerLocalizer.cs │ │ └── ResourceManagerLocalizer.cs │ ├── SaveFile │ │ ├── ISaveFile.cs │ │ └── SaveFile.cs │ ├── SaveableEventable │ │ └── ISaveableEventable.cs │ ├── SearchExtraParameterable │ │ └── ISearchExtraParameterable.cs │ ├── SearchableEventable │ │ └── ISearchableEventable.cs │ ├── SearchablePageable │ │ └── ISearchablePageable.cs │ ├── Selectable │ │ └── ISelectable.cs │ ├── Sortable │ │ └── ISortable.cs │ ├── SupportedCultures │ │ ├── ISupportedCultures.cs │ │ └── SupportedCultures.cs │ ├── ValidatableEventable │ │ └── IValidatableEventable.cs │ ├── WorkFlowManager │ │ └── IWorkFlowManager.cs │ └── WorkFlowStateProcess │ │ └── IWorkFlowStateProcess.cs │ ├── Enums │ ├── ApiResponseStatus.cs │ ├── ApplicationSession.cs │ ├── CollectionAppendReplaceMode.cs │ ├── FormMode.cs │ ├── FormState.cs │ ├── RecordsSelectionMode.cs │ ├── SaveOperation.cs │ └── TransactionType.cs │ ├── Extensions │ ├── ApiResponseStatusExtensions.cs │ ├── ApplicationSessionExtensions.cs │ ├── BasicExtensions.cs │ ├── BoolExtensions.cs │ ├── ClaimsPrincipalExtensions.cs │ ├── DateTimeExtensions.cs │ ├── DayOfWeekExtensions.cs │ ├── DecimalExtensions.cs │ ├── EnumExtensions.cs │ ├── FormModeExtensions.cs │ ├── FormStateExtensions.cs │ ├── HttpClientExtensions.cs │ ├── IApiResponseExtensions.cs │ ├── IDictionaryExtensions.cs │ ├── IEnumerableExtensions.cs │ ├── IntergerExtensions.cs │ ├── NavigationManagerExtensions.cs │ ├── NullableExtensions.cs │ ├── PredicateBuilder.cs │ ├── RateLimitingExtensionForObject.cs │ ├── RecordsSelectionModeExtensions.cs │ ├── SaveOperationExtensions.cs │ ├── StreamExtensions.cs │ ├── StringExtensions.cs │ ├── TransactionTypeExtensions.cs │ └── TypeExtension.cs │ ├── InheritedExtendedClasses │ └── ObservableRangeCollection │ │ └── ObservableRangeCollection.cs │ ├── Messaging │ ├── SendGrid │ │ ├── ISendGridApi.cs │ │ ├── ISendGridApiSettings.cs │ │ ├── SendGrid.cs │ │ └── SendGridApiSettings.cs │ └── Smtp │ │ ├── ISmtp.cs │ │ ├── ISmtpSettings.cs │ │ ├── Smtp.cs │ │ └── SmtpSettings.cs │ ├── Models │ ├── ApiResponse │ │ ├── ApiResponse.cs │ │ └── IApiResponse.cs │ ├── AuditTrails │ │ └── IAuditTrails.cs │ ├── BlobData │ │ ├── BlobData.cs │ │ └── IBlobData.cs │ ├── BlobsStoragePath │ │ ├── BlobsStoragePath.cs │ │ └── IBlobsStoragePath.cs │ ├── DataHolder │ │ ├── DataHolder.cs │ │ └── IDataHolder.cs │ ├── ExceptionLogs │ │ └── IExceptionsLogs.cs │ ├── FormFileRules │ │ ├── FormFileRules.cs │ │ └── IFormFileRules.cs │ ├── Identifier │ │ ├── IIdentifier.cs │ │ └── Identifier.cs │ ├── IdentifierString │ │ └── IdentifierString.cs │ ├── Mutable │ │ ├── IMutable.cs │ │ └── Mutable.cs │ ├── NotificationMessages │ │ └── INotificationMessages.cs │ ├── Paged │ │ ├── IPaged.cs │ │ └── Paged.cs │ ├── Paging │ │ ├── IPaging.cs │ │ └── Paging.cs │ ├── ResponseResult │ │ ├── IResponseResult.cs │ │ └── ResponseResult.cs │ ├── SaveForm │ │ ├── ISaveForm.cs │ │ └── SaveForm.cs │ ├── SaveFormWithValidator │ │ ├── ISaveFormWithValidator.cs │ │ └── SaveFormWithValidator.cs │ ├── SaveReplaceList │ │ ├── ISaveReplaceList.cs │ │ └── SaveReplaceList.cs │ ├── Search │ │ ├── ISearch.cs │ │ └── Search.cs │ ├── SearchPaging │ │ ├── ISearchPaging.cs │ │ └── SearchPaging.cs │ ├── SoftDeletable │ │ └── ISoftDeletable.cs │ ├── UploadBlobData │ │ ├── IUploadBlobData.cs │ │ └── UploadBlobData.cs │ └── UserBlobs │ │ └── IUserBlobs.cs │ ├── OneLine.csproj │ ├── Validations │ └── BlobDataValidator │ │ └── BlobDataValidator.cs │ └── _Imports.razor └── workload-install.ps1 /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2020 Anthony G. Rivera Cosme 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /OneLine.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32901.215 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{57CE4ABF-44A5-4BEE-A900-3F173A01C66C}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OneLine", "Src\OneLine\OneLine.csproj", "{FFE57380-97E2-4799-83A0-4CD002EAEED5}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OneLine.Server", "Src\OneLine.Server\OneLine.Server.csproj", "{95CAFD2F-3512-4100-97F0-27C6CC22E88F}" 11 | EndProject 12 | Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "OneLine.SqlServer", "Src\OneLine.SqlServer\OneLine.SqlServer.sqlproj", "{3CD8A192-02B9-4225-90CE-4197AB332349}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Debug|iPhone = Debug|iPhone 18 | Debug|iPhoneSimulator = Debug|iPhoneSimulator 19 | Release|Any CPU = Release|Any CPU 20 | Release|iPhone = Release|iPhone 21 | Release|iPhoneSimulator = Release|iPhoneSimulator 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Debug|iPhone.ActiveCfg = Debug|Any CPU 27 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Debug|iPhone.Build.0 = Debug|Any CPU 28 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU 29 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU 30 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Release|iPhone.ActiveCfg = Release|Any CPU 33 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Release|iPhone.Build.0 = Release|Any CPU 34 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU 35 | {FFE57380-97E2-4799-83A0-4CD002EAEED5}.Release|iPhoneSimulator.Build.0 = Release|Any CPU 36 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Debug|iPhone.ActiveCfg = Debug|Any CPU 39 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Debug|iPhone.Build.0 = Debug|Any CPU 40 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU 41 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU 42 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Release|iPhone.ActiveCfg = Release|Any CPU 45 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Release|iPhone.Build.0 = Release|Any CPU 46 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU 47 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F}.Release|iPhoneSimulator.Build.0 = Release|Any CPU 48 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 49 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Debug|Any CPU.Build.0 = Debug|Any CPU 50 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 51 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Debug|iPhone.ActiveCfg = Debug|Any CPU 52 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Debug|iPhone.Build.0 = Debug|Any CPU 53 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Debug|iPhone.Deploy.0 = Debug|Any CPU 54 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU 55 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU 56 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU 57 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Release|Any CPU.ActiveCfg = Release|Any CPU 58 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Release|Any CPU.Build.0 = Release|Any CPU 59 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Release|Any CPU.Deploy.0 = Release|Any CPU 60 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Release|iPhone.ActiveCfg = Release|Any CPU 61 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Release|iPhone.Build.0 = Release|Any CPU 62 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Release|iPhone.Deploy.0 = Release|Any CPU 63 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU 64 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Release|iPhoneSimulator.Build.0 = Release|Any CPU 65 | {3CD8A192-02B9-4225-90CE-4197AB332349}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU 66 | EndGlobalSection 67 | GlobalSection(SolutionProperties) = preSolution 68 | HideSolutionNode = FALSE 69 | EndGlobalSection 70 | GlobalSection(NestedProjects) = preSolution 71 | {FFE57380-97E2-4799-83A0-4CD002EAEED5} = {57CE4ABF-44A5-4BEE-A900-3F173A01C66C} 72 | {95CAFD2F-3512-4100-97F0-27C6CC22E88F} = {57CE4ABF-44A5-4BEE-A900-3F173A01C66C} 73 | {3CD8A192-02B9-4225-90CE-4197AB332349} = {57CE4ABF-44A5-4BEE-A900-3F173A01C66C} 74 | EndGlobalSection 75 | GlobalSection(ExtensibilityGlobals) = postSolution 76 | SolutionGuid = {31771D0A-435A-4C14-96DD-F0D8A7BC4148} 77 | EndGlobalSection 78 | EndGlobal 79 | -------------------------------------------------------------------------------- /Src/OneLine.Server/Bases/ApiContextService/ApiContextService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using OneLine.Models; 5 | 6 | namespace OneLine.Bases 7 | { 8 | public partial class ApiContextService 9 | where TDbContext : DbContext 10 | where TAuditTrails : class, IAuditTrails, new() 11 | where TUserBlobs : class, IUserBlobs, new() 12 | where TBlobStorage : class, IBlobStorageService, new() 13 | { 14 | /// 15 | /// The database conext 16 | /// 17 | public TDbContext DbContext { get; set; } 18 | /// 19 | /// The Http context accessor 20 | /// 21 | public IHttpContextAccessor HttpContextAccessor { get; set; } 22 | /// 23 | /// The blob storage service provider 24 | /// 25 | public TBlobStorage BlobStorageService { get; set; } 26 | /// 27 | /// Gets the scope factory of the current application or service 28 | /// 29 | public IServiceScopeFactory ServiceScopeFactory { get; set; } 30 | /// 31 | /// The api context service will create a context containing from the most minimalist api service to the most robust service provider 32 | /// 33 | /// 34 | public ApiContextService() 35 | { 36 | } 37 | /// 38 | /// The api context service will create a context containing from the most minimalist api service to the most robust service provider 39 | /// 40 | /// 41 | public ApiContextService(IServiceScopeFactory serviceScopeFactory) 42 | { 43 | ServiceScopeFactory = serviceScopeFactory; 44 | } 45 | /// 46 | /// The api context service will create a context containing from the most minimalist api service to the most robust service provider 47 | /// 48 | /// 49 | public ApiContextService(TDbContext dbContext) 50 | { 51 | DbContext = dbContext; 52 | } 53 | /// 54 | /// The api context service will create a context containing from the most minimalist api service to the most robust service provider 55 | /// 56 | /// 57 | public ApiContextService(TDbContext dbContext, IServiceScopeFactory serviceScopeFactory) 58 | { 59 | DbContext = dbContext; 60 | ServiceScopeFactory = serviceScopeFactory; 61 | } 62 | /// 63 | /// The api context service will create a context containing from the most minimalist api service to the most robust service provider 64 | /// 65 | /// 66 | /// 67 | public ApiContextService(TDbContext dbContext, IHttpContextAccessor httpContextAccessor) 68 | { 69 | DbContext = dbContext; 70 | HttpContextAccessor = httpContextAccessor; 71 | } 72 | /// 73 | /// The api context service will create a context containing from the most minimalist api service to the most robust service provider 74 | /// 75 | /// 76 | /// 77 | public ApiContextService(TDbContext dbContext, IHttpContextAccessor httpContextAccessor, IServiceScopeFactory serviceScopeFactory) 78 | { 79 | DbContext = dbContext; 80 | HttpContextAccessor = httpContextAccessor; 81 | ServiceScopeFactory = serviceScopeFactory; 82 | } 83 | /// 84 | /// The api context service will create a context containing from the most minimalist api service to the most robust service provider 85 | /// 86 | /// 87 | /// 88 | /// 89 | public ApiContextService(TDbContext dbContext, IHttpContextAccessor httpContextAccessor, TBlobStorage blobStorage) 90 | { 91 | DbContext = dbContext; 92 | HttpContextAccessor = httpContextAccessor; 93 | BlobStorageService = blobStorage; 94 | } 95 | /// 96 | /// The api context service will create a context containing from the most minimalist api service to the most robust service provider 97 | /// 98 | /// 99 | /// 100 | /// 101 | public ApiContextService(TDbContext dbContext, IHttpContextAccessor httpContextAccessor, TBlobStorage blobStorage, IServiceScopeFactory serviceScopeFactory) 102 | { 103 | DbContext = dbContext; 104 | HttpContextAccessor = httpContextAccessor; 105 | BlobStorageService = blobStorage; 106 | ServiceScopeFactory = serviceScopeFactory; 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Src/OneLine.Server/Bases/BlobStorageService/IBlobStorageService.cs: -------------------------------------------------------------------------------- 1 | using Storage.Net.Blobs; 2 | 3 | namespace OneLine.Bases 4 | { 5 | public interface IBlobStorageService 6 | { 7 | public IBlobStorage BlobStorage { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Src/OneLine.Server/Extensions/BlobDataCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | using OneLine.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | 8 | namespace OneLine.Extensions 9 | { 10 | public static class BlobDataCollectionExtensions 11 | { 12 | public static bool BlobDataExists(this IEnumerable blobDatas, Func predicate) 13 | { 14 | return blobDatas.IsNotNull() && blobDatas.Any() && blobDatas.Any(predicate); 15 | } 16 | public static bool IsValidBlobData(this IEnumerable blobDatas, IFormFileRules formFileRules) 17 | { 18 | return IsValidBlobData(blobDatas, null, formFileRules); 19 | } 20 | public static bool IsValidBlobData(this IEnumerable blobDatas, Func predicate, IFormFileRules formFileRules) 21 | { 22 | return IsValidBlobDataApiResponse(blobDatas, predicate, formFileRules).Status == ApiResponseStatus.Succeeded; 23 | } 24 | public static ApiResponse IsValidBlobDataApiResponse(this IEnumerable blobDatas, IFormFileRules formFileRules) 25 | { 26 | return IsValidBlobDataApiResponse(blobDatas, null, formFileRules); 27 | } 28 | public static ApiResponse IsValidBlobDataApiResponse(this IEnumerable blobDatas, Func predicate, IFormFileRules formFileRules) 29 | { 30 | if (formFileRules.AllowedBlobMaxLength <= 0) 31 | { 32 | throw new ArgumentException("The AllowedBlobMaxLength can't be zero or less."); 33 | } 34 | if (formFileRules.AllowedMinimumFiles <= 0) 35 | { 36 | throw new ArgumentException("The AllowedMinimumFiles can't be zero or less."); 37 | } 38 | if (formFileRules.AllowedMaximumFiles <= 0) 39 | { 40 | throw new ArgumentException("The AllowedMaximumFiles can't be zero or less."); 41 | } 42 | var blobs = predicate == null ? blobDatas : blobDatas.Where(predicate); 43 | if ((blobs.IsNull() || !blobDatas.Any()) && formFileRules.IsRequired || formFileRules.ForceUpload) 44 | { 45 | return new ApiResponse() { Status = ApiResponseStatus.Failed, Message = "FileUploadRequired" }; 46 | } 47 | else if (blobs.IsNotNull() && blobs.Any()) 48 | { 49 | if (blobs.Count() < formFileRules.AllowedMinimumFiles) 50 | { 51 | return new ApiResponse() { Status = ApiResponseStatus.Failed, Message = "TheCountOfFilesUploadedHasExceededTheMaximumAllowedFiles" }; 52 | } 53 | if (blobs.Count() > formFileRules.AllowedMaximumFiles) 54 | { 55 | return new ApiResponse() { Status = ApiResponseStatus.Failed, Message = "TheCountOfFilesUploadedIsLessThanTheMinimumAllowedFiles" }; 56 | } 57 | foreach (var blob in blobs) 58 | { 59 | if (blob.IsNull() || blob.Size == 0) 60 | { 61 | return new ApiResponse() { Status = ApiResponseStatus.Failed, Message = "FileUploadRequired", Data = blob.Name }; 62 | } 63 | else if (blob.Size > formFileRules.AllowedBlobMaxLength) 64 | { 65 | return new ApiResponse() { Status = ApiResponseStatus.Failed, Message = "TheFileHasExceededTheLargestSizeAllowed", Data = blob.Name }; 66 | } 67 | else if (formFileRules.AllowedContentTypes != null && formFileRules.AllowedContentTypes.Any() && !formFileRules.AllowedContentTypes.Contains(blob.Type)) 68 | { 69 | return new ApiResponse() { Status = ApiResponseStatus.Failed, Message = "TheFileDoesNotHaveTheExpectedContentType", Data = blob.Name }; 70 | } 71 | else if (formFileRules.AllowedExtensions != null && formFileRules.AllowedExtensions.Any() && !formFileRules.AllowedExtensions.Contains(Path.GetExtension(blob.Name))) 72 | { 73 | return new ApiResponse() { Status = ApiResponseStatus.Failed, Message = "TheFileDoesNotHaveTheExpectedExtension", Data = blob.Name }; 74 | } 75 | else if (formFileRules.AllowedContentDispositions != null && formFileRules.AllowedContentDispositions.Any() && !formFileRules.AllowedContentDispositions.Contains(blob.Type)) 76 | { 77 | return new ApiResponse() { Status = ApiResponseStatus.Failed, Message = "TheFileDoesNotHaveTheExpectedContentDisposition", Data = blob.Name }; 78 | } 79 | } 80 | } 81 | return new ApiResponse() { Status = ApiResponseStatus.Succeeded }; 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Src/OneLine.Server/Extensions/DataReaderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data; 4 | using System.Reflection; 5 | 6 | namespace OneLine.Extensions 7 | { 8 | public static class DataReaderExtensions 9 | { 10 | /// 11 | /// This method reader data reader and yield record to strong type IEnumerable 12 | /// 13 | /// 14 | /// 15 | /// 16 | public static IEnumerable DataReaderMapToEnumerable(this IDataReader dr) 17 | { 18 | while (dr.Read()) 19 | { 20 | var obj = Activator.CreateInstance(); 21 | foreach (PropertyInfo prop in obj.GetType().GetProperties()) 22 | { 23 | if (!Equals(dr[prop.Name], DBNull.Value)) 24 | { 25 | prop.SetValue(obj, dr[prop.Name], null); 26 | } 27 | } 28 | yield return obj; 29 | } 30 | dr.Close(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Src/OneLine.Server/Extensions/HttpContextExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Routing; 3 | using Microsoft.Extensions.Primitives; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace OneLine.Extensions 8 | { 9 | public static class HttpContextExtensions 10 | { 11 | /// 12 | /// Gets the current executing controller name 13 | /// 14 | /// 15 | /// 16 | public static string CurrentControllerName(this HttpContext httpContext) 17 | { 18 | return httpContext 19 | .GetRouteData() 20 | ?.Values["controller"] 21 | ?.ToString(); 22 | } 23 | /// 24 | /// Gets the current executing controller action name 25 | /// 26 | /// 27 | /// 28 | public static string CurrentControllerActionName(this HttpContext httpContext) 29 | { 30 | return httpContext 31 | .GetRouteData() 32 | ?.Values["action"] 33 | ?.ToString(); 34 | } 35 | /// 36 | /// Gets the current host base url 37 | /// 38 | /// 39 | /// 40 | public static string RequestHostBaseUrl(this HttpContext httpContext) 41 | { 42 | var request = httpContext.Request; 43 | var host = request.Host.ToUriComponent(); 44 | var pathBase = request.PathBase.ToUriComponent(); 45 | return $"{request.Scheme}://{host}{pathBase}"; 46 | } 47 | /// 48 | /// Gets the first lang code from accept-language header 49 | /// 50 | /// 51 | /// 52 | public static string GetLangCode(this HttpContext httpContext) 53 | { 54 | return httpContext.Request.Headers.TryGetValue("accept-language", out StringValues value) ? 55 | value.ToString().Split(',')[0] : 56 | null; 57 | } 58 | /// 59 | /// Gets all lang codes from accept-language header 60 | /// 61 | /// 62 | /// 63 | public static IEnumerable GetLangCodes(this HttpContext httpContext) 64 | { 65 | return httpContext.Request.Headers.TryGetValue("accept-language", out StringValues value) ? 66 | value.ToString().Split(',').ToList() : 67 | null; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Src/OneLine.Server/OneLine.Server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net7.0 5 | 8.0 6 | true 7 | 7.3 8 | Anthony G. Rivera Cosme 9 | OneLine.Server is a project that can be used on a server backend. This package already includes OneLine. 10 | Anthony G. Rivera Cosme 11 | 12 | https://github.com/arivera12/OneLine 13 | https://github.com/arivera12/OneLine 14 | 15 | Fixed typo on class property and translations keys and texts. 16 | LICENSE.txt 17 | C# 18 | true 19 | 7.3 20 | 7.3 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | True 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Src/OneLine.SqlServer/FrameworkTablesData.sql: -------------------------------------------------------------------------------- 1 | SET IDENTITY_INSERT [dbo].[TeleCommunicationServiceProviders] ON 2 | GO 3 | INSERT [dbo].[TeleCommunicationServiceProviders] ([TeleCommunicationServiceProviderId], [Name], [DomainGateway], [IsDeleted], [RecordRevisions], [CreatedBy], [CreatedOn], [LastModifiedBy], [LastModifiedOn]) VALUES (1, N'AT&T', N'@mms.att.net', 0, 0, N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime), N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime)) 4 | GO 5 | INSERT [dbo].[TeleCommunicationServiceProviders] ([TeleCommunicationServiceProviderId], [Name], [DomainGateway], [IsDeleted], [RecordRevisions], [CreatedBy], [CreatedOn], [LastModifiedBy], [LastModifiedOn]) VALUES (2, N'Claro', N'@vtexto.com', 0, 0, N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime), N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime)) 6 | GO 7 | INSERT [dbo].[TeleCommunicationServiceProviders] ([TeleCommunicationServiceProviderId], [Name], [DomainGateway], [IsDeleted], [RecordRevisions], [CreatedBy], [CreatedOn], [LastModifiedBy], [LastModifiedOn]) VALUES (3, N'Comcast', N'@comcastpcs.textmsg.com', 0, 0, N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime), N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime)) 8 | GO 9 | INSERT [dbo].[TeleCommunicationServiceProviders] ([TeleCommunicationServiceProviderId], [Name], [DomainGateway], [IsDeleted], [RecordRevisions], [CreatedBy], [CreatedOn], [LastModifiedBy], [LastModifiedOn]) VALUES (4, N'Liberty', N'@mms.att.net', 0, 0, N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime), N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime)) 10 | GO 11 | INSERT [dbo].[TeleCommunicationServiceProviders] ([TeleCommunicationServiceProviderId], [Name], [DomainGateway], [IsDeleted], [RecordRevisions], [CreatedBy], [CreatedOn], [LastModifiedBy], [LastModifiedOn]) VALUES (5, N'Sprint', N'@pm.sprint.com', 0, 0, N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime), N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime)) 12 | GO 13 | INSERT [dbo].[TeleCommunicationServiceProviders] ([TeleCommunicationServiceProviderId], [Name], [DomainGateway], [IsDeleted], [RecordRevisions], [CreatedBy], [CreatedOn], [LastModifiedBy], [LastModifiedOn]) VALUES (6, N'T-Mobile', N'@tmomail.net', 0, 0, N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime), N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime)) 14 | GO 15 | INSERT [dbo].[TeleCommunicationServiceProviders] ([TeleCommunicationServiceProviderId], [Name], [DomainGateway], [IsDeleted], [RecordRevisions], [CreatedBy], [CreatedOn], [LastModifiedBy], [LastModifiedOn]) VALUES (7, N'Verizon Wireless', N'@vzwpix.com', 0, 0, N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime), N'0', CAST(N'2021-04-08T00:00:00.000' AS DateTime)) 16 | GO 17 | SET IDENTITY_INSERT [dbo].[TeleCommunicationServiceProviders] OFF 18 | GO 19 | INSERT [dbo].[SupportedCultures] ([SupportedCultureId], [Locale], [Name], [IsDeleted], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (N'en-US', N'en-US', N'English (United States)', 0, N'64666f90-f15e-491f-98df-069d02aa19f9', CAST(N'2021-04-07T23:17:01.770' AS DateTime), NULL, NULL) 20 | GO 21 | INSERT [dbo].[SupportedCultures] ([SupportedCultureId], [Locale], [Name], [IsDeleted], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn]) VALUES (N'es-PR', N'es-PR', N'Spanish (Puerto Rico)', 0, N'64666f90-f15e-491f-98df-069d02aa19f9', CAST(N'2021-04-07T23:17:22.930' AS DateTime), NULL, NULL) 22 | GO 23 | -------------------------------------------------------------------------------- /Src/OneLine.SqlServer/OneLine.SqlServer.sqlproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | OneLine.SqlServer 7 | 2.0 8 | 4.1 9 | {3cd8a192-02b9-4225-90ce-4197ab332349} 10 | Microsoft.Data.Tools.Schema.Sql.Sql130DatabaseSchemaProvider 11 | Database 12 | 13 | 14 | OneLine.SqlServer 15 | OneLine.SqlServer 16 | 1033, CI 17 | BySchemaAndSchemaType 18 | True 19 | v4.8 20 | CS 21 | Properties 22 | False 23 | True 24 | True 25 | 26 | 27 | 28 | bin\Release\ 29 | $(MSBuildProjectName).sql 30 | False 31 | pdbonly 32 | true 33 | false 34 | true 35 | prompt 36 | 4 37 | 38 | 39 | bin\Debug\ 40 | $(MSBuildProjectName).sql 41 | false 42 | true 43 | full 44 | false 45 | true 46 | true 47 | prompt 48 | 4 49 | 50 | 51 | 11.0 52 | 53 | True 54 | 11.0 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Src/OneLine/Bases/Contextable/BaseContext.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Contracts; 2 | 3 | namespace OneLine.Bases 4 | { 5 | public class BaseContext : IContextable 6 | { 7 | public TContext Context { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Src/OneLine/Bases/WorkFlowManager/WorkFlowManager.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Contracts; 2 | using OneLine.Extensions; 3 | using OneLine.Models; 4 | 5 | namespace OneLine.Bases 6 | { 7 | public class WorkFlowManager : IWorkFlowManager 8 | { 9 | public WorkFlowManager() 10 | { 11 | } 12 | /// 13 | public Func StatePropertyName { get; set; } 14 | /// 15 | public T Record { get; set; } 16 | /// 17 | public IEnumerable> WorkFlowStateProcesses { get; set; } 18 | /// 19 | public async ValueTask> RunWorkFlowProcessAsync() 20 | { 21 | if (WorkFlowStateProcesses.IsNull() || !WorkFlowStateProcesses.Any()) 22 | throw new ArgumentNullException(nameof(WorkFlowStateProcesses)); 23 | if (Record.IsNull()) 24 | throw new ArgumentNullException(nameof(Record)); 25 | if (StatePropertyName.IsNull()) 26 | throw new ArgumentNullException(nameof(StatePropertyName)); 27 | var currentStateProperty = typeof(T).GetProperties().FirstOrDefault(w => w.PropertyType == typeof(TState) && w.Name == StatePropertyName(Record)).GetValue(Record); 28 | if (currentStateProperty.IsNull()) 29 | throw new ArgumentNullException(nameof(currentStateProperty)); 30 | var recordCurrentState = (TState)currentStateProperty; 31 | var nextAvailableWorkFlowStateProcessesFromCurrentState = WorkFlowStateProcesses.Where(w => w.CurrentState.Equals(recordCurrentState)); 32 | if (!nextAvailableWorkFlowStateProcessesFromCurrentState.Any()) 33 | return new ApiResponse(Enums.ApiResponseStatus.Succeeded, Record, "ThereAreNoStepsAvailableAfterTheCurrentState"); 34 | IApiResponse response = default; 35 | foreach (var nextWorkFlowNextState in nextAvailableWorkFlowStateProcessesFromCurrentState) 36 | { 37 | var result = await nextWorkFlowNextState.ProceedNextStateProcessWhen(); 38 | if (result) 39 | { 40 | response = await nextWorkFlowNextState.ProceedNextStateProcess(); 41 | break; 42 | } 43 | } 44 | return response; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Src/OneLine/Bases/WorkFlowStateProcess/WorkFlowStateProcess.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Contracts; 2 | using OneLine.Models; 3 | 4 | namespace OneLine.Bases 5 | { 6 | /// 7 | /// Implements a work flow state process 8 | /// 9 | /// The type of the record 10 | /// The state of the record 11 | public class WorkFlowStateProcess : IWorkFlowStateProcess 12 | { 13 | public WorkFlowStateProcess() 14 | { 15 | } 16 | /// 17 | public T Record { get; set; } 18 | /// 19 | public TState CurrentState { get; set; } 20 | /// 21 | public TState NextState { get; set; } 22 | /// 23 | public virtual Task ProceedNextStateProcessWhen() 24 | { 25 | return default; 26 | } 27 | /// 28 | public virtual Task> ProceedNextStateProcess() 29 | { 30 | return default; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Src/OneLine/Constants/ClaimTypes.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Constants 2 | { 3 | // 4 | // Summary: 5 | // Defines constants for the well-known claim types that can be assigned to a subject. 6 | // This class cannot be inherited. 7 | public static class ClaimTypes 8 | { 9 | // 10 | // Summary: 11 | // The URI for a claim that specifies the access token. 12 | public const string AccessToken = "http://schemas.oneline.com/identity/claims/accesstoken"; 13 | // 14 | // Summary: 15 | // The URI for a claim that specifies the prefered culture locale. 16 | public const string PreferredCultureLocale = "http://schemas.oneline.com/identity/claims/preferredculturelocale"; 17 | // 18 | // Summary: 19 | // The URI for a claim that specifies the short message service gateway. 20 | public const string SMSGateway = "http://schemas.oneline.com/identity/claims/shortmessageservicegateway"; 21 | // 22 | // Summary: 23 | // The URI for a claim that specifies the multimedia messaging service gateway. 24 | public const string MMSGateway = "http://schemas.oneline.com/identity/claims/multimediamessagingservicegateway"; 25 | // 26 | // Summary: 27 | // The URI for a claim that specifies the password. 28 | public const string Password = "http://schemas.oneline.com/identity/claims/password"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/OneLine/Constants/DefaultRoutes.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Constants 2 | { 3 | /// 4 | /// Default routes used by an api 5 | /// 6 | public static class DefaultRoutes 7 | { 8 | /// 9 | /// Api default route template 10 | /// 11 | public static class Api 12 | { 13 | /// 14 | /// Api default route template: "api/[controller]" 15 | /// 16 | public const string Default = "api/[controller]"; 17 | } 18 | /// 19 | /// Base controller routes 20 | /// 21 | public static class BaseController 22 | { 23 | public const string Add = "Add"; 24 | public const string Update = "Update"; 25 | public const string Delete = "Delete"; 26 | public const string GetOne = "GetOne"; 27 | public const string Search = "Search"; 28 | public const string List = "List"; 29 | public const string DownloadCsvExcel = "DownloadCsvExcel"; 30 | public const string SaveReplaceList = "SaveReplaceList"; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Src/OneLine/Constants/JwtAuthenticationSchemes.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Constants 2 | { 3 | /// 4 | /// Jwt authenticantion schemes 5 | /// 6 | public class JwtAuthenticationSchemes 7 | { 8 | /// 9 | /// Default value for AuthenticationScheme property in the JwtBearerAuthenticationOptions 10 | /// 11 | public const string Bearer = "Bearer"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/OneLine/Constants/MimeTypes.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Constants 2 | { 3 | /// 4 | /// Mime types utility used for upload and download purpose 5 | /// 6 | public static class MimeTypes 7 | { 8 | public static class Application 9 | { 10 | public const string AtomXml = "application/atom+xml"; 11 | public const string AtomcatXml = "application/atomcat+xml"; 12 | public const string Ecmascript = "application/ecmascript"; 13 | public const string JavaArchive = "application/java-archive"; 14 | public const string Javascript = "application/javascript"; 15 | public const string Json = "application/json"; 16 | public const string Mp4 = "application/mp4"; 17 | public const string OctetStream = "application/octet-stream"; 18 | public const string Pdf = "application/pdf"; 19 | public const string Pkcs10 = "application/pkcs10"; 20 | public const string Pkcs7Mime = "application/pkcs7-mime"; 21 | public const string Pkcs7Signature = "application/pkcs7-signature"; 22 | public const string Pkcs8 = "application/pkcs8"; 23 | public const string Postscript = "application/postscript"; 24 | public const string RdfXml = "application/rdf+xml"; 25 | public const string RssXml = "application/rss+xml"; 26 | public const string Rtf = "application/rtf"; 27 | public const string SmilXml = "application/smil+xml"; 28 | public const string XFontOtf = "application/x-font-otf"; 29 | public const string XFontTtf = "application/x-font-ttf"; 30 | public const string XFontWoff = "application/x-font-woff"; 31 | public const string XPkcs12 = "application/x-pkcs12"; 32 | public const string XShockwaveFlash = "application/x-shockwave-flash"; 33 | public const string XSilverlightApp = "application/x-silverlight-app"; 34 | public const string XhtmlXml = "application/xhtml+xml"; 35 | public const string Xml = "application/xml"; 36 | public const string XmlDtd = "application/xml-dtd"; 37 | public const string XsltXml = "application/xslt+xml"; 38 | public const string Zip = "application/zip"; 39 | } 40 | 41 | public static class Audio 42 | { 43 | public const string Midi = "audio/midi"; 44 | public const string Mp4 = "audio/mp4"; 45 | public const string Mpeg = "audio/mpeg"; 46 | public const string Ogg = "audio/ogg"; 47 | public const string Webm = "audio/webm"; 48 | public const string XAac = "audio/x-aac"; 49 | public const string XAiff = "audio/x-aiff"; 50 | public const string XMpegurl = "audio/x-mpegurl"; 51 | public const string XMsWma = "audio/x-ms-wma"; 52 | public const string XWav = "audio/x-wav"; 53 | } 54 | 55 | public static class Image 56 | { 57 | public const string Bmp = "image/bmp"; 58 | public const string Gif = "image/gif"; 59 | public const string Jpeg = "image/jpeg"; 60 | public const string Png = "image/png"; 61 | public const string SvgXml = "image/svg+xml"; 62 | public const string Tiff = "image/tiff"; 63 | public const string Webp = "image/webp"; 64 | } 65 | 66 | public static class Text 67 | { 68 | public const string Css = "text/css"; 69 | public const string Csv = "text/csv"; 70 | public const string Html = "text/html"; 71 | public const string Plain = "text/plain"; 72 | public const string RichText = "text/richtext"; 73 | public const string Sgml = "text/sgml"; 74 | public const string Yaml = "text/yaml"; 75 | } 76 | 77 | public static class Video 78 | { 79 | public const string Threegpp = "video/3gpp"; 80 | public const string H264 = "video/h264"; 81 | public const string Mp4 = "video/mp4"; 82 | public const string Mpeg = "video/mpeg"; 83 | public const string Ogg = "video/ogg"; 84 | public const string Quicktime = "video/quicktime"; 85 | public const string Webm = "video/webm"; 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ApiResponseable/IApiResponseable.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Models; 2 | using System; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// This interface is a definition of actions based on the state and response result of the api 8 | /// 9 | /// The api response type 10 | public interface IApiResponseable 11 | { 12 | /// 13 | /// The server response result 14 | /// 15 | IResponseResult> Response { get; set; } 16 | /// 17 | /// The server response result changed action 18 | /// 19 | Action>> ResponseChanged { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ApiResponseableCollectionable/IApiResponseableCollectionable.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace OneLine.Contracts 6 | { 7 | /// 8 | /// This interface is a definition of actions based on the state and response result collection of the api 9 | /// 10 | /// The type of the api response collection 11 | public interface IApiResponseableCollectionable 12 | { 13 | /// 14 | /// The response result collection 15 | /// 16 | IResponseResult>> ResponseCollection { get; set; } 17 | /// 18 | /// The response result collection changed action 19 | /// 20 | Action>>> ResponseCollectionChanged { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ApiResponseablePageable/IApiResponseablePageable.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace OneLine.Contracts 6 | { 7 | /// 8 | /// This interface is a definition of actions based on the state and response result paged of the api 9 | /// 10 | /// The api response paged type 11 | public interface IApiResponseablePageable 12 | { 13 | /// 14 | /// The response result paged 15 | /// 16 | IResponseResult>>> ResponsePaged { get; set; } 17 | /// 18 | /// The response result paged changed action 19 | /// 20 | Action>>>> ResponsePagedChanged { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ApplicationConfiguration/ApplicationConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Microsoft.Extensions.Primitives; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | public class ApplicationConfiguration : IApplicationConfiguration 7 | { 8 | public ApplicationConfiguration(IApplicationConfigurationSource applicationConfigurationSource) 9 | { 10 | var stream = applicationConfigurationSource.ConfigurationFileAssemblyFile.GetManifestResourceStream(applicationConfigurationSource.ConfigurationFilePath); 11 | Configuration = new ConfigurationBuilder().AddJsonStream(stream).Build(); 12 | } 13 | private protected IConfiguration Configuration { get; set; } 14 | public string this[string key] { get => Configuration[key]; set => Configuration[key] = value; } 15 | public IEnumerable GetChildren() 16 | { 17 | return Configuration.GetChildren(); 18 | } 19 | public IChangeToken GetReloadToken() 20 | { 21 | return Configuration.GetReloadToken(); 22 | } 23 | public IConfigurationSection GetSection(string key) 24 | { 25 | return Configuration.GetSection(key); 26 | } 27 | } 28 | public static partial class ServiceCollectionExtensions 29 | { 30 | public static IServiceCollection AddApplicationConfiguration(this IServiceCollection services) 31 | { 32 | return services.AddScoped(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ApplicationConfiguration/IApplicationConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | /// 6 | /// A service which manage the configuration file 7 | /// 8 | public interface IApplicationConfiguration : IConfiguration 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ApplicationConfigurationSource/ApplicationConfigurationSource.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | public class ApplicationConfigurationSource : IApplicationConfigurationSource 6 | { 7 | public string ConfigurationFilePath { get; set; } 8 | public Assembly ConfigurationFileAssemblyFile { get; set; } 9 | public string ResourceFilesBasePath { get; set; } 10 | public Assembly ResourceFilesAssemblyFile { get; set; } 11 | public ApplicationConfigurationSource() 12 | { 13 | } 14 | public ApplicationConfigurationSource(string configurationFilePath, Assembly configurationFileAssemblyFile, string resourceFilesBasePath, Assembly resourceFilesAssemblyFile) 15 | { 16 | ConfigurationFilePath = configurationFilePath; 17 | ConfigurationFileAssemblyFile = configurationFileAssemblyFile; 18 | ResourceFilesBasePath = resourceFilesBasePath; 19 | ResourceFilesAssemblyFile = resourceFilesAssemblyFile; 20 | } 21 | } 22 | public static partial class ServiceCollectionExtensions 23 | { 24 | public static IServiceCollection AddApplicationConfigurationSource(this IServiceCollection services) 25 | where TApplicationConfigurationSourceImplementation : class, IApplicationConfigurationSource 26 | { 27 | return services.AddScoped(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ApplicationConfigurationSource/IApplicationConfigurationSource.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | /// 6 | /// A service which tells where are static files locate wether in the assembly. 7 | /// 8 | public interface IApplicationConfigurationSource 9 | { 10 | public string ConfigurationFilePath { get; set; } 11 | public Assembly ConfigurationFileAssemblyFile { get; set; } 12 | public string ResourceFilesBasePath { get; set; } 13 | public Assembly ResourceFilesAssemblyFile { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ApplicationLocale/ApplicationLocale.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Contracts 2 | { 3 | public class ApplicationLocale : IApplicationLocale 4 | { 5 | private string ApplicationLocaleStorageKey { get; set; } 6 | private IDeviceStorage DeviceStorage { get; set; } 7 | public ApplicationLocale(IDeviceStorage deviceStorage, string applicationLocaleStorageKey) 8 | { 9 | DeviceStorage = deviceStorage; 10 | ApplicationLocaleStorageKey = applicationLocaleStorageKey; 11 | } 12 | /// 13 | public async Task GetApplicationLocale() 14 | { 15 | return await DeviceStorage.GetItem(ApplicationLocaleStorageKey, true); 16 | } 17 | /// 18 | public async Task SetApplicationLocale(string applicationLocale) 19 | { 20 | await DeviceStorage.SetItem(ApplicationLocaleStorageKey, applicationLocale, true); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ApplicationLocale/IApplicationLocale.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Contracts 2 | { 3 | /// 4 | /// A translator service using the resource manager 5 | /// 6 | public interface IApplicationLocale 7 | { 8 | /// 9 | /// Gets the current application locale from storage 10 | /// 11 | /// 12 | Task GetApplicationLocale(); 13 | /// 14 | /// Sets the current application locale in the storage 15 | /// 16 | /// 17 | Task SetApplicationLocale(string applicationLocale); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ApplicationState/ApplicationState.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using OneLine.Enums; 3 | using OneLine.Extensions; 4 | 5 | namespace OneLine.Contracts 6 | { 7 | public class ApplicationState : IApplicationState 8 | { 9 | private string UserStorageKey { get; set; } 10 | private string EncryptionKeyStorageKey { get; set; } 11 | private string ApplicationSessionStorageKey { get; set; } 12 | private IDeviceStorage DeviceStorage { get; set; } 13 | public ApplicationState(IDeviceStorage deviceStorage, string userStorageKey, string encryptionKeyStorageKey, string applicationSessionStorageKey) 14 | { 15 | DeviceStorage = deviceStorage; 16 | UserStorageKey = userStorageKey; 17 | EncryptionKeyStorageKey = encryptionKeyStorageKey; 18 | ApplicationSessionStorageKey = applicationSessionStorageKey; 19 | } 20 | /// 21 | public Task GetApplicationSession() 22 | { 23 | return DeviceStorage.GetItem(ApplicationSessionStorageKey, true); 24 | } 25 | /// 26 | public async Task SetApplicationSession(ApplicationSession applicationSession) 27 | { 28 | await DeviceStorage.SetItem(ApplicationSessionStorageKey, applicationSession, true); 29 | } 30 | /// 31 | public async Task GetApplicationEncryptionKey() 32 | { 33 | return await DeviceStorage.GetItem(EncryptionKeyStorageKey, true); 34 | } 35 | /// 36 | public async Task SetApplicationEncryptionKey(string encryptionKey) 37 | { 38 | if (string.IsNullOrWhiteSpace(encryptionKey)) 39 | { 40 | throw new ArgumentNullException(nameof(encryptionKey)); 41 | } 42 | await DeviceStorage.SetItem(EncryptionKeyStorageKey, encryptionKey, true); 43 | } 44 | /// 45 | public async Task GetApplicationUserSecure() 46 | { 47 | try 48 | { 49 | var applicationSession = await GetApplicationSession(); 50 | var encryptedUser = await DeviceStorage.GetItem(UserStorageKey, applicationSession.IsPersistent()); 51 | var applicationEncryptionKey = await GetApplicationEncryptionKey(); 52 | var jsonUser = encryptedUser.Decrypt(applicationEncryptionKey); 53 | return JsonConvert.DeserializeObject(jsonUser); 54 | } 55 | catch (Exception) 56 | { 57 | return default; 58 | } 59 | } 60 | /// 61 | public async Task SetApplicationUserSecure(TUser user, ApplicationSession applicationSession) 62 | { 63 | if (user.IsNull()) 64 | { 65 | throw new ArgumentNullException(nameof(user)); 66 | } 67 | var jsonUser = JsonConvert.SerializeObject(user); 68 | var applicationEncryptionKey = await GetApplicationEncryptionKey(); 69 | await DeviceStorage.SetItem(UserStorageKey, jsonUser.Encrypt(applicationEncryptionKey), applicationSession.IsPersistent()); 70 | } 71 | /// 72 | public async Task Logout() 73 | { 74 | var applicationSession = await GetApplicationSession(); 75 | await DeviceStorage.RemoveItem(UserStorageKey, applicationSession.IsPersistent()); 76 | await DeviceStorage.RemoveItem(EncryptionKeyStorageKey, true); 77 | await DeviceStorage.RemoveItem(ApplicationSessionStorageKey, true); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ApplicationState/IApplicationState.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | /// 6 | /// A base application state to manage the user state. 7 | /// 8 | public interface IApplicationState 9 | { 10 | /// 11 | /// Gets the application current user securely 12 | /// 13 | /// 14 | /// 15 | Task GetApplicationUserSecure(); 16 | /// 17 | /// Sets the application current user securely in local or session storage based on the 18 | /// 19 | /// 20 | /// 21 | /// 22 | /// 23 | Task SetApplicationUserSecure(TUser user, ApplicationSession applicationSession); 24 | /// 25 | /// Logs out the current user from the application 26 | /// 27 | /// 28 | Task Logout(); 29 | /// 30 | /// Gets the 31 | /// 32 | /// 33 | Task GetApplicationSession(); 34 | /// 35 | /// Sets the 36 | /// 37 | /// 38 | /// 39 | Task SetApplicationSession(ApplicationSession applicationSession); 40 | /// 41 | /// Gets the application encryption key 42 | /// 43 | /// 44 | Task GetApplicationEncryptionKey(); 45 | /// 46 | /// Sets the the application encryption key 47 | /// 48 | /// 49 | /// 50 | Task SetApplicationEncryptionKey(string encryptionKey); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/CancelableEventable/ICancelableEventable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | public interface ICancelableEventable 7 | { 8 | /// 9 | /// The cancel task 10 | /// 11 | /// 12 | Task Cancel(); 13 | /// 14 | /// The action before cancel 15 | /// 16 | Action OnBeforeCancel { get; set; } 17 | /// 18 | /// The action after cancel 19 | /// 20 | Action OnAfterCancel { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/CollectionAppendableReplaceableModeable/ICollectionAppendableReplaceableModeable.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | /// 6 | /// The collection mode wether is appendable or replaceable mode 7 | /// 8 | public interface ICollectionAppendableReplaceableModeable 9 | { 10 | /// 11 | /// The collection mode appendable or replaceable 12 | /// 13 | CollectionAppendReplaceMode CollectionAppendReplaceMode { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/CollectionFilterableSortable/ICollectionFilterableSortable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.ObjectModel; 3 | using System.Threading.Tasks; 4 | 5 | namespace OneLine.Contracts 6 | { 7 | /// 8 | /// The collection is filterable and sortable 9 | /// 10 | /// 11 | public interface ICollectionFilterableSortable 12 | { 13 | /// 14 | /// Filter and sort method 15 | /// 16 | /// 17 | Task FilterAndSort(); 18 | /// 19 | /// Filter and sort method by a property name and descending or ascending 20 | /// 21 | /// The property name to be sorted by 22 | /// Descending or ascending 23 | /// 24 | Task FilterAndSort(string sortBy, bool descending); 25 | /// 26 | /// Filter and sort method by a property name and descending or ascending with a filter predicate 27 | /// 28 | /// The property name to be sorted by 29 | /// Descending or ascending 30 | /// The predicate filter 31 | /// 32 | Task FilterAndSort(string sortBy, bool descending, Func filterPredicate); 33 | /// 34 | /// The filter predicate 35 | /// 36 | Func FilterPredicate { get; set; } 37 | /// 38 | /// The filter predicate changed action 39 | /// 40 | Action> FilterPredicateChanged { get; set; } 41 | /// 42 | /// The sort by filter by property name 43 | /// 44 | string FilterSortBy { get; set; } 45 | /// 46 | /// The filter sort by property name changed action 47 | /// 48 | Action FilterSortByChanged { get; set; } 49 | /// 50 | /// The sorting filter 51 | /// 52 | bool FilterDescending { get; set; } 53 | /// 54 | /// The sorting filter changed action 55 | /// 56 | Action FilterDescendingChanged { get; set; } 57 | /// 58 | /// The records filtered and sorted result 59 | /// 60 | ObservableRangeCollection RecordsFilteredSorted { get; set; } 61 | /// 62 | /// The records filtered and sorted result changed action 63 | /// 64 | Action> RecordsFilteredSortedChanged { get; set; } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/Contextable/IContextable.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Contracts 2 | { 3 | public interface IContextable 4 | { 5 | public TContext Context { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/CoreView/ICoreView.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Contracts 2 | { 3 | /// 4 | /// Defines a base core view with most common actions and options 5 | /// 6 | /// 7 | /// 8 | /// 9 | public interface ICoreView : 10 | IModelable, 11 | IHttpServiceable, 12 | ISearchExtraParameterable, 13 | ISearchableEventable, 14 | ICollectionFilterableSortable, 15 | ICollectionAppendableReplaceableModeable, 16 | ISelectable, 17 | IPageable, 18 | ISearchablePageable, 19 | IPageableNavigable, 20 | ISortable, 21 | IPropertySortable, 22 | IApiResponseable, 23 | IApiResponseablePageable, 24 | IApiResponseableCollectionable, 25 | ILoadableEventable, 26 | IMutableBlobDataCollectionableValidatable, 27 | ISaveableEventable, 28 | IValidatableEventable, 29 | IFormStateable, 30 | IFormModeable, 31 | IDeletableEventable, 32 | IResettableEventable, 33 | ICancelableEventable 34 | { 35 | /// 36 | /// A save file service 37 | /// 38 | public ISaveFile SaveFile { get; set; } 39 | /// 40 | /// A service which identifies the current device 41 | /// 42 | public IDevice Device { get; set; } 43 | /// 44 | /// A translator service using the resource manager 45 | /// 46 | public IResourceManagerLocalizer ResourceManagerLocalizer { get; set; } 47 | /// 48 | /// A base application state 49 | /// 50 | public IApplicationState ApplicationState { get; set; } 51 | /// 52 | /// A service which manage the configuration file 53 | /// 54 | public IApplicationConfiguration ApplicationConfiguration { get; set; } 55 | /// 56 | /// A service which manage the storage of a device 57 | /// 58 | public IDeviceStorage DeviceStorage { get; set; } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/DeletableEventable/IDeletableEventable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// The class is Deletable and eventable 8 | /// 9 | public interface IDeletableEventable 10 | { 11 | /// 12 | /// The delete task 13 | /// 14 | /// 15 | Task Delete(); 16 | /// 17 | /// The action before delete 18 | /// 19 | Action OnBeforeDelete { get; set; } 20 | /// 21 | /// The action after delete 22 | /// 23 | Action OnAfterDelete { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/Device/IDevice.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Contracts 2 | { 3 | /// 4 | /// A service which identifies the current device 5 | /// 6 | public interface IDevice 7 | { 8 | bool IsDesktop { get; } 9 | bool IsTablet { get; } 10 | bool IsMobile { get; } 11 | bool IsXamarinPlatform { get; } 12 | bool IsMauiPlatform { get; } 13 | bool IsAndroidDevice { get; } 14 | bool IstvOSDevice { get; } 15 | bool IsiOSDevice { get; } 16 | bool IsMacOSDevice { get; } 17 | bool IsMacCatalystDevice { get; } 18 | bool IsTizenDevice { get; } 19 | bool IsWinUIDevice { get; } 20 | bool IsWindowsOSPlatform { get; } 21 | bool IsLinuxOSPlatform { get; } 22 | bool IsOSXOSPlatform { get; } 23 | bool IsPhysical { get; } 24 | bool IsVirtual { get; } 25 | bool IsWebPlatform { get; } 26 | bool IsWebBlazorWAsmPlatform { get; } 27 | bool IsWebBlazorServerPlatform { get; } 28 | bool IsHybridPlatform { get; } 29 | bool Is32BitsArmOSArquitecture { get; } 30 | bool Is64BitsArmOSArquitecture { get; } 31 | bool Is32BitsOSArquitecture { get; } 32 | bool Is64BitsOSArquitecture { get; } 33 | bool Is32BitsArmProcessArquitecture { get; } 34 | bool Is64BitsArmProcessArquitecture { get; } 35 | bool Is32BitsProcessArquitecture { get; } 36 | bool Is64BitsProcessArquitecture { get; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/DeviceStorage/DeviceStorage.cs: -------------------------------------------------------------------------------- 1 | using BlazorBrowserStorage; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | public class DeviceStorage : IDeviceStorage 6 | { 7 | private ILocalStorage LocalStorage { get; set; } 8 | private ISessionStorage SessionStorage { get; set; } 9 | public static IDictionary SessionStorageDictionary { get; set; } 10 | public DeviceStorage(ILocalStorage localStorage, ISessionStorage sessionStorage) 11 | { 12 | SessionStorageDictionary = new Dictionary(); 13 | LocalStorage = localStorage; 14 | SessionStorage = sessionStorage; 15 | } 16 | /// 17 | public async Task Clear(bool useDevicePersistentStorageProvider = false) 18 | { 19 | if (useDevicePersistentStorageProvider) 20 | { 21 | 22 | #if ANDROID || IOS || MACCATALYST || WINDOWS || Linux 23 | Directory.Delete(FileSystem.Current.AppDataDirectory, true); 24 | #else 25 | await LocalStorage.Clear(); 26 | #endif 27 | } 28 | else 29 | { 30 | #if ANDROID || IOS || MACCATALYST || WINDOWS || Linux 31 | SessionStorageDictionary.Clear(); 32 | #else 33 | await SessionStorage.Clear(); 34 | #endif 35 | } 36 | } 37 | /// 38 | public async Task GetItem(string key, bool useDevicePersistentStorageProvider = false) 39 | { 40 | if (useDevicePersistentStorageProvider) 41 | { 42 | #if ANDROID || IOS || MACCATALYST || WINDOWS || Linux 43 | if(File.Exists(Path.Combine(FileSystem.Current.AppDataDirectory, key))) 44 | { 45 | var stringValue = await File.ReadAllTextAsync(Path.Combine(FileSystem.Current.AppDataDirectory, key)); 46 | if (!string.IsNullOrWhiteSpace(stringValue)) 47 | { 48 | return Newtonsoft.Json.JsonConvert.DeserializeObject(stringValue); 49 | } 50 | } 51 | return default(T); 52 | #else 53 | return await LocalStorage.GetItem(key); 54 | #endif 55 | } 56 | else 57 | { 58 | #if ANDROID || IOS || MACCATALYST || WINDOWS || Linux 59 | if (SessionStorageDictionary.ContainsKey(Path.Combine(FileSystem.Current.AppDataDirectory, key))) 60 | { 61 | var stringValue = SessionStorageDictionary[Path.Combine(FileSystem.Current.AppDataDirectory, key)]; 62 | if (!string.IsNullOrWhiteSpace(stringValue)) 63 | { 64 | return Newtonsoft.Json.JsonConvert.DeserializeObject(stringValue); 65 | } 66 | else 67 | { 68 | return default(T); 69 | } 70 | } 71 | return default(T); 72 | #else 73 | return await SessionStorage.GetItem(key); 74 | #endif 75 | } 76 | } 77 | /// 78 | public async Task RemoveItem(string key, bool useDevicePersistentStorageProvider = false) 79 | { 80 | if (useDevicePersistentStorageProvider) 81 | { 82 | #if ANDROID || IOS || MACCATALYST || WINDOWS || Linux 83 | if(File.Exists(Path.Combine(FileSystem.Current.AppDataDirectory, key))) 84 | { 85 | File.Delete(Path.Combine(FileSystem.Current.AppDataDirectory, key)); 86 | } 87 | #else 88 | await LocalStorage.RemoveItem(key); 89 | #endif 90 | } 91 | else 92 | { 93 | #if ANDROID || IOS || MACCATALYST || WINDOWS || Linux 94 | SessionStorageDictionary.Remove(key); 95 | #else 96 | await SessionStorage.RemoveItem(key); 97 | #endif 98 | } 99 | } 100 | /// 101 | public async Task SetItem(string key, T item, bool useDevicePersistentStorageProvider = false) 102 | { 103 | if (useDevicePersistentStorageProvider) 104 | { 105 | #if ANDROID || IOS || MACCATALYST || WINDOWS || Linux 106 | await File.WriteAllTextAsync(Path.Combine(FileSystem.Current.AppDataDirectory, key), Newtonsoft.Json.JsonConvert.SerializeObject(item)); 107 | #else 108 | await LocalStorage.SetItem(key, item); 109 | #endif 110 | } 111 | else 112 | { 113 | #if ANDROID || IOS || MACCATALYST || WINDOWS || Linux 114 | SessionStorageDictionary.Add(Path.Combine(FileSystem.Current.AppDataDirectory, key), Newtonsoft.Json.JsonConvert.SerializeObject(item)); 115 | #else 116 | await SessionStorage.SetItem(key, item); 117 | #endif 118 | } 119 | } 120 | } 121 | public static partial class ServiceCollectionExtensions 122 | { 123 | public static IServiceCollection AddDeviceStorage(this IServiceCollection services) 124 | { 125 | return services.AddScoped(); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/DeviceStorage/IDeviceStorage.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Contracts 2 | { 3 | /// 4 | /// A service which manage the storage of a device 5 | /// 6 | public interface IDeviceStorage 7 | { 8 | /// 9 | /// Gets an item from the device storage 10 | /// 11 | /// 12 | /// The key of the item to look up in the device storage 13 | /// Tells to use persistent storage provider of the device 14 | /// 15 | Task GetItem(string key, bool useDevicePersistentStorageProvider = false); 16 | /// 17 | /// Removes an item from the device storage 18 | /// 19 | /// The key of the item to look up in the device storage 20 | /// Tells to use persistent storage provider of the device 21 | /// 22 | Task RemoveItem(string key, bool useDevicePersistentStorageProvider = false); 23 | /// 24 | /// Sets an item into the device storage 25 | /// 26 | /// 27 | /// The key of the item to look up in the device storage 28 | /// The item to be stored 29 | /// Tells to use persistent storage provider of the device 30 | /// 31 | Task SetItem(string key, T item, bool useDevicePersistentStorageProvider = false); 32 | /// 33 | /// Clears all items in the device storage 34 | /// 35 | /// Tells to use persistent storage provider of the device 36 | /// 37 | Task Clear(bool useDevicePersistentStorageProvider = false); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/FormModeable/IFormModeable.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | using System; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// The class as FormMode single or multiple. 8 | /// 9 | public interface IFormModeable 10 | { 11 | /// 12 | /// The form mode. Single or multiple. 13 | /// 14 | FormMode FormMode { get; set; } 15 | /// 16 | /// The form mode changed action. 17 | /// 18 | Action FormModeChanged { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/FormStateable/IFormStateable.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | using System; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// The class has a form state 8 | /// 9 | public interface IFormStateable 10 | { 11 | /// 12 | /// The form state. See 13 | /// 14 | FormState FormState { get; set; } 15 | /// 16 | /// The form state changed action 17 | /// 18 | Action FormStateChanged { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/HttpCrudExtendedService/IHttpCrudExtendedService.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using OneLine.Models; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// Http crud service extended with import and export of data using csv files 8 | /// 9 | /// 10 | /// 11 | public interface IHttpCrudExtendedService : IHttpCrudService 12 | { 13 | /// 14 | /// The download csv server method 15 | /// 16 | string DownloadCsvMethod { get; set; } 17 | /// 18 | /// The upload csv server method 19 | /// 20 | string UploadCsvMethod { get; set; } 21 | /// 22 | /// The download csv server method as a 23 | /// 24 | /// 25 | /// 26 | /// 27 | Task> DownloadCsvAsByteArrayAsync(ISearchPaging SearchPaging, object searchExtraParams); 28 | ///// 29 | ///// The dowload csv server method as a 30 | ///// 31 | ///// 32 | ///// 33 | ///// 34 | //Task> DownloadCsvAsStreamAsync(ISearchPaging SearchPaging, object searchExtraParams); 35 | /// 36 | /// The download csv server method as a 37 | /// 38 | /// 39 | /// 40 | /// 41 | Task> DownloadCsvAsHttpResponseMessageAsync(ISearchPaging SearchPaging, object searchExtraParams); 42 | /// 43 | /// The upload csv server method as a 44 | /// 45 | /// 46 | /// 47 | /// 48 | /// 49 | Task>>> UploadCsvAsync(IEnumerable blobDatas, IValidator validator, HttpMethod httpMethod); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/HttpService/IHttpService.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | /// 6 | /// Defines a http service using the 7 | /// 8 | public interface IHttpService 9 | { 10 | /// 11 | /// The api url path 12 | /// 13 | string Api { get; set; } 14 | /// 15 | /// The http client 16 | /// 17 | HttpClient HttpClient { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/HttpServiceable/IHttpServiceable.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Contracts 2 | { 3 | /// 4 | /// Defines that the class is http serviceable 5 | /// 6 | /// 7 | public interface IHttpServiceable 8 | { 9 | THttpService HttpService { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/HttpUserBlobsService/IHttpUserBlobsService.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using OneLine.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Net.Http; 7 | using System.Threading.Tasks; 8 | 9 | namespace OneLine.Contracts 10 | { 11 | interface IHttpUserBlobsService : IHttpCrudExtendedService 12 | { 13 | string DownloadBinaryMethod { get; set; } 14 | string DownloadRangeBinaryMethod { get; set; } 15 | string DownloadBase64Method { get; set; } 16 | string DownloadRangeBase64Method { get; set; } 17 | string GetOneOwnsMethod { get; set; } 18 | string SearchOwnsMethod { get; set; } 19 | string ListMethod { get; set; } 20 | string ListOwnsMethod { get; set; } 21 | string DownloadCsvOwnsMethod { get; set; } 22 | Task>> AddAsync(IEnumerable blobDatas); 23 | Task>>> AddRangeAsync(IEnumerable blobDatas); 24 | Task>>> UpdateAsync(T userBlobs, IEnumerable blobDatas); 25 | Task, IEnumerable>>>> UpdateRangeAsync(IEnumerable userBlobs, IEnumerable blobDatas); 26 | Task> DownloadBinaryAsync(TIdentifier identifier, IValidator validator); 27 | Task> DownloadRangeBinaryAsync(IEnumerable identifiers, IValidator validator); 28 | Task>>> DownloadBase64Async(TIdentifier identifier, IValidator validator); 29 | Task, IEnumerable>>>> DownloadRangeBase64Async(IEnumerable identifiers, IValidator validator); 30 | Task>> GetOneOwnsAsync(TIdentifier identifier, IValidator validator); 31 | Task>>>> SearchOwnsAsync(ISearchPaging SearchPaging, object searchExtraParams); 32 | Task>>>> ListAsync(ISearchPaging SearchPaging, object searchExtraParams); 33 | Task>>>> ListOwnsAsync(ISearchPaging SearchPaging, object searchExtraParams); 34 | Task> DownloadCsvOwnsAsByteArrayAsync(ISearchPaging SearchPaging, object searchExtraParams); 35 | //Task> DownloadCsvOwnsAsStreamAsync(ISearchPaging SearchPaging, object searchExtraParams); 36 | Task> DownloadCsvOwnsAsHttpResponseMessageAsync(ISearchPaging SearchPaging, object searchExtraParams); 37 | } 38 | } -------------------------------------------------------------------------------- /Src/OneLine/Contracts/LoadableEventable/ILoadableEventable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// Defines a class that has loading and before and after loading capabilities 8 | /// 9 | public interface ILoadableEventable 10 | { 11 | /// 12 | /// The load method. This method should be chained with 13 | /// 14 | /// 15 | Task Load(); 16 | /// 17 | /// The on before load method. This method should be chained with 18 | /// 19 | Action OnBeforeLoad { get; set; } 20 | /// 21 | /// The on after load method. 22 | /// 23 | Action OnAfterLoad { get; set; } 24 | /// 25 | /// Let's know when auto load is required 26 | /// 27 | bool AutoLoad { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/Modelable/IModelable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | /// 6 | /// Defines properties that are holder for the models context of a class 7 | /// 8 | /// 9 | /// 10 | public interface IModelable 11 | { 12 | /// 13 | /// The identifier 14 | /// 15 | TIdentifier Identifier { get; set; } 16 | /// 17 | /// The identifier changed action callback 18 | /// 19 | Action IdentifierChanged { get; set; } 20 | /// 21 | /// The identifiers 22 | /// 23 | IEnumerable Identifiers { get; set; } 24 | /// 25 | /// The identifiers changed action callback 26 | /// 27 | Action> IdentifiersChanged { get; set; } 28 | /// 29 | /// The context record 30 | /// 31 | T Record { get; set; } 32 | /// 33 | /// The context record changed action callback 34 | /// 35 | Action RecordChanged { get; set; } 36 | /// 37 | /// The context records 38 | /// 39 | ObservableRangeCollection Records { get; set; } 40 | /// 41 | /// The context records changed action callback 42 | /// 43 | Action> RecordsChanged { get; set; } 44 | /// 45 | /// Whether to allow duplicates on 46 | /// 47 | bool AllowDuplicates { get; set; } 48 | } 49 | } -------------------------------------------------------------------------------- /Src/OneLine/Contracts/MutableBlobDataCollectionableValidatable/IMutableBlobDataCollectionableValidatable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using System.Threading.Tasks; 4 | 5 | namespace OneLine.Contracts 6 | { 7 | /// 8 | /// This interface is a definition of blob data representation 9 | /// 10 | public interface IMutableBlobDataCollectionableValidatable 11 | { 12 | /// 13 | /// Validates mutable blob datas 14 | /// 15 | /// 16 | Task ValidateMutableBlobDatas(); 17 | /// 18 | /// Clears mutable blob datas with rules 19 | /// 20 | void ClearMutableBlobDatasWithRules(); 21 | /// 22 | /// Get mutable blob datas with rules properties of the model context 23 | /// 24 | /// 25 | IEnumerable GetMutableBlobDatasWithRulesProperties(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/Notification/INotification.cs: -------------------------------------------------------------------------------- 1 | using BlazorNotification; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | public interface INotification 6 | { 7 | IBlazorNotificationService BlazorNotificationService { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /Src/OneLine/Contracts/Notification/Notification.cs: -------------------------------------------------------------------------------- 1 | using BlazorNotification; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | public class Notification : INotification 6 | { 7 | public IBlazorNotificationService BlazorNotificationService { get; set; } 8 | public Notification(IBlazorNotificationService blazorNotificationService) 9 | { 10 | BlazorNotificationService = blazorNotificationService; 11 | } 12 | } 13 | public static partial class ServiceCollectionExtensions 14 | { 15 | public static IServiceCollection AddNotification(this IServiceCollection services) 16 | { 17 | return services.AddScoped(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/Pageable/IPageable.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Models; 2 | using System; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// Defines a pageable class 8 | /// 9 | public interface IPageable 10 | { 11 | /// 12 | /// The paging model 13 | /// 14 | IPaging Paging { get; set; } 15 | /// 16 | /// Paging changed action callback 17 | /// 18 | Action PagingChanged { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/PageableNavigable/IPageableNavigable.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | /// 6 | /// Defines methods that works with a paged data and it's navigation. 7 | /// 8 | public interface IPageableNavigable 9 | { 10 | /// 11 | /// Navigates the previous page 12 | /// 13 | /// 14 | Task GoPreviousPage(); 15 | /// 16 | /// Navigates previous page changing the 17 | /// 18 | /// The page size 19 | /// 20 | Task GoPreviousPage(int pageSize); 21 | /// 22 | /// Navigates previous page changing the 23 | /// 24 | /// The sort by property name 25 | /// 26 | Task GoPreviousPage(string sortBy); 27 | /// 28 | /// Navigates previous page changing the and 29 | /// 30 | /// The page size 31 | /// The sort by property name 32 | /// 33 | Task GoPreviousPage(int pageSize, string sortBy); 34 | /// 35 | /// Navigates next page 36 | /// 37 | /// 38 | Task GoNextPage(); 39 | /// 40 | /// Navigates next page changing the 41 | /// 42 | /// The page size 43 | /// 44 | Task GoNextPage(int pageSize); 45 | /// 46 | /// Navigates next page changing the 47 | /// 48 | /// The sort by property name 49 | /// 50 | Task GoNextPage(string sortBy); 51 | /// 52 | /// Navigates next page changing the and 53 | /// 54 | /// The page size 55 | /// The sort by property name 56 | /// 57 | Task GoNextPage(int pageSize, string sortBy); 58 | /// 59 | /// Navigates to the specified page by the and 60 | /// 61 | /// The page index 62 | /// The page size 63 | /// 64 | Task GoToPage(int pageIndex, int pageSize); 65 | /// 66 | /// Navigates to the specified page by the and 67 | /// 68 | /// The page index 69 | /// The sort by property name 70 | /// 71 | Task GoToPage(int pageIndex, string sortBy); 72 | /// 73 | /// Navigates to the specified page by the , and 74 | /// 75 | /// The page index 76 | /// The page size 77 | /// The sort by property name 78 | /// 79 | Task GoToPage(int pageIndex, int pageSize, string sortBy); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/PropertySortable/IPropertySortable.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | /// 6 | /// Defines methods to sort by a property of the model context 7 | /// 8 | public interface IPropertySortable 9 | { 10 | /// 11 | /// Sorts the by property name 12 | /// 13 | /// The sort by property name 14 | /// 15 | Task SortBy(string sortBy); 16 | /// 17 | /// Sorts the by property name 18 | /// 19 | /// The sort by property name 20 | /// Descending? 21 | /// 22 | Task SortBy(string sortBy, bool descending); 23 | /// 24 | /// Sorts the ascending by property name 25 | /// 26 | /// The sort by property name 27 | /// 28 | Task SortByAscending(string sortBy); 29 | /// 30 | /// Sorts the descending by property name 31 | /// 32 | /// The sort by property name 33 | /// 34 | Task SortByDescending(string sortBy); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ResettableEventable/IResettableEventable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// Define method to reset a context with before and after actions 8 | /// 9 | public interface IResettableEventable 10 | { 11 | /// 12 | /// The reset method. This method should be chained with 13 | /// 14 | /// 15 | Task Reset(); 16 | /// 17 | /// The before reset action callback. This method should be chained with 18 | /// 19 | Action OnBeforeReset { get; set; } 20 | /// 21 | /// The on after reset method. This method should be called from 22 | /// 23 | Action OnAfterReset { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ResourceManagerLocalizer/IResourceManagerLocalizer.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | /// 6 | /// A translator service using the resource manager 7 | /// 8 | public interface IResourceManagerLocalizer 9 | { 10 | // 11 | // Summary: 12 | // Gets a resource value. 13 | // 14 | // Parameters: 15 | // key: 16 | // The resource key. 17 | // 18 | // Returns: 19 | // The resource value. 20 | string this[string key] { get; } 21 | /// 22 | /// Gets the current application resource manager 23 | /// 24 | ResourceManager ResourceManager { get; set; } 25 | /// 26 | /// Sets the and 27 | /// with the current application locale 28 | /// 29 | /// 30 | Task SetCurrentThreadCulture(); 31 | /// 32 | /// Sets the and 33 | /// with the specified application locale 34 | /// 35 | /// 36 | /// 37 | Task SetCurrentThreadCulture(string applicationLocale); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ResourceManagerLocalizer/ResourceManagerLocalizer.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using System.Resources; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | public class ResourceManagerLocalizer : IResourceManagerLocalizer 7 | { 8 | private IApplicationConfigurationSource ApplicationConfigurationSource { get; set; } 9 | private IApplicationLocale ApplicationLocale { get; set; } 10 | private string CurrentApplicationLocale { get; set; } 11 | public ResourceManager ResourceManager { get; set; } 12 | public string this[string key] 13 | { 14 | get => string.IsNullOrWhiteSpace(CurrentApplicationLocale) ? 15 | ResourceManager.GetString(key) : 16 | ResourceManager.GetString(key, new CultureInfo(CurrentApplicationLocale)); 17 | } 18 | public ResourceManagerLocalizer(IApplicationConfigurationSource applicationConfigurationSource) 19 | { 20 | ApplicationConfigurationSource = applicationConfigurationSource; 21 | ResourceManager = new ResourceManager(ApplicationConfigurationSource.ResourceFilesBasePath, ApplicationConfigurationSource.ResourceFilesAssemblyFile); 22 | } 23 | public ResourceManagerLocalizer(IApplicationConfigurationSource applicationConfigurationSource, IApplicationLocale applicationLocale) 24 | { 25 | ApplicationConfigurationSource = applicationConfigurationSource; 26 | ResourceManager = new ResourceManager(ApplicationConfigurationSource.ResourceFilesBasePath, ApplicationConfigurationSource.ResourceFilesAssemblyFile); 27 | ApplicationLocale = applicationLocale; 28 | new Action(async () => 29 | { 30 | CurrentApplicationLocale = await ApplicationLocale.GetApplicationLocale(); 31 | await SetCurrentThreadCulture(); 32 | }).Invoke(); 33 | } 34 | /// 35 | public async Task SetCurrentThreadCulture() 36 | { 37 | var applicationLocale = await ApplicationLocale.GetApplicationLocale(); 38 | if (!string.IsNullOrWhiteSpace(applicationLocale)) 39 | { 40 | CurrentApplicationLocale = applicationLocale; 41 | var currentCulture = new CultureInfo(applicationLocale); 42 | CultureInfo.CurrentCulture = currentCulture; 43 | CultureInfo.CurrentUICulture = currentCulture; 44 | CultureInfo.DefaultThreadCurrentCulture = currentCulture; 45 | CultureInfo.DefaultThreadCurrentUICulture = currentCulture; 46 | Thread.CurrentThread.CurrentCulture = currentCulture; 47 | Thread.CurrentThread.CurrentUICulture = currentCulture; 48 | } 49 | } 50 | /// 51 | public async Task SetCurrentThreadCulture(string applicationLocale) 52 | { 53 | await ApplicationLocale.SetApplicationLocale(applicationLocale); 54 | CurrentApplicationLocale = applicationLocale; 55 | var currentCulture = new CultureInfo(applicationLocale); 56 | CultureInfo.CurrentCulture = currentCulture; 57 | CultureInfo.CurrentUICulture = currentCulture; 58 | CultureInfo.DefaultThreadCurrentCulture = currentCulture; 59 | CultureInfo.DefaultThreadCurrentUICulture = currentCulture; 60 | Thread.CurrentThread.CurrentCulture = currentCulture; 61 | Thread.CurrentThread.CurrentUICulture = currentCulture; 62 | } 63 | } 64 | public static partial class ServiceCollectionExtensions 65 | { 66 | public static IServiceCollection AddResourceManagerLocalizer(this IServiceCollection services) 67 | { 68 | return services.AddScoped(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/SaveFile/ISaveFile.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Contracts 2 | { 3 | /// 4 | /// A save file service 5 | /// 6 | public interface ISaveFile 7 | { 8 | /// 9 | /// Saves or downloads a file 10 | /// 11 | /// 12 | /// 13 | /// 14 | Task SaveFileAsync(Stream stream, string pathOrDownloadFileName); 15 | /// 16 | /// Saves or downloads a file 17 | /// 18 | /// 19 | /// 20 | /// 21 | /// 22 | Task SaveFileAsync(Stream stream, string pathOrDownloadFileName, int bufferSize); 23 | /// 24 | /// Saves or downloads a file 25 | /// 26 | /// 27 | /// 28 | /// 29 | Task SaveFileAsync(byte[] byteArray, string pathOrDownloadFileName); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/SaveFile/SaveFile.cs: -------------------------------------------------------------------------------- 1 | using BlazorDownloadFile; 2 | using OneLine.Extensions; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | public class SaveFile : ISaveFile 7 | { 8 | private IDevice Device { get; set; } 9 | private IBlazorDownloadFileService BlazorDownloadFileService { get; set; } 10 | public SaveFile() 11 | { } 12 | public SaveFile(IDevice device) 13 | { 14 | Device = device; 15 | } 16 | public SaveFile(IDevice device, IBlazorDownloadFileService blazorDownloadFileService) 17 | { 18 | Device = device; 19 | BlazorDownloadFileService = blazorDownloadFileService; 20 | } 21 | public async Task SaveFileAsync(Stream stream, string pathOrDownloadFileName, int bufferSize) 22 | { 23 | if (Device.IsXamarinPlatform) 24 | { 25 | await stream.WriteStreamToFileSystemAsync(pathOrDownloadFileName, bufferSize); 26 | } 27 | else if (Device.IsWebPlatform) 28 | { 29 | await BlazorDownloadFileService.DownloadFile(pathOrDownloadFileName, stream, bufferSize); 30 | } 31 | else 32 | { 33 | _ = new PlatformNotSupportedException("Saving a file seems not to be supported by this platform. We could not recognize wether the platform is running on xamarin or blazor"); 34 | } 35 | } 36 | public async Task SaveFileAsync(byte[] byteArray, string pathOrDownloadFileName) 37 | { 38 | if (Device.IsXamarinPlatform) 39 | { 40 | await File.WriteAllBytesAsync(pathOrDownloadFileName, byteArray); 41 | } 42 | else if (Device.IsWebPlatform) 43 | { 44 | await BlazorDownloadFileService.DownloadFile(pathOrDownloadFileName, byteArray, "application/octet-stream"); 45 | } 46 | else 47 | { 48 | _ = new PlatformNotSupportedException("Saving a file seems not to be supported by this platform. We could not recognize wether the platform is running on xamarin or blazor"); 49 | } 50 | } 51 | public async Task SaveFileAsync(Stream stream, string pathOrDownloadFileName) 52 | { 53 | if (Device.IsXamarinPlatform) 54 | { 55 | await File.WriteAllBytesAsync(pathOrDownloadFileName, await stream.ToByteArrayAsync()); 56 | } 57 | else if (Device.IsWebPlatform) 58 | { 59 | await BlazorDownloadFileService.DownloadFile(pathOrDownloadFileName, stream, "application/octet-stream"); 60 | } 61 | else 62 | { 63 | _ = new PlatformNotSupportedException("Saving a file seems not to be supported by this platform. We could not recognize wether the platform is running on xamarin or blazor"); 64 | } 65 | } 66 | } 67 | public static partial class ServiceCollectionExtensions 68 | { 69 | public static IServiceCollection AddSaveFile(this IServiceCollection services) 70 | { 71 | return services.AddScoped(); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/SaveableEventable/ISaveableEventable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// Defines method to save with before and after action callbacks 8 | /// 9 | public interface ISaveableEventable 10 | { 11 | /// 12 | /// The save method. This method should be chained with 13 | /// 14 | /// 15 | Task Save(); 16 | /// 17 | /// The before save action callback. This method should be chained with 18 | /// 19 | Action OnBeforeSave { get; set; } 20 | /// 21 | /// The after saver action callback. This method should be called by 22 | /// 23 | Action OnAfterSave { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/SearchExtraParameterable/ISearchExtraParameterable.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | /// 6 | /// Defines a property which is capable to be an extra parameter fo seach purpose 7 | /// 8 | /// 9 | public interface ISearchExtraParameterable 10 | { 11 | /// 12 | /// The search extra paremeters 13 | /// 14 | TSearchExtraParams SearchExtraParams { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/SearchableEventable/ISearchableEventable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// Defines search method with setting options and before and after action callbacks 8 | /// 9 | public interface ISearchableEventable 10 | { 11 | /// 12 | /// The before search action callback. This method should be chained with 13 | /// 14 | Action OnBeforeSearch { get; set; } 15 | /// 16 | /// The search method. This mthod should be chained with 17 | /// 18 | /// 19 | Task Search(); 20 | /// 21 | /// The after search action callback. This method should be called by 22 | /// 23 | Action OnAfterSearch { get; set; } 24 | /// 25 | /// Indicates when we should peform an initial search 26 | /// 27 | bool InitialAutoSearch { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/SearchablePageable/ISearchablePageable.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Models; 2 | using System; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// Defines a property which holds a search with paging capabilities 8 | /// 9 | public interface ISearchablePageable 10 | { 11 | /// 12 | /// The search and paging property 13 | /// 14 | ISearchPaging SearchPaging { get; set; } 15 | /// 16 | /// The search and paging action callback 17 | /// 18 | Action SearchPagingChanged { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/Selectable/ISelectable.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | using System.Threading.Tasks; 6 | 7 | namespace OneLine.Contracts 8 | { 9 | /// 10 | /// Defines properties and methods for selection mode, options and actions 11 | /// 12 | /// 13 | public interface ISelectable 14 | { 15 | /// 16 | /// The record selection mode 17 | /// 18 | RecordsSelectionMode RecordsSelectionMode { get; set; } 19 | /// 20 | /// The context selected record 21 | /// 22 | T SelectedRecord { get; set; } 23 | /// 24 | /// The context selecte records 25 | /// 26 | System.Collections.ObjectModel.ObservableRangeCollection SelectedRecords { get; set; } 27 | /// 28 | /// The minimun allowed o required records selections 29 | /// 30 | long MinimumRecordsSelections { get; set; } 31 | /// 32 | /// The maximun allowed o required records selections 33 | /// 34 | long MaximumRecordsSelections { get; set; } 35 | /// 36 | /// The minimun records selection indicator 37 | /// 38 | bool MinimumRecordsSelectionsReached { get; set; } 39 | /// 40 | /// The maximun records selection indicator 41 | /// 42 | bool MaximumRecordsSelectionsReached { get; set; } 43 | /// 44 | /// The select record method 45 | /// 46 | /// 47 | /// 48 | Task SelectRecord(T selectedRecord); 49 | /// 50 | /// The select records method 51 | /// 52 | /// 53 | /// 54 | Task SelectRecords(IEnumerable selectedRecords); 55 | /// 56 | /// The before selected record action callback. This action callback should be chained with or 57 | /// 58 | Action BeforeSelectedRecord { get; set; } 59 | /// 60 | /// The after selected record action callback. This action callback should be called from or 61 | /// 62 | Action AfterSelectedRecord { get; set; } 63 | /// 64 | /// The selected record changed action callback 65 | /// 66 | Action SelectedRecordChanged { get; set; } 67 | /// 68 | /// The selected records changed action callback 69 | /// 70 | Action> SelectedRecordsChanged { get; set; } 71 | /// 72 | /// The minimun records selection reached indicator action callback 73 | /// 74 | Action MinimumRecordsSelectionsReachedChanged { get; set; } 75 | /// 76 | /// The maximum records selection reached indicator action callback 77 | /// 78 | Action MaximumRecordsSelectionsReachedChanged { get; set; } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/Sortable/ISortable.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | /// 6 | /// Defines methods for sortable capabilities 7 | /// 8 | public interface ISortable 9 | { 10 | /// 11 | /// Toggles sorting descending or ascending 12 | /// 13 | /// 14 | Task Sort(); 15 | /// 16 | /// Sorts descending or ascending 17 | /// 18 | /// 19 | /// 20 | Task Sort(bool descending); 21 | /// 22 | /// Sorts ascending 23 | /// 24 | /// 25 | Task SortAscending(); 26 | /// 27 | /// Sorts descending 28 | /// 29 | /// 30 | Task SortDescending(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/SupportedCultures/ISupportedCultures.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | public interface ISupportedCultures 6 | { 7 | IEnumerable Cultures { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/SupportedCultures/SupportedCultures.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace OneLine.Contracts 4 | { 5 | public class SupportedCultures : ISupportedCultures 6 | { 7 | public IEnumerable Cultures { get; set; } 8 | public SupportedCultures() 9 | { 10 | } 11 | } 12 | public static partial class ServiceCollectionExtensions 13 | { 14 | public static IServiceCollection AddSupportedCultures(this IServiceCollection services) 15 | where TSupportedCulturesImplementation : class, ISupportedCultures 16 | { 17 | return services.AddScoped(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/ValidatableEventable/IValidatableEventable.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using FluentValidation.Results; 3 | using System; 4 | using System.Threading.Tasks; 5 | 6 | namespace OneLine.Contracts 7 | { 8 | /// 9 | /// Defines methods, properties and action callback to perform validations 10 | /// 11 | public interface IValidatableEventable 12 | { 13 | /// 14 | /// The context validator with the validation rules 15 | /// 16 | IValidator Validator { get; set; } 17 | /// 18 | /// The validation result 19 | /// 20 | ValidationResult ValidationResult { get; set; } 21 | /// 22 | /// The validation result changed action callback 23 | /// 24 | Action ValidationResultChanged { get; set; } 25 | /// 26 | /// Indicator whether the succedded or failed 27 | /// 28 | bool IsValidModelState { get; set; } 29 | /// 30 | /// changed action callback 31 | /// 32 | Action IsValidModelStateChanged { get; set; } 33 | /// 34 | /// Before validation action callback. This action callback should be chained with 35 | /// 36 | Action OnBeforeValidate { get; set; } 37 | /// 38 | /// The validate method. This method should be chained with 39 | /// 40 | /// 41 | Task Validate(); 42 | /// 43 | /// The afte validate action callback. This method should be called from 44 | /// 45 | Action OnAfterValidate { get; set; } 46 | } 47 | } -------------------------------------------------------------------------------- /Src/OneLine/Contracts/WorkFlowManager/IWorkFlowManager.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | namespace OneLine.Contracts 7 | { 8 | /// 9 | /// Defines properties and methods that should define the process and execution of a workflow process 10 | /// 11 | /// 12 | /// 13 | public interface IWorkFlowManager 14 | { 15 | /// 16 | /// The property name that holds the state of the workflow process 17 | /// 18 | Func StatePropertyName { get; set; } 19 | /// 20 | /// The stateable record of the process 21 | /// 22 | T Record { get; set; } 23 | /// 24 | /// The workflow processes 25 | /// 26 | IEnumerable> WorkFlowStateProcesses { get; set; } 27 | /// 28 | /// The method that runs the workflow processes 29 | /// 30 | /// 31 | ValueTask> RunWorkFlowProcessAsync(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Src/OneLine/Contracts/WorkFlowStateProcess/IWorkFlowStateProcess.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Models; 2 | using System.Threading.Tasks; 3 | 4 | namespace OneLine.Contracts 5 | { 6 | /// 7 | /// Defines a work flow state process 8 | /// 9 | /// The type of the record 10 | /// The state of the record 11 | public interface IWorkFlowStateProcess 12 | { 13 | /// 14 | /// The record 15 | /// 16 | T Record { get; set; } 17 | /// 18 | /// The current state of the process 19 | /// 20 | TState CurrentState { get; set; } 21 | /// 22 | /// The next state of the process 23 | /// 24 | TState NextState { get; set; } 25 | /// 26 | /// The method which tells when to proceed to the next process and state 27 | /// 28 | /// 29 | Task ProceedNextStateProcessWhen(); 30 | /// 31 | /// The process to do to move to the next state process 32 | /// 33 | /// 34 | Task> ProceedNextStateProcess(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Src/OneLine/Enums/ApiResponseStatus.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Enums 2 | { 3 | /// 4 | /// Determines the status of the transaction executed by the Api whether it failed or succeeded 5 | /// 6 | public enum ApiResponseStatus 7 | { 8 | Failed, 9 | Succeeded 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/OneLine/Enums/ApplicationSession.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Enums 2 | { 3 | /// 4 | /// Determines the application session storage whether it will use the local storage or the session storage. 5 | /// 6 | public enum ApplicationSession 7 | { 8 | SessionStorage, 9 | LocalStorage 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/OneLine/Enums/CollectionAppendReplaceMode.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Enums 2 | { 3 | /// 4 | /// Determines the collection mode wether it will append o replace the current collection. 5 | /// 6 | public enum CollectionAppendReplaceMode 7 | { 8 | Replace, 9 | Add 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/OneLine/Enums/FormMode.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Enums 2 | { 3 | /// 4 | /// Determines the form mode whether is single or multiple mode. 5 | /// 6 | public enum FormMode 7 | { 8 | Single, 9 | Multiple 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/OneLine/Enums/FormState.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Enums 2 | { 3 | /// 4 | /// Dtermines the form state wether is on create, edit, copy, delete, deleted, details or read only state. 5 | /// 6 | public enum FormState 7 | { 8 | Create, 9 | Edit, 10 | Copy, 11 | Delete, 12 | Deleted, 13 | Details, 14 | ReadOnly 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/OneLine/Enums/RecordsSelectionMode.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Enums 2 | { 3 | /// 4 | /// Determines the selection mode whether is single or multiple when selecting records from a list. 5 | /// 6 | public enum RecordsSelectionMode 7 | { 8 | Single, 9 | Multiple 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Src/OneLine/Enums/SaveOperation.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Enums 2 | { 3 | /// 4 | /// Determines the save operation whether is add or update. 5 | /// 6 | public enum SaveOperation 7 | { 8 | Any, 9 | Add, 10 | Update 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/OneLine/Enums/TransactionType.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Enums 2 | { 3 | /// 4 | /// Determines the transaction type wether is add, update, delete, soft delete, soft undelete or search. 5 | /// 6 | public enum TransactionType 7 | { 8 | Add, 9 | Update, 10 | Delete, 11 | SoftDelete, 12 | SoftUndelete, 13 | Search 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/ApiResponseStatusExtensions.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | using OneLine.Models; 3 | 4 | namespace OneLine.Extensions 5 | { 6 | public static class ApiResponseStatusExtensions 7 | { 8 | /// 9 | /// Checks if the Api Response Status Succeeded 10 | /// 11 | /// 12 | /// 13 | 14 | public static bool Succeeded(this ApiResponseStatus apiResponseStatus) 15 | { 16 | return apiResponseStatus.Equals(ApiResponseStatus.Succeeded); 17 | } 18 | /// 19 | /// Checks if the Api Response Status Failed 20 | /// 21 | /// 22 | /// 23 | 24 | public static bool Failed(this ApiResponseStatus apiResponseStatus) 25 | { 26 | return apiResponseStatus.Equals(ApiResponseStatus.Failed); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/ApplicationSessionExtensions.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | 3 | namespace OneLine.Extensions 4 | { 5 | public static class ApplicationSessionExtensions 6 | { 7 | /// 8 | /// Checks if the application session is persistent 9 | /// 10 | /// 11 | /// 12 | public static bool IsPersistent(this ApplicationSession applicationSession) 13 | { 14 | return applicationSession.Equals(ApplicationSession.LocalStorage); 15 | } 16 | /// 17 | /// Checks if the application session is not persistent 18 | /// 19 | /// 20 | /// 21 | public static bool IsNotPersistent(this ApplicationSession applicationSession) 22 | { 23 | return applicationSession.Equals(ApplicationSession.SessionStorage); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/BoolExtensions.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Models; 2 | using OneLine.Enums; 3 | 4 | namespace OneLine.Extensions 5 | { 6 | public static class BoolExtensions 7 | { 8 | /// 9 | /// Converts to 10 | /// 11 | /// The source 12 | /// 13 | public static ApiResponse TransactionResultApiResponse(this bool source) 14 | { 15 | return source ? 16 | new ApiResponse(ApiResponseStatus.Succeeded) : 17 | new ApiResponse(ApiResponseStatus.Failed); 18 | } 19 | /// 20 | /// Converts to with a 21 | /// 22 | /// The source 23 | /// The message 24 | /// 25 | public static ApiResponse TransactionResultApiResponse(this bool source, string message) 26 | { 27 | return source ? 28 | new ApiResponse(ApiResponseStatus.Succeeded, message: message) : 29 | new ApiResponse(ApiResponseStatus.Failed, message: message); 30 | } 31 | /// 32 | /// Converts to with 33 | /// 34 | /// The source 35 | /// The data 36 | /// The data type 37 | /// 38 | public static ApiResponse TransactionResultApiResponse(this bool source, T data) 39 | { 40 | return source ? 41 | new ApiResponse(ApiResponseStatus.Succeeded, data) : 42 | new ApiResponse(ApiResponseStatus.Failed, data); 43 | } 44 | /// 45 | /// Converts to with and a 46 | /// 47 | /// The source 48 | /// The data 49 | /// The message 50 | /// The data type 51 | /// 52 | public static ApiResponse TransactionResultApiResponse(this bool source, T data, string message) 53 | { 54 | return source ? 55 | new ApiResponse(ApiResponseStatus.Succeeded, data, message) : 56 | new ApiResponse(ApiResponseStatus.Failed, data, message); 57 | } 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/DayOfWeekExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OneLine.Extensions 4 | { 5 | public static class DayOfWeekExtensions 6 | { 7 | /// 8 | /// Check whether the equals or 9 | /// 10 | /// 11 | /// 12 | public static bool IsWeekend(this DayOfWeek value) 13 | { 14 | return value.Equals(DayOfWeek.Sunday) || value.Equals(DayOfWeek.Saturday); 15 | } 16 | /// 17 | /// Check whether the equals 18 | /// 19 | /// 20 | /// 21 | public static bool IsFirstDayOfWeekend(this DayOfWeek value) 22 | { 23 | return value.Equals(DayOfWeek.Saturday); 24 | } 25 | /// 26 | /// Check whether the equals 27 | /// 28 | /// 29 | /// 30 | public static bool IsLastDayOfWeekend(this DayOfWeek value) 31 | { 32 | return value.Equals(DayOfWeek.Sunday); 33 | } 34 | /// 35 | /// Check whether the is not equal to and 36 | /// 37 | /// 38 | /// 39 | public static bool IsWeekday(this DayOfWeek value) 40 | { 41 | return !value.Equals(DayOfWeek.Sunday) && !value.Equals(DayOfWeek.Saturday); 42 | } 43 | /// 44 | /// Check whether the is equal to 45 | /// 46 | /// 47 | /// 48 | public static bool IsFirstDayOfWeek(this DayOfWeek value) 49 | { 50 | return value.Equals(DayOfWeek.Monday); 51 | } 52 | /// 53 | /// Check whether the is equal to 54 | /// 55 | /// 56 | /// 57 | public static bool IsLastDayOfWeek(this DayOfWeek value) 58 | { 59 | return value.Equals(DayOfWeek.Friday); 60 | } 61 | /// 62 | /// Check whether the is equal to 63 | /// 64 | /// 65 | /// 66 | public static bool IsSunday(this DayOfWeek value) 67 | { 68 | return value.Equals(DayOfWeek.Sunday); 69 | } 70 | /// 71 | /// Check whether the is equal to 72 | /// 73 | /// 74 | /// 75 | public static bool IsMonday(this DayOfWeek value) 76 | { 77 | return value.Equals(DayOfWeek.Monday); 78 | } 79 | /// 80 | /// Check whether the is equal to 81 | /// 82 | /// 83 | /// 84 | public static bool IsTuesday(this DayOfWeek value) 85 | { 86 | return value.Equals(DayOfWeek.Tuesday); 87 | } 88 | /// 89 | /// Check whether the is equal to 90 | /// 91 | /// 92 | /// 93 | public static bool IsWednesday(this DayOfWeek value) 94 | { 95 | return value.Equals(DayOfWeek.Wednesday); 96 | } 97 | /// 98 | /// Check whether the is equal to 99 | /// 100 | /// 101 | /// 102 | public static bool IsThursday(this DayOfWeek value) 103 | { 104 | return value.Equals(DayOfWeek.Thursday); 105 | } 106 | /// 107 | /// Check whether the is equal to 108 | /// 109 | /// 110 | /// 111 | public static bool IsFriday(this DayOfWeek value) 112 | { 113 | return value.Equals(DayOfWeek.Friday); 114 | } 115 | /// 116 | /// Check whether the is equal to 117 | /// 118 | /// 119 | /// 120 | public static bool IsSaturday(this DayOfWeek value) 121 | { 122 | return value.Equals(DayOfWeek.Saturday); 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/DecimalExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace OneLine.Extensions 3 | { 4 | public static class DecimalExtensions 5 | { 6 | /// 7 | /// Converts a decimal value to it's currency 8 | /// 9 | /// The decimal value 10 | /// 11 | public static string ToCurrency(this decimal? input) 12 | { 13 | if (!input.HasValue) 14 | { 15 | return string.Empty; 16 | } 17 | return string.Format("{0:C}", input.Value); 18 | } 19 | /// 20 | /// Converts a decimal value to it's currency 21 | /// 22 | /// The decimal value 23 | /// 24 | public static string ToCurrencyRounded(this decimal input, int numberOfDecimals = 2, MidpointRounding midpointRounding = MidpointRounding.AwayFromZero) 25 | { 26 | return string.Format("{0:C}", decimal.Round(input, numberOfDecimals, midpointRounding)); 27 | } 28 | /// 29 | /// Converts a decimal value to it's currency 30 | /// 31 | /// The decimal value 32 | /// 33 | public static string ToCurrencyRounded(this decimal? input, int numberOfDecimals = 2, MidpointRounding midpointRounding = MidpointRounding.AwayFromZero) 34 | { 35 | if (!input.HasValue) 36 | { 37 | return string.Empty; 38 | } 39 | return string.Format("{0:C}", decimal.Round(input.Value, numberOfDecimals, midpointRounding)); 40 | } 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/EnumExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace OneLine.Extensions 5 | { 6 | public static class EnumExtensions 7 | { 8 | /// 9 | /// Converts a to a 10 | /// 11 | /// 12 | /// 13 | public static IEnumerable ToEnumerable(this Enum input) 14 | { 15 | foreach (Enum value in Enum.GetValues(input.GetType())) 16 | { 17 | if (input.HasFlag(value) && Convert.ToInt64(value) != 0) 18 | { 19 | yield return value; 20 | } 21 | } 22 | } 23 | /// 24 | /// Checks if the Enum contains the value 25 | /// 26 | /// 27 | /// 28 | /// 29 | /// 30 | public static bool Contains(this Enum type, T value) 31 | { 32 | try 33 | { 34 | return ((int)(object)type & (int)(object)value) == (int)(object)value; 35 | } 36 | catch 37 | { 38 | return false; 39 | } 40 | } 41 | /// 42 | /// Checks if the equals the value 43 | /// 44 | /// 45 | /// 46 | /// 47 | /// 48 | public static bool Equals(this Enum type, T value) 49 | { 50 | try 51 | { 52 | return (int)(object)type == (int)(object)value; 53 | } 54 | catch 55 | { 56 | return false; 57 | } 58 | } 59 | /// 60 | /// Adds a of type of 61 | /// 62 | /// 63 | /// 64 | /// 65 | /// 66 | public static T Add(this Enum type, T value) 67 | { 68 | try 69 | { 70 | return (T)(object)((int)(object)type | (int)(object)value); 71 | } 72 | catch (Exception ex) 73 | { 74 | throw new ArgumentException(string.Format("Could not append value from enumerated type '{0}'.", typeof(T).Name), ex); 75 | } 76 | } 77 | /// 78 | /// Removes a of type of 79 | /// 80 | /// 81 | /// 82 | /// 83 | /// 84 | public static T Remove(this Enum type, T value) 85 | { 86 | try 87 | { 88 | return (T)(object)((int)(object)type & ~(int)(object)value); 89 | } 90 | catch (Exception ex) 91 | { 92 | throw new ArgumentException(string.Format("Could not remove value from enumerated type '{0}'.", typeof(T).Name), ex); 93 | } 94 | } 95 | } 96 | } 97 | 98 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/FormModeExtensions.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | 3 | namespace OneLine.Extensions 4 | { 5 | public static class FormModeExtensions 6 | { 7 | /// 8 | /// Checks whether the equals 9 | /// 10 | /// 11 | /// 12 | public static bool IsSingle(this FormMode formMode) 13 | { 14 | return formMode.Equals(FormMode.Single); 15 | } 16 | /// 17 | /// Checks whether the equals 18 | /// 19 | /// 20 | /// 21 | public static bool IsMultiple(this FormMode formMode) 22 | { 23 | return formMode.Equals(FormMode.Multiple); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/FormStateExtensions.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | 3 | namespace OneLine.Extensions 4 | { 5 | public static class FormStateExtensions 6 | { 7 | /// 8 | /// Check wheter equals 9 | /// 10 | /// 11 | /// 12 | public static bool IsCopy(this FormState formState) 13 | { 14 | return formState.Equals(FormState.Copy); 15 | } 16 | /// 17 | /// Check wheter equals 18 | /// 19 | /// 20 | /// 21 | public static bool IsCreate(this FormState formState) 22 | { 23 | return formState.Equals(FormState.Create); 24 | } 25 | /// 26 | /// Check wheter equals 27 | /// 28 | /// 29 | /// 30 | public static bool IsDelete(this FormState formState) 31 | { 32 | return formState.Equals(FormState.Delete); 33 | } 34 | /// 35 | /// Check wheter equals 36 | /// 37 | /// 38 | /// 39 | public static bool IsDeleted(this FormState formState) 40 | { 41 | return formState.Equals(FormState.Deleted); 42 | } 43 | /// 44 | /// Check wheter equals 45 | /// 46 | /// 47 | /// 48 | public static bool IsDetails(this FormState formState) 49 | { 50 | return formState.Equals(FormState.Details); 51 | } 52 | /// 53 | /// Check wheter equals 54 | /// 55 | /// 56 | /// 57 | public static bool IsEdit(this FormState formState) 58 | { 59 | return formState.Equals(FormState.Edit); 60 | } 61 | /// 62 | /// Check wheter equals 63 | /// 64 | /// 65 | /// 66 | public static bool IsReadOnly(this FormState formState) 67 | { 68 | return formState.Equals(FormState.ReadOnly); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/IApiResponseExtensions.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | using OneLine.Models; 3 | 4 | namespace OneLine.Extensions 5 | { 6 | public static class IApiResponseExtensions 7 | { 8 | /// 9 | /// Checks if the Api Response Status Succeeded 10 | /// 11 | /// 12 | /// 13 | /// 14 | public static bool Succeeded(this IApiResponse apiResponse) 15 | { 16 | return apiResponse.Status.Equals(ApiResponseStatus.Succeeded); 17 | } 18 | /// 19 | /// Checks if the Api Response Status Failed 20 | /// 21 | /// 22 | /// 23 | /// 24 | public static bool Failed(this IApiResponse apiResponse) 25 | { 26 | return apiResponse.Status.Equals(ApiResponseStatus.Failed); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/IDictionaryExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace OneLine.Extensions 4 | { 5 | public static class IDictionaryExtensions 6 | { 7 | /// 8 | /// Merges the current dictionary with the supplied dictionary into a new dictionary. 9 | /// 10 | /// 11 | /// 12 | /// 13 | /// 14 | /// 15 | public static IDictionary Merge(this IDictionary current, IDictionary keyValuePairs) 16 | { 17 | var dictionaryMerge = new Dictionary(current); 18 | foreach (var item in keyValuePairs) 19 | { 20 | dictionaryMerge[item.Key] = item.Value; 21 | } 22 | return dictionaryMerge; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/NavigationManagerExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.AspNetCore.WebUtilities; 3 | 4 | namespace OneLine.Extensions 5 | { 6 | public static class NavigationManagerExtensions 7 | { 8 | /// 9 | /// Tries to get a value from the and convert it to . 10 | /// 11 | /// 12 | /// 13 | /// 14 | /// 15 | /// 16 | public static void TryGetQueryStringValue(this NavigationManager navigationManager, string key, out T value) 17 | { 18 | var uri = navigationManager.ToAbsoluteUri(navigationManager.Uri); 19 | if (QueryHelpers.ParseQuery(uri.Query).TryGetValue(key, out var valueFromQueryString)) 20 | { 21 | try 22 | { 23 | value = valueFromQueryString.ToType(); 24 | } 25 | catch 26 | { 27 | value = default; 28 | } 29 | } 30 | else 31 | { 32 | value = default; 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/NullableExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Extensions 2 | { 3 | public static class NullableExtensions 4 | { 5 | /// 6 | /// Checks where the value is null or the default value. 7 | /// 8 | /// The nullable struct 9 | /// The value of the struct 10 | /// 11 | public static bool IsNullOrDefaultValue(this T? value) where T : struct 12 | { 13 | return !value.HasValue || value.Value.IsDefaultValue(); 14 | } 15 | /// 16 | /// Checks where the value is not null and not the default value. 17 | /// 18 | /// The nullable struct 19 | /// The value of the struct 20 | /// 21 | public static bool IsNotNullAndNotDefaultValue(this T? value) where T : struct 22 | { 23 | return value.HasValue && !value.Value.IsDefaultValue(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Src/OneLine/Extensions/PredicateBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | 6 | namespace OneLine.Extensions 7 | { 8 | /// 9 | /// Enables the efficient, portable and dynamic composition of query predicates. 10 | /// 11 | public static class PredicateBuilder 12 | { 13 | /// 14 | /// Creates a predicate that evaluates to true. 15 | /// 16 | public static Expression> True() => param => true; 17 | /// 18 | /// Creates a predicate that evaluates to false. 19 | /// 20 | public static Expression> False() => param => false; 21 | /// 22 | /// Creates a predicate expression from the specified lambda expression. 23 | /// 24 | public static Expression> Create(Expression> predicate) => predicate; 25 | /// 26 | /// Combines the first predicate with the second using the logical "and". 27 | /// 28 | public static Expression> And(this Expression> first, Expression> second) => first.Compose(second, Expression.AndAlso); 29 | /// 30 | /// Combines the first predicate with the second using the logical "or". 31 | /// 32 | public static Expression> Or(this Expression> first, Expression> second) => first.Compose(second, Expression.OrElse); 33 | /// 34 | /// Negates the predicate. 35 | /// 36 | public static Expression> Not(this Expression> expression) => Expression.Lambda>(Expression.Not(expression.Body), expression.Parameters); 37 | /// 38 | /// Combines the first expression with the second using the specified merge function. 39 | /// 40 | private static Expression Compose(this Expression first, Expression second, Func merge) 41 | { 42 | // zip parameters (map from parameters of second to parameters of first) 43 | var map = first.Parameters 44 | .Select((f, i) => new { f, s = second.Parameters[i] }) 45 | .ToDictionary(p => p.s, p => p.f); 46 | // replace parameters in the second lambda expression with the parameters in the first 47 | var secondBody = ParameterRebinder.ReplaceParameters(map, second.Body); 48 | // create a merged lambda expression with parameters from the first expression 49 | return Expression.Lambda(merge(first.Body, secondBody), first.Parameters); 50 | } 51 | /// 52 | /// Replaces the parameters in the second lambda expression with the parameters in the first expression 53 | /// 54 | private class ParameterRebinder : ExpressionVisitor 55 | { 56 | readonly Dictionary map; 57 | ParameterRebinder(Dictionary map) => this.map = map ?? new Dictionary(); 58 | public static Expression ReplaceParameters(Dictionary map, Expression exp) => new ParameterRebinder(map).Visit(exp); 59 | protected override Expression VisitParameter(ParameterExpression p) 60 | { 61 | if (map.TryGetValue(p, out ParameterExpression replacement)) 62 | { 63 | p = replacement; 64 | } 65 | return base.VisitParameter(p); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/RateLimitingExtensionForObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace OneLine.Extensions 5 | { 6 | public class RateLimitingExtensionForObject 7 | { 8 | #region Private Properties 9 | 10 | private static Timer _throttleTimerInterval; 11 | private static Timer _debounceTimerInterval; 12 | 13 | private static Action _debounceAction; 14 | private static object _lastObjectDebounce; 15 | 16 | private static Action _throttleAction; 17 | private static object _lastObjectThrottle; 18 | 19 | #endregion 20 | 21 | #region Debounce 22 | 23 | /// 24 | /// Debounce reset timer and after last item received give you last item. 25 | /// 26 | /// Your object 27 | /// Milisecond interval 28 | /// Called when last item call this method and after interval was finished 29 | public static void Debounce(object obj, int interval, Action debounceAction) 30 | { 31 | _lastObjectDebounce = obj; 32 | _debounceAction = debounceAction; 33 | 34 | _debounceTimerInterval?.Dispose(); 35 | 36 | _debounceTimerInterval = new Timer(DebounceTimerIntervalOnTick, obj, interval, interval); 37 | } 38 | 39 | /// 40 | /// DispatchTimer tick event for debounce 41 | /// 42 | /// 43 | private static void DebounceTimerIntervalOnTick(object state) 44 | { 45 | _debounceTimerInterval?.Dispose(); 46 | 47 | if (_debounceTimerInterval != null) 48 | { 49 | _debounceAction?.Invoke(_lastObjectDebounce); 50 | } 51 | 52 | _debounceTimerInterval = null; 53 | } 54 | 55 | #endregion 56 | 57 | #region Throttle 58 | 59 | /// 60 | /// Throttle give you last object when timer was ticked and invoke throttleAction callback. 61 | /// 62 | /// Your object 63 | /// Milisecond interval 64 | /// Invoked last object when timer ticked invoked 65 | public static void Throttle(object obj, int interval, Action throttleAction) 66 | { 67 | _lastObjectThrottle = obj; 68 | _throttleAction = throttleAction; 69 | 70 | if (_throttleTimerInterval == null) 71 | { 72 | _throttleTimerInterval = new Timer(ThrottleTimerIntervalOnTick, obj, interval, interval); 73 | } 74 | } 75 | 76 | /// 77 | /// DispatchTimer tick event for throttle 78 | /// 79 | /// 80 | private static void ThrottleTimerIntervalOnTick(object state) 81 | { 82 | _throttleTimerInterval?.Dispose(); 83 | _throttleTimerInterval = null; 84 | 85 | if (_lastObjectThrottle != null) 86 | { 87 | _throttleAction?.Invoke(_lastObjectThrottle); 88 | } 89 | } 90 | 91 | #endregion 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/RecordsSelectionModeExtensions.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | 3 | namespace OneLine.Extensions 4 | { 5 | public static class RecordsSelectionModeExtensions 6 | { 7 | /// 8 | /// Checks whether the equals 9 | /// 10 | /// 11 | /// 12 | public static bool IsSingle(this RecordsSelectionMode recordsSelectionMode) 13 | { 14 | return recordsSelectionMode.Equals(RecordsSelectionMode.Single); 15 | } 16 | /// 17 | /// Checks whether the equals 18 | /// 19 | /// 20 | /// 21 | public static bool IsMultiple(this RecordsSelectionMode recordsSelectionMode) 22 | { 23 | return recordsSelectionMode.Equals(RecordsSelectionMode.Multiple); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/SaveOperationExtensions.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | 3 | namespace OneLine.Extensions 4 | { 5 | public static class SaveOperationExtensions 6 | { 7 | /// 8 | /// Check whether the equals 9 | /// 10 | /// 11 | /// 12 | public static bool IsAdd(this SaveOperation saveOperation) 13 | { 14 | return saveOperation == SaveOperation.Add; 15 | } 16 | /// 17 | /// Check whether the equals 18 | /// 19 | /// 20 | /// 21 | public static bool IsUpdate(this SaveOperation saveOperation) 22 | { 23 | return saveOperation == SaveOperation.Update; 24 | } 25 | /// 26 | /// Check whether the equals 27 | /// 28 | /// 29 | /// 30 | public static bool IsAny(this SaveOperation saveOperation) 31 | { 32 | return saveOperation == SaveOperation.Any; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/StreamExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace OneLine.Extensions 6 | { 7 | public static class StreamExtensions 8 | { 9 | /// 10 | /// Reads and converts a into a . Take note that you may not use this method for huge files. 11 | /// 12 | /// 13 | /// 14 | public static byte[] ToByteArray(this Stream stream) 15 | { 16 | var streamLength = (int)stream.Length; 17 | var data = new byte[streamLength]; 18 | stream.Read(data, 0, streamLength); 19 | return data; 20 | } 21 | /// 22 | /// Asynchronously reads and converts a into a . Take note that you may not use this method for huge files. 23 | /// 24 | /// 25 | /// 26 | /// 27 | public static async Task ToByteArrayAsync(this Stream stream, CancellationToken cancellationToken = default) 28 | { 29 | var streamLength = (int)stream.Length; 30 | var data = new byte[streamLength]; 31 | await stream.ReadAsync(data, 0, streamLength, cancellationToken); 32 | return data; 33 | } 34 | /// 35 | /// Copies the contents of input to output. Doesn't close either stream. 36 | /// 37 | /// 38 | /// 39 | /// 40 | /// 41 | /// 42 | public static async Task CopyStreamAsync(this Stream input, Stream output, int bufferSize, CancellationToken cancellationToken = default) 43 | { 44 | if (bufferSize <= 0) 45 | throw new System.Exception("The bufferSize is zero or less"); 46 | byte[] buffer = new byte[bufferSize]; 47 | int len; 48 | while ((len = await input.ReadAsync(buffer, 0, buffer.Length)) > 0) 49 | { 50 | await output.WriteAsync(buffer, 0, len, cancellationToken); 51 | } 52 | } 53 | /// 54 | /// Copies the contents of the stream to the file system. 55 | /// Doesn't close the input stream but closes the output stream after write is completed. 56 | /// The recommended buffer size is 32 KB but can be bigger for end devices. 57 | /// 58 | /// 59 | /// 60 | /// 61 | /// 62 | /// 63 | public static async Task WriteStreamToFileSystemAsync(this Stream input, string path, int bufferSize, CancellationToken cancellationToken = default) 64 | { 65 | using Stream file = File.Create(path); 66 | await CopyStreamAsync(input, file, bufferSize, cancellationToken); 67 | } 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/TransactionTypeExtensions.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | using System; 3 | 4 | namespace OneLine.Extensions 5 | { 6 | public static class TransactionTypeExtensions 7 | { 8 | /// 9 | /// Returns a generic audit trail transaction message 10 | /// 11 | /// 12 | public static string TransactionTypeMessage(this TransactionType transactionType) 13 | { 14 | if (transactionType.Equals(TransactionType.Add)) 15 | { 16 | return "Added a " + typeof(T).Name; 17 | } 18 | else if (transactionType.Equals(TransactionType.Delete)) 19 | { 20 | return "Deleted a " + typeof(T).Name; 21 | } 22 | else if (transactionType.Equals(TransactionType.SoftDelete)) 23 | { 24 | return "Soft Deleted a " + typeof(T).Name; 25 | } 26 | else if (transactionType.Equals(TransactionType.SoftUndelete)) 27 | { 28 | return "Soft Undeleted a " + typeof(T).Name; 29 | } 30 | else if (transactionType.Equals(TransactionType.Update)) 31 | { 32 | return "Updated a " + typeof(T).Name; 33 | } 34 | else if (transactionType.Equals(TransactionType.Search)) 35 | { 36 | return "Searched a " + typeof(T).Name; 37 | } 38 | throw new ArgumentException("No transaction type found"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Src/OneLine/Extensions/TypeExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | 7 | namespace OneLine.Extensions 8 | { 9 | public static class TypeExtension 10 | { 11 | /// 12 | /// Checks if the type is anonymous type 13 | /// 14 | /// 15 | /// 16 | public static bool IsAnonymousType(this Type type) 17 | { 18 | if (type == null) 19 | throw new ArgumentNullException("type"); 20 | if (typeof(IEnumerable).IsAssignableFrom(type) || typeof(ICollection).IsAssignableFrom(type)) 21 | type = type.GetGenericArguments()[0]; 22 | return Attribute.IsDefined(type, typeof(CompilerGeneratedAttribute), false) 23 | && type.IsGenericType && type.Name.Contains("AnonymousType") 24 | && (type.Name.StartsWith("<>") || type.Name.StartsWith("VB$")) 25 | && (type.Attributes & TypeAttributes.NotPublic) == TypeAttributes.NotPublic; 26 | } 27 | /// 28 | /// Determines wether the type is numeric 29 | /// 30 | /// 31 | /// 32 | public static bool IsNumericType(this Type type) 33 | { 34 | switch (Type.GetTypeCode(type)) 35 | { 36 | case TypeCode.Byte: 37 | case TypeCode.SByte: 38 | case TypeCode.UInt16: 39 | case TypeCode.UInt32: 40 | case TypeCode.UInt64: 41 | case TypeCode.Int16: 42 | case TypeCode.Int32: 43 | case TypeCode.Int64: 44 | case TypeCode.Decimal: 45 | case TypeCode.Double: 46 | case TypeCode.Single: 47 | return true; 48 | default: 49 | return false; 50 | } 51 | } 52 | /// 53 | /// Checks whether the type is a simple type 54 | /// 55 | /// The type 56 | /// 57 | public static bool IsSimpleType(this Type type) 58 | { 59 | return 60 | type.IsValueType || 61 | type.IsPrimitive || 62 | new Type[] { 63 | typeof(byte), 64 | typeof(byte[]), 65 | typeof(sbyte), 66 | typeof(sbyte[]), 67 | typeof(short), 68 | typeof(float), 69 | typeof(string), 70 | typeof(decimal), 71 | typeof(DateTime), 72 | typeof(DateTimeOffset), 73 | typeof(TimeSpan), 74 | typeof(Guid) 75 | }.Contains(type) || 76 | Convert.GetTypeCode(type) != TypeCode.Object; 77 | } 78 | /// 79 | /// Checks whether the type is a complex type 80 | /// 81 | /// The type 82 | /// 83 | public static bool IsComplextType(this Type type) 84 | { 85 | return !type.IsSimpleType(); 86 | } 87 | /// 88 | /// Checks whether the exists in 89 | /// 90 | /// The type 91 | /// The property name 92 | /// The binding flags 93 | /// 94 | public static bool PropertyExists(this Type type, string propertyName, BindingFlags bindingFlags = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance) 95 | { 96 | return type.GetProperty(propertyName, bindingFlags).IsNotNull(); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Src/OneLine/Messaging/SendGrid/ISendGridApi.cs: -------------------------------------------------------------------------------- 1 | using SendGrid.Helpers.Mail; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | 5 | namespace OneLine.Messaging 6 | { 7 | /// 8 | /// Defines send grid api service 9 | /// 10 | public interface ISendGridApi 11 | { 12 | /// 13 | /// The send grid api settings 14 | /// 15 | ISendGridApiSettings SendGridApiSettings { get; set; } 16 | /// 17 | /// Send email asyncronously using the send grid api 18 | /// 19 | /// The sender email address 20 | /// The recipient's email address/es 21 | /// The email subject 22 | /// The email content as plain text 23 | /// The email content as html content 24 | /// The email attachments 25 | /// The email headers 26 | /// 27 | Task SendEmailAsync( 28 | EmailAddress from, 29 | IEnumerable toMailAddresses, 30 | string subject, 31 | string plainTextContent, 32 | string htmlContent, 33 | List attachments = null, 34 | Dictionary headers = null); 35 | /// 36 | /// Send email asyncronously using the send grid api 37 | /// 38 | /// The sender email address 39 | /// The recipient's email address/es 40 | /// The email subject 41 | /// The email content as plain text 42 | /// The email content as html content 43 | /// The email attachments 44 | /// The email headers 45 | /// 46 | Task SendEmailAsync( 47 | IEnumerable toMailAddresses, 48 | string subject, 49 | string plainTextContent, 50 | string htmlContent, 51 | List attachments = null, 52 | Dictionary headers = null); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Src/OneLine/Messaging/SendGrid/ISendGridApiSettings.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Messaging 2 | { 3 | /// 4 | /// The send grid api settings 5 | /// 6 | public interface ISendGridApiSettings 7 | { 8 | /// 9 | /// The send grid user 10 | /// 11 | string SendGridUser { get; set; } 12 | /// 13 | /// The send grid key 14 | /// 15 | string SendGridKey { get; set; } 16 | /// 17 | /// The send grid email address 18 | /// 19 | string Email { get; set; } 20 | /// 21 | /// The send grid display name 22 | /// 23 | string DisplayName { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/OneLine/Messaging/SendGrid/SendGridApiSettings.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Messaging 2 | { 3 | public class SendGridApiSettings : ISendGridApiSettings 4 | { 5 | /// 6 | public string SendGridUser { get; set; } 7 | /// 8 | public string SendGridKey { get; set; } 9 | /// 10 | public string Email { get; set; } 11 | /// 12 | public string DisplayName { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/OneLine/Messaging/Smtp/ISmtpSettings.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Messaging 2 | { 3 | /// 4 | /// Defines a smpt setting to be used in a Smpt client 5 | /// 6 | public interface ISmtpSettings 7 | { 8 | /// 9 | /// The email address 10 | /// 11 | string Email { get; set; } 12 | /// 13 | /// The display name 14 | /// 15 | string DisplayName { get; set; } 16 | /// 17 | /// Use default credentials indicator 18 | /// 19 | bool UseDefaultCredentials { get; set; } 20 | /// 21 | /// The smtp host address 22 | /// 23 | string Host { get; set; } 24 | /// 25 | /// The host port 26 | /// 27 | int Port { get; set; } 28 | /// 29 | /// Enable Ssl indicator 30 | /// 31 | bool EnableSsl { get; set; } 32 | /// 33 | /// The timeout for the smtp client 34 | /// 35 | int Timeout { get; set; } 36 | /// 37 | /// The username for the smtp 38 | /// 39 | string UserName { get; set; } 40 | /// 41 | /// The password for the smtp 42 | /// 43 | string Password { get; set; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Src/OneLine/Messaging/Smtp/SmtpSettings.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Messaging 2 | { 3 | public class SmtpSettings : ISmtpSettings 4 | { 5 | /// 6 | /// 7 | /// 8 | public string Email { get; set; } 9 | /// 10 | /// 11 | /// 12 | public string DisplayName { get; set; } 13 | /// 14 | /// 15 | /// 16 | public bool UseDefaultCredentials { get; set; } 17 | /// 18 | /// 19 | /// 20 | public string Host { get; set; } 21 | /// 22 | /// 23 | /// 24 | public int Port { get; set; } 25 | /// 26 | /// 27 | /// 28 | public bool EnableSsl { get; set; } 29 | /// 30 | /// 31 | /// 32 | public int Timeout { get; set; } 33 | /// 34 | /// 35 | /// 36 | public string UserName { get; set; } 37 | /// 38 | /// 39 | /// 40 | public string Password { get; set; } 41 | /// 42 | /// Default constructor 43 | /// 44 | public SmtpSettings() 45 | { 46 | 47 | } 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /Src/OneLine/Models/ApiResponse/IApiResponse.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | using System.Collections.Generic; 3 | 4 | namespace OneLine.Models 5 | { 6 | /// 7 | /// This interface defines a base api response structure to be used as an standard object in every api response result. 8 | /// 9 | /// 10 | public interface IApiResponse : IDataHolder 11 | { 12 | /// 13 | /// The api response status is the result of the transaction wether it succeeded or failed. 14 | /// 15 | ApiResponseStatus Status { get; set; } 16 | /// 17 | /// The message from response whether there is anything that needs to be notified about like an error message or success message. 18 | /// 19 | string Message { get; set; } 20 | /// 21 | /// The validation status is whether the validation result passed or failed 22 | /// 23 | bool ValidationFailed { get; set; } 24 | /// 25 | /// The errors messages from response when validation result failed 26 | /// 27 | IEnumerable ErrorMessages { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/OneLine/Models/AuditTrails/IAuditTrails.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OneLine.Models 4 | { 5 | /// 6 | /// Defines a structure to save audit trails 7 | /// 8 | public interface IAuditTrails 9 | { 10 | /// 11 | /// The audit trail identifier 12 | /// 13 | string AuditTrailId { get; set; } 14 | /// 15 | /// The action that was performed on the api. 16 | /// 17 | string Action { get; set; } 18 | /// 19 | /// The name of the action. This is the method that was called from the api. 20 | /// 21 | string ActionName { get; set; } 22 | /// 23 | /// The controller name. This is the class name of the controller that was calles from the api. 24 | /// 25 | string ControllerName { get; set; } 26 | /// 27 | /// The remote Ip Address of the client that made the request to the api. 28 | /// 29 | string RemoteIpAddress { get; set; } 30 | /// 31 | /// The database table name that the transaction was performed. 32 | /// 33 | string TableName { get; set; } 34 | /// 35 | /// The record state before any change was made except insert operation. 36 | /// 37 | string Record { get; set; } 38 | /// 39 | /// The host name that performed that processed the request. 40 | /// 41 | string Hostname { get; set; } 42 | /// 43 | /// The user that created the transaction. 44 | /// 45 | string CreatedBy { get; set; } 46 | /// 47 | /// The date time stamp that this trasaction was performed. 48 | /// 49 | DateTime CreatedOn { get; set; } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Src/OneLine/Models/BlobData/BlobData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace OneLine.Models 5 | { 6 | [NotMapped] 7 | /// 8 | /// Implements a structure to hold binary data 9 | /// 10 | public class BlobData : IBlobData 11 | { 12 | /// 13 | public DateTime LastModified { get; set; } 14 | /// 15 | public string Name { get; set; } 16 | /// 17 | public string InputName { get; set; } 18 | /// 19 | public long Size { get; set; } 20 | /// 21 | public string Type { get; set; } 22 | /// 23 | public byte[] Data { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/OneLine/Models/BlobData/IBlobData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OneLine.Models 4 | { 5 | /// 6 | /// Defines a structure to hold binary data 7 | /// 8 | public interface IBlobData : IDataHolder 9 | { 10 | /// 11 | /// Last modified 12 | /// 13 | DateTime LastModified { get; set; } 14 | /// 15 | /// The File Name 16 | /// 17 | string Name { get; set; } 18 | /// 19 | /// The File Input Name 20 | /// 21 | string InputName { get; set; } 22 | /// 23 | /// The file size 24 | /// 25 | long Size { get; set; } 26 | /// 27 | /// The file type 28 | /// 29 | string Type { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Src/OneLine/Models/BlobsStoragePath/BlobsStoragePath.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// This class implements a basic blob storage path definition 5 | /// 6 | public class BlobsStoragePath : IBlobsStoragePath 7 | { 8 | /// 9 | /// 10 | /// 11 | public string PublicUploadFilePath { get; set; } 12 | /// 13 | /// 14 | /// 15 | public string PrivateUploadFilePath { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/OneLine/Models/BlobsStoragePath/IBlobsStoragePath.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Defines a basic blob storage path 5 | /// 6 | public interface IBlobsStoragePath 7 | { 8 | /// 9 | /// Public web server path 10 | /// 11 | string PublicUploadFilePath { get; set; } 12 | /// 13 | /// Private web server path 14 | /// 15 | string PrivateUploadFilePath { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/OneLine/Models/DataHolder/DataHolder.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Implements 5 | /// 6 | /// 7 | public class DataHolder : IDataHolder 8 | { 9 | /// 10 | /// The data 11 | /// 12 | public T Data { get; set; } 13 | public DataHolder() 14 | { 15 | } 16 | public DataHolder(T data) 17 | { 18 | Data = data; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/OneLine/Models/DataHolder/IDataHolder.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Defines a generic data holder 5 | /// 6 | /// 7 | public interface IDataHolder 8 | { 9 | /// 10 | /// The data 11 | /// 12 | T Data { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/OneLine/Models/ExceptionLogs/IExceptionsLogs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OneLine.Models 4 | { 5 | /// 6 | /// Defines a stucture for saving exceptions 7 | /// 8 | public interface IExceptionLogs 9 | { 10 | /// 11 | /// The System Exception Log Identifier 12 | /// 13 | string ExceptionLogId { get; set; } 14 | /// 15 | /// The HResult from the exception 16 | /// 17 | int? HResult { get; set; } 18 | /// 19 | /// The HelpLink from the exception 20 | /// 21 | string HelpLink { get; set; } 22 | /// 23 | /// The InnerException from the exception 24 | /// 25 | string InnerException { get; set; } 26 | /// 27 | /// The Message from the exception 28 | /// 29 | string Message { get; set; } 30 | /// 31 | /// The Source from the exception 32 | /// 33 | string Source { get; set; } 34 | /// 35 | /// The Source from the exception 36 | /// 37 | string StackTrace { get; set; } 38 | /// 39 | /// The date time stamp that this trasaction was performed. 40 | /// 41 | DateTime CreatedOn { get; set; } 42 | /// 43 | /// The user that created the transaction. 44 | /// 45 | string CreatedBy { get; set; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Src/OneLine/Models/FormFileRules/IFormFileRules.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Defines a structure to set rules to a form file 5 | /// 6 | public interface IFormFileRules 7 | { 8 | /// 9 | /// Specify what file types the user can pick from the device file system. 10 | /// This property may be used for browser application only has the accept attribute value of a input of file type. 11 | /// 12 | string Accept { get; set; } 13 | /// 14 | /// Validates if the file is required. 15 | /// 16 | bool IsRequired { get; set; } 17 | /// 18 | /// The property name which rules are being validating. 19 | /// 20 | string PropertyName { get; set; } 21 | /// 22 | /// The maximum allowed files. 23 | /// 24 | short AllowedMaximumFiles { get; set; } 25 | /// 26 | /// The minimum allowed files. 27 | /// 28 | short AllowedMinimumFiles { get; set; } 29 | /// 30 | /// The allowed max length in bytes. 31 | /// 32 | long AllowedBlobMaxLength { get; set; } 33 | /// 34 | /// The allowed content types 35 | /// 36 | IEnumerable AllowedContentTypes { get; set; } 37 | /// 38 | /// The allowed extensions 39 | /// 40 | IEnumerable AllowedExtensions { get; set; } 41 | /// 42 | /// The allowed content dispositions 43 | /// 44 | IEnumerable AllowedContentDispositions { get; set; } 45 | /// 46 | /// Forces a file upload. Overrides IsRequired property rule. 47 | /// This property should be used for example: when a file state is expired, incorrect, wrong, etc and needs to be forced to be update. 48 | /// 49 | bool ForceUpload { get; set; } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Src/OneLine/Models/Identifier/IIdentifier.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Defines a generic model to be used as an identifier 5 | /// 6 | /// The type of the model identifier 7 | public interface IIdentifier 8 | { 9 | /// 10 | /// The model of typeof 11 | /// 12 | T Model { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/OneLine/Models/Identifier/Identifier.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Implements a generic model to be used as an identifier 5 | /// 6 | /// The type of the model identifier 7 | public class Identifier : IIdentifier 8 | { 9 | /// 10 | public T Model { get; set; } 11 | /// 12 | /// Default constructor 13 | /// 14 | public Identifier() 15 | { } 16 | /// 17 | /// Contructor with model value setup 18 | /// 19 | /// The value of the model 20 | public Identifier(T model) 21 | { 22 | Model = model; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/OneLine/Models/IdentifierString/IdentifierString.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Implements a string model to be used as an identifier 5 | /// 6 | public class IdentifierString : IIdentifier 7 | { 8 | /// 9 | /// The model is a string type 10 | /// 11 | public string Model { get; set; } 12 | /// 13 | /// Default constructor 14 | /// 15 | public IdentifierString() 16 | { } 17 | /// 18 | /// Constructor setting the string model value 19 | /// 20 | /// 21 | public IdentifierString(string model) 22 | { 23 | Model = model; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/OneLine/Models/Mutable/IMutable.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Defines a generic mutable structure 5 | /// 6 | /// 7 | public interface IMutable 8 | { 9 | T Item1 { get; set; } 10 | } 11 | /// 12 | /// Defines a generic mutable structure 13 | /// 14 | /// 15 | public interface IMutable 16 | { 17 | T1 Item1 { get; set; } 18 | T2 Item2 { get; set; } 19 | } 20 | /// 21 | /// Defines a generic mutable structure 22 | /// 23 | /// 24 | public interface IMutable 25 | { 26 | T1 Item1 { get; set; } 27 | T2 Item2 { get; set; } 28 | T3 Item3 { get; set; } 29 | } 30 | /// 31 | /// Defines a generic mutable structure 32 | /// 33 | /// 34 | public interface IMutable 35 | { 36 | T1 Item1 { get; set; } 37 | T2 Item2 { get; set; } 38 | T3 Item3 { get; set; } 39 | T4 Item4 { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Src/OneLine/Models/Mutable/Mutable.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Implements a generic mutable structure 5 | /// 6 | public class Mutable : IMutable 7 | { 8 | public Mutable() 9 | { 10 | } 11 | public Mutable(T item1) 12 | { 13 | Item1 = item1; 14 | } 15 | public T Item1 { get; set; } 16 | } 17 | /// 18 | /// Implements a generic mutable structure 19 | /// 20 | public class Mutable : IMutable 21 | { 22 | public Mutable() 23 | { 24 | } 25 | public Mutable(T1 item1, T2 item2) 26 | { 27 | Item1 = item1; 28 | Item2 = item2; 29 | } 30 | public T1 Item1 { get; set; } 31 | public T2 Item2 { get; set; } 32 | } 33 | /// 34 | /// Implements a generic mutable structure 35 | /// 36 | public class Mutable : IMutable 37 | { 38 | public Mutable() 39 | { 40 | } 41 | public Mutable(T1 item1, T2 item2, T3 item3) 42 | { 43 | Item1 = item1; 44 | Item2 = item2; 45 | Item3 = item3; 46 | } 47 | public T1 Item1 { get; set; } 48 | public T2 Item2 { get; set; } 49 | public T3 Item3 { get; set; } 50 | } 51 | /// 52 | /// Implements a generic mutable structure 53 | /// 54 | public class Mutable : IMutable 55 | { 56 | public Mutable() 57 | { 58 | } 59 | public Mutable(T1 item1, T2 item2, T3 item3, T4 item4) 60 | { 61 | Item1 = item1; 62 | Item2 = item2; 63 | Item3 = item3; 64 | Item4 = item4; 65 | } 66 | public T1 Item1 { get; set; } 67 | public T2 Item2 { get; set; } 68 | public T3 Item3 { get; set; } 69 | public T4 Item4 { get; set; } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Src/OneLine/Models/NotificationMessages/INotificationMessages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OneLine.Models 4 | { 5 | public interface INotificationMessages 6 | { 7 | /// 8 | /// Notification identifier 9 | /// 10 | string NotificationMessageId { get; set; } 11 | /// 12 | /// Notification user identifier 13 | /// 14 | string UserId { get; set; } 15 | /// 16 | /// The notification title 17 | /// 18 | string Title { get; set; } 19 | /// 20 | /// The notification message 21 | /// 22 | string Message { get; set; } 23 | /// 24 | /// The notification icon 25 | /// 26 | string IconUri { get; set; } 27 | /// 28 | /// The is deleted is to allow soft delete 29 | /// 30 | bool? IsDeleted { get; set; } 31 | /// 32 | /// The is readed is to know when the user readed the notification 33 | /// 34 | bool? IsReaded { get; set; } 35 | /// 36 | /// Created on 37 | /// 38 | DateTime CreatedOn { get; set; } 39 | /// 40 | /// Created by 41 | /// 42 | string CreatedBy { get; set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Src/OneLine/Models/Paged/IPaged.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Defines a paged data structure 5 | /// 6 | /// The type of the data 7 | public interface IPaged : IDataHolder 8 | { 9 | /// 10 | /// The page index 11 | /// 12 | int PageIndex { get; set; } 13 | /// 14 | /// The page size 15 | /// 16 | int PageSize { get; set; } 17 | /// 18 | /// The total count of records 19 | /// 20 | int TotalCount { get; set; } 21 | /// 22 | /// The total pages 23 | /// 24 | int TotalPages { get; set; } 25 | /// 26 | /// The last page is the same as the total of pages. This property is for reference purpose only. 27 | /// 28 | int LastPage { get; set; } 29 | /// 30 | /// Determines wether you can go back to the previous page of records 31 | /// 32 | bool HasPreviousPage { get; set; } 33 | /// 34 | /// Determines wether you can go foward to the next page of record 35 | /// 36 | bool HasNextPage { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Src/OneLine/Models/Paged/Paged.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OneLine.Models 4 | { 5 | /// 6 | /// Implements a paged data structure 7 | /// 8 | /// The type of the data 9 | public class Paged : IPaged 10 | { 11 | /// 12 | public int PageIndex { get; set; } 13 | /// 14 | public int PageSize { get; set; } 15 | /// 16 | public int TotalCount { get; set; } 17 | /// 18 | public int LastPage { get; set; } 19 | /// 20 | public int TotalPages { get; set; } 21 | /// 22 | public bool HasPreviousPage { get; set; } 23 | /// 24 | public bool HasNextPage { get; set; } 25 | /// 26 | public T Data { get; set; } 27 | /// 28 | /// The default constructor 29 | /// 30 | public Paged() 31 | { 32 | 33 | } 34 | /// 35 | /// The paged main constructors 36 | /// 37 | /// The page index 38 | /// The page size 39 | /// The records total count 40 | /// The paged data 41 | public Paged(int pageIndex, int pageSize, int totalCount, T data) 42 | { 43 | PageIndex = pageIndex; 44 | PageSize = pageSize; 45 | TotalCount = totalCount; 46 | TotalPages = TotalCount == 0 ? 0 : Convert.ToInt32(Math.Ceiling(TotalCount / Convert.ToDouble(PageSize))); 47 | LastPage = TotalPages; 48 | HasPreviousPage = PageIndex > 0; 49 | HasNextPage = TotalCount != 0 && PageIndex == 0 ? TotalCount > PageSize : TotalCount > (PageIndex + 1) * PageSize; 50 | Data = data; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Src/OneLine/Models/Paging/IPaging.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Defined a paging structure to be applied 5 | /// 6 | public interface IPaging 7 | { 8 | /// 9 | /// Determines wether data should be decending 10 | /// 11 | bool? Descending { get; set; } 12 | /// 13 | /// Sets the page index of the data 14 | /// 15 | int? PageIndex { get; set; } 16 | /// 17 | /// Sets the page size of the data 18 | /// 19 | int? PageSize { get; set; } 20 | /// 21 | /// Sets whichs property of the data model wants to be used for sorting 22 | /// 23 | string SortBy { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/OneLine/Models/Paging/Paging.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Implements a paging structure to be applied 5 | /// 6 | public class Paging : IPaging 7 | { 8 | /// 9 | public bool? Descending { get; set; } 10 | /// 11 | public int? PageIndex { get; set; } 12 | /// 13 | public int? PageSize { get; set; } 14 | /// 15 | public string SortBy { get; set; } 16 | /// 17 | /// Default constructor 18 | /// 19 | public Paging() 20 | { 21 | 22 | } 23 | /// 24 | /// The paging main constructor 25 | /// 26 | /// The page index 27 | /// The page size 28 | /// Descending indicator 29 | /// Sort by property name 30 | public Paging(int? pageIndex, int? pageSize, bool? descending, string sortBy) 31 | { 32 | PageIndex = pageIndex; 33 | PageSize = pageSize; 34 | Descending = descending; 35 | SortBy = sortBy; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Src/OneLine/Models/ResponseResult/IResponseResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | 4 | namespace OneLine.Models 5 | { 6 | /// 7 | /// This interface defines a holder and evaluator of a response result of a and the 8 | /// 9 | /// The type of the response data 10 | public interface IResponseResult 11 | { 12 | /// 13 | /// The response from the server 14 | /// 15 | T Response { get; set; } 16 | /// 17 | /// Determines where the server response succeed 18 | /// 19 | bool Succeed { get; set; } 20 | /// 21 | /// Determines when the request was successfully or not 22 | /// 23 | bool HasException { get; set; } 24 | /// 25 | /// The exception when an error ocurred on the request 26 | /// 27 | Exception Exception { get; set; } 28 | /// 29 | /// The HTTP response message including the status code and data. 30 | /// 31 | HttpResponseMessage HttpResponseMessage { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Src/OneLine/Models/ResponseResult/ResponseResult.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Extensions; 2 | using System; 3 | using System.Net.Http; 4 | 5 | namespace OneLine.Models 6 | { 7 | /// 8 | /// This class implements a holder and evaluator of a response result of a and the 9 | /// 10 | /// The type of the response data 11 | public class ResponseResult : IResponseResult 12 | { 13 | /// 14 | /// 15 | /// 16 | public T Response { get; set; } 17 | /// 18 | /// 19 | /// 20 | public bool Succeed { get; set; } 21 | /// 22 | /// 23 | /// 24 | public bool HasException { get; set; } 25 | /// 26 | /// 27 | /// 28 | public Exception Exception { get; set; } 29 | /// 30 | /// 31 | /// 32 | public HttpResponseMessage HttpResponseMessage { get; set; } 33 | /// 34 | /// Default constructor 35 | /// 36 | public ResponseResult() { } 37 | /// 38 | /// The response result main constructor 39 | /// 40 | /// The response 41 | /// The exception 42 | /// The httpResponseMessage 43 | public ResponseResult(T response = default, Exception exception = null, HttpResponseMessage httpResponseMessage = null) 44 | { 45 | Response = response; 46 | Exception = exception; 47 | HasException = Exception.IsNotNull(); 48 | Succeed = httpResponseMessage.IsNotNull() && httpResponseMessage.IsSuccessStatusCode && !HasException; 49 | HttpResponseMessage = httpResponseMessage; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Src/OneLine/Models/SaveForm/ISaveForm.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | 3 | namespace OneLine.Models 4 | { 5 | /// 6 | /// Defines model to save a form. 7 | /// 8 | /// 9 | public interface ISaveForm : IDataHolder 10 | { 11 | /// 12 | /// The save operation to perform to the form data. 13 | /// 14 | public SaveOperation SaveOperation { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/OneLine/Models/SaveForm/SaveForm.cs: -------------------------------------------------------------------------------- 1 | using OneLine.Enums; 2 | 3 | namespace OneLine.Models 4 | { 5 | /// 6 | /// Implements a model to save a form. 7 | /// 8 | /// 9 | public class SaveForm : ISaveForm 10 | { 11 | /// 12 | public T Data { get; set; } 13 | /// 14 | public SaveOperation SaveOperation { get; set; } 15 | /// 16 | /// Default constructor 17 | /// 18 | public SaveForm() 19 | { 20 | } 21 | /// 22 | /// Constructor with the form data 23 | /// 24 | /// 25 | public SaveForm(T data) 26 | { 27 | Data = data; 28 | } 29 | /// 30 | /// Constructor with the form data and the save operation 31 | /// 32 | /// 33 | /// 34 | public SaveForm(T data, SaveOperation saveOperation) 35 | { 36 | Data = data; 37 | SaveOperation = saveOperation; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Src/OneLine/Models/SaveFormWithValidator/ISaveFormWithValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using OneLine.Enums; 3 | 4 | namespace OneLine.Models 5 | { 6 | /// 7 | /// Defines model to save a form. 8 | /// 9 | /// 10 | public interface ISaveFormWithValidator : IDataHolder 11 | { 12 | /// 13 | /// The validator of the data. 14 | /// 15 | public IValidator Validator { get; set; } 16 | /// 17 | /// The save operation to perform to the form data. 18 | /// 19 | public SaveOperation SaveOperation { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/OneLine/Models/SaveFormWithValidator/SaveFormWithValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using OneLine.Enums; 3 | 4 | namespace OneLine.Models 5 | { 6 | /// 7 | /// Implements a model to save a form. 8 | /// 9 | /// 10 | public class SaveFormWithValidator : ISaveForm 11 | { 12 | /// 13 | public T Data { get; set; } 14 | /// 15 | public IValidator Validator { get; set; } 16 | /// 17 | public SaveOperation SaveOperation { get; set; } 18 | /// 19 | /// Default constructor 20 | /// 21 | public SaveFormWithValidator() 22 | { 23 | } 24 | /// 25 | /// Constructor with the form data 26 | /// 27 | /// 28 | public SaveFormWithValidator(T data) 29 | { 30 | Data = data; 31 | } 32 | /// 33 | /// Constructor with the form data and the validator 34 | /// 35 | /// 36 | /// 37 | public SaveFormWithValidator(T data, IValidator validator) 38 | { 39 | Data = data; 40 | Validator = validator; 41 | } 42 | /// 43 | /// Constructor with the form data and the save operation 44 | /// 45 | /// 46 | /// 47 | public SaveFormWithValidator(T data, SaveOperation saveOperation) 48 | { 49 | Data = data; 50 | SaveOperation = saveOperation; 51 | } 52 | /// 53 | /// Constructor with the form data, validator and save operation 54 | /// 55 | /// 56 | /// 57 | /// 58 | public SaveFormWithValidator(T data, IValidator validator, SaveOperation saveOperation) 59 | { 60 | Data = data; 61 | Validator = validator; 62 | SaveOperation = saveOperation; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Src/OneLine/Models/SaveReplaceList/ISaveReplaceList.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | public interface ISaveReplaceList : IDataHolder 4 | { 5 | /// 6 | /// The id to be used to save the record on the query filter 7 | /// 8 | TId Id { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/OneLine/Models/SaveReplaceList/SaveReplaceList.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | public class SaveReplaceList : ISaveReplaceList 4 | { 5 | /// 6 | /// The id to be used to save the record on the query filter 7 | /// 8 | public TId Id { get; set; } 9 | /// 10 | /// The data to be stored 11 | /// 12 | public T Data { get; set; } 13 | public SaveReplaceList() 14 | { 15 | } 16 | public SaveReplaceList(TId id, T data) 17 | { 18 | Id = id; 19 | Data = data; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/OneLine/Models/Search/ISearch.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Defines a structure with a search term 5 | /// 6 | public interface ISearch 7 | { 8 | /// 9 | /// Sets a search term to be used in the query 10 | /// 11 | string SearchTerm { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/OneLine/Models/Search/Search.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Implements a structure with a search term 5 | /// 6 | public class Search : ISearch 7 | { 8 | /// 9 | public string SearchTerm { get; set; } 10 | /// 11 | /// Default constructor 12 | /// 13 | public Search() 14 | { 15 | 16 | } 17 | /// 18 | /// Class constructor 19 | /// 20 | /// The search term 21 | public Search(string searchTerm) 22 | { 23 | SearchTerm = searchTerm; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/OneLine/Models/SearchPaging/ISearchPaging.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Defines a structure with search term and paging capabilities 5 | /// 6 | public interface ISearchPaging : ISearch, IPaging 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Src/OneLine/Models/SearchPaging/SearchPaging.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Implements a structure with search term and paging capabilities 5 | /// 6 | public class SearchPaging : ISearchPaging 7 | { 8 | /// 9 | public string SearchTerm { get; set; } 10 | /// 11 | public bool? Descending { get; set; } 12 | /// 13 | public int? PageIndex { get; set; } 14 | /// 15 | public int? PageSize { get; set; } 16 | /// 17 | public string SortBy { get; set; } 18 | /// 19 | /// Default constructor 20 | /// 21 | public SearchPaging() { } 22 | /// 23 | /// Constructor with paging capabilities 24 | /// 25 | /// The page index 26 | /// The page size 27 | /// Descending indicator 28 | /// Sort by property name 29 | public SearchPaging(int? pageIndex, int? pageSize, bool? descending, string sortBy) 30 | { 31 | PageIndex = pageIndex; 32 | PageSize = pageSize; 33 | Descending = descending; 34 | SortBy = sortBy; 35 | } 36 | /// 37 | /// Constructor with search term and paging capabilities 38 | /// 39 | /// The page index 40 | /// The page size 41 | /// Descending indicator 42 | /// Sort by property name 43 | /// The search term 44 | public SearchPaging(int? pageIndex, int? pageSize, bool? descending, string sortBy, string searchTerm) 45 | { 46 | PageIndex = pageIndex; 47 | PageSize = pageSize; 48 | Descending = descending; 49 | SortBy = sortBy; 50 | SearchTerm = searchTerm; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Src/OneLine/Models/SoftDeletable/ISoftDeletable.cs: -------------------------------------------------------------------------------- 1 | namespace OneLine.Models 2 | { 3 | /// 4 | /// Defines a soft deletable structure 5 | /// 6 | public interface ISoftDeletable 7 | { 8 | /// 9 | /// Is deleted indicator property 10 | /// 11 | bool? IsDeleted { get; set; } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Src/OneLine/Models/UploadBlobData/IUploadBlobData.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace OneLine.Models 4 | { 5 | /// 6 | /// Defines a structure to manage files on a integrated way on the client and server side 7 | /// 8 | public interface IUploadBlobData 9 | { 10 | /// 11 | /// The blob datas to upload 12 | /// 13 | IEnumerable BlobDatas { get; set; } 14 | /// 15 | /// The form file rules. 16 | /// 17 | IFormFileRules FormFileRules { get; set; } 18 | /// 19 | /// The property name should be the same as the file input name. 20 | /// This field must and should match the property name where blob reference will be stored. 21 | /// This reference property must be always a byte[] data type to work properly. 22 | /// 23 | string PropertyName { get; set; } 24 | /// 25 | /// Forces a file upload on update operation. Overrides IsRequired property rule. 26 | /// 27 | bool ForceUpload { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/OneLine/Models/UploadBlobData/UploadBlobData.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace OneLine.Models 4 | { 5 | /// 6 | /// Implements a structure to manage files on a integrated way on the client and server side 7 | /// 8 | public class UploadBlobData : IUploadBlobData 9 | { 10 | /// 11 | public virtual IEnumerable BlobDatas { get; set; } 12 | /// 13 | public virtual IFormFileRules FormFileRules { get; set; } 14 | /// 15 | public virtual string PropertyName { get; set; } 16 | /// 17 | public virtual bool ForceUpload { get; set; } 18 | /// 19 | /// The default constructor 20 | /// 21 | public UploadBlobData() 22 | { } 23 | /// 24 | /// 25 | /// 26 | /// 27 | /// 28 | public UploadBlobData(IEnumerable blobDatas, IFormFileRules formFileRules) 29 | { 30 | BlobDatas = blobDatas; 31 | FormFileRules = formFileRules; 32 | } 33 | /// 34 | /// 35 | /// 36 | /// 37 | /// 38 | /// 39 | public UploadBlobData(IEnumerable blobDatas, IFormFileRules formFileRules, string propertyName) 40 | { 41 | BlobDatas = blobDatas; 42 | FormFileRules = formFileRules; 43 | PropertyName = propertyName; 44 | } 45 | /// 46 | /// 47 | /// 48 | /// 49 | /// 50 | /// 51 | /// 52 | public UploadBlobData(IEnumerable blobDatas, IFormFileRules formFileRules, string propertyName, bool forceUpload) 53 | { 54 | BlobDatas = blobDatas; 55 | FormFileRules = formFileRules; 56 | PropertyName = propertyName; 57 | ForceUpload = forceUpload; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Src/OneLine/Models/UserBlobs/IUserBlobs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OneLine.Models 4 | { 5 | /// 6 | /// Defines a structure for user blobs 7 | /// 8 | public interface IUserBlobs 9 | { 10 | /// 11 | /// The user blob id 12 | /// 13 | string UserBlobId { get; set; } 14 | /// 15 | /// The user identifier 16 | /// 17 | string UserId { get; set; } 18 | /// 19 | /// The content disposition 20 | /// 21 | string ContentDisposition { get; set; } 22 | /// 23 | /// The content type 24 | /// 25 | string ContentType { get; set; } 26 | /// 27 | /// The original file name 28 | /// 29 | string FileName { get; set; } 30 | /// 31 | /// The name of the input file 32 | /// 33 | string Name { get; set; } 34 | /// 35 | /// The length of the file measured in bytes 36 | /// 37 | long Length { get; set; } 38 | /// 39 | /// The file path where the file is physically stored 40 | /// 41 | string FilePath { get; set; } 42 | /// 43 | /// The table name where this user blob is being referenced 44 | /// 45 | string TableName { get; set; } 46 | /// 47 | /// The is deleted user blob is to allow soft delete 48 | /// 49 | bool? IsDeleted { get; set; } 50 | /// 51 | /// Created on 52 | /// 53 | DateTime CreatedOn { get; set; } 54 | /// 55 | /// Created by 56 | /// 57 | string CreatedBy { get; set; } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Src/OneLine/OneLine.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst 4 | $(TargetFrameworks);net7.0-windows10.0.19041.0 5 | 6 | 7 | true 8 | true 9 | enable 10 | 11 | 14.2 12 | 14.0 13 | 21.0 14 | 10.0.17763.0 15 | 10.0.17763.0 16 | 6.5 17 | OneLine is an abstraction standardized redefined framework. 18 | 7.3 19 | 7.3 20 | 7.3 21 | 22 | OneLine is an abstraction standardized redefined framework. 23 | Anthony Greg Rivera Cosme 24 | https://github.com/arivera12/OneLine 25 | git 26 | Fixed typo on class property and translations keys and texts. 27 | LICENSE.txt 28 | README.md 29 | True 30 | Anthony Greg Rivera Cosme 31 | True 32 | 33 | 34 | 35 | true 36 | true 37 | true 38 | 39 | 40 | 41 | Windows 42 | 43 | 44 | OSX 45 | 46 | 47 | Linux 48 | 49 | 50 | 51 | 52 | True 53 | \ 54 | 55 | 56 | True 57 | \ 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Src/OneLine/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | --------------------------------------------------------------------------------