├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── Aspian.Application.Core ├── ActivityServices │ └── AdminServices │ │ ├── DTOs │ │ ├── ActivityDto.cs │ │ ├── MappingProfile.cs │ │ ├── SiteDto.cs │ │ └── UserDto.cs │ │ └── List.cs ├── Aspian.Application.Core.csproj ├── AttachmentServices │ ├── AdminServices │ │ ├── Add.cs │ │ ├── DTOs │ │ │ ├── AttachmentDto.cs │ │ │ ├── AttachmentUploadSettingsDto.cs │ │ │ ├── DownloadFileDto.cs │ │ │ ├── FileBrowserDto.cs │ │ │ ├── GetImageDto.cs │ │ │ ├── MappingProfile.cs │ │ │ ├── SiteDto.cs │ │ │ └── UserDto.cs │ │ ├── Delete.cs │ │ ├── Download.cs │ │ ├── FileBrowser.cs │ │ ├── FileBrowserFileDetails.cs │ │ ├── FileUploadResult.cs │ │ ├── GetImage.cs │ │ ├── GetUploadSettings.cs │ │ ├── List.cs │ │ └── TusDelete.cs │ └── UserServices │ │ └── SetMainPhoto.cs ├── CommentServices │ └── AdminServices │ │ ├── Approve.cs │ │ ├── Create.cs │ │ ├── DTOs │ │ ├── CommentDto.cs │ │ ├── CommentmetaDto.cs │ │ ├── MappingProfile.cs │ │ └── UserDto.cs │ │ ├── Delete.cs │ │ ├── Details.cs │ │ ├── Edit.cs │ │ ├── List.cs │ │ └── Unapprove.cs ├── Errors │ └── RestException.cs ├── Interfaces │ ├── IActivityLogger.cs │ ├── IBackgroundTaskQueue.cs │ ├── IJwtGenerator.cs │ ├── IOptionAccessor.cs │ ├── IScheduler.cs │ ├── ISlugGenerator.cs │ ├── ITusUploadUtils.cs │ ├── IUploadAccessor.cs │ └── IUserAccessor.cs ├── OptionServices │ └── AdminServices │ │ ├── DTOs │ │ ├── MappingProfile.cs │ │ ├── OptionDto.cs │ │ ├── OptionmetaDto.cs │ │ ├── SiteDto.cs │ │ └── UserDto.cs │ │ ├── Edit.cs │ │ ├── List.cs │ │ ├── OptionmetaResult.cs │ │ ├── RestoreDefaultOption.cs │ │ └── RestoreDefaultOptions.cs ├── PostServices │ └── AdminServices │ │ ├── Create.cs │ │ ├── DTOs │ │ ├── AntParentPostTreeSelectDto.cs │ │ ├── AttachmentDto.cs │ │ ├── AttachmentmetaDto.cs │ │ ├── MappingProfile.cs │ │ ├── PhotoDto.cs │ │ ├── PostAttachmentDto.cs │ │ ├── PostDto.cs │ │ ├── PostmetaDto.cs │ │ ├── SiteDto.cs │ │ ├── TaxonomyDto.cs │ │ ├── TaxonomyPostDto.cs │ │ ├── TermDto.cs │ │ ├── TermmetaDto.cs │ │ └── UserDto.cs │ │ ├── Delete.cs │ │ ├── Details.cs │ │ ├── Edit.cs │ │ ├── Helpers │ │ └── PostHelpers.cs │ │ ├── List.cs │ │ └── ParentPostTreeSelectAntd.cs ├── SiteServices │ └── AdminServices │ │ ├── DTOs │ │ ├── MappingProfile.cs │ │ ├── SiteDto.cs │ │ └── UserDto.cs │ │ ├── Details.cs │ │ ├── DeveloperEdit.cs │ │ ├── Edit.cs │ │ └── List.cs ├── TaxonomyServices │ └── AdminServices │ │ ├── CategoryTreeSelectAntd.cs │ │ ├── Create.cs │ │ ├── DTOs │ │ ├── AntdCategoryTreeSelectDto.cs │ │ ├── MappingProfile.cs │ │ ├── PostDto.cs │ │ ├── TaxonomyDto.cs │ │ ├── TaxonomyPostDto.cs │ │ ├── TermDto.cs │ │ └── UserDto.cs │ │ ├── Delete.cs │ │ ├── Details.cs │ │ ├── Edit.cs │ │ └── List.cs ├── UserServices │ └── AdminServices │ │ ├── ChangePassword.cs │ │ ├── CurrentUser.cs │ │ ├── DTOs │ │ ├── CurrentUserDto.cs │ │ ├── MappingProfile.cs │ │ ├── PhotoDto.cs │ │ ├── RefreshTokenDto.cs │ │ ├── UserDto.cs │ │ ├── UserListDto.cs │ │ └── UserProfileDto.cs │ │ ├── EditProfile.cs │ │ ├── List.cs │ │ ├── LockoutUser.cs │ │ ├── Login.cs │ │ ├── RefreshToken.cs │ │ ├── Register.cs │ │ ├── UnlockUser.cs │ │ └── UserProfile.cs └── Validators │ └── ValidatorExtensions.cs ├── Aspian.Domain ├── ActivityModel │ ├── Activity.cs │ ├── ActivityConfig.cs │ └── IActivity.cs ├── Aspian.Domain.csproj ├── AttachmentModel │ ├── Attachment.cs │ ├── AttachmentConfig.cs │ ├── Attachmentmeta.cs │ ├── AttachmentmetaConfig.cs │ ├── IAttachment.cs │ └── IAttachmentmeta.cs ├── BaseModel │ ├── EntityBase.cs │ ├── EntityCreate.cs │ ├── EntityInfo.cs │ ├── EntityModify.cs │ ├── Entitymeta.cs │ ├── IEntity.cs │ ├── IEntityBase.cs │ ├── IEntityCreate.cs │ ├── IEntityInfo.cs │ ├── IEntityMetadata.cs │ ├── IEntityModify.cs │ └── IEntitymeta.cs ├── CommentModel │ ├── Comment.cs │ ├── CommentConfig.cs │ ├── CommentHistory.cs │ ├── CommentHistoryConfig.cs │ ├── Commentmeta.cs │ ├── CommentmetaConfig.cs │ ├── IComment.cs │ ├── ICommentHistory.cs │ └── ICommentmeta.cs ├── OptionModel │ ├── IOption.cs │ ├── IOptionmeta.cs │ ├── Option.cs │ ├── OptionConfig.cs │ ├── Optionmeta.cs │ └── OptionmetaConfig.cs ├── PostModel │ ├── IPost.cs │ ├── IPostAttachment.cs │ ├── IPostmeta.cs │ ├── Post.cs │ ├── PostAttachment.cs │ ├── PostAttachmentConfig.cs │ ├── PostConfig.cs │ ├── Postmeta.cs │ └── PostmetaConfig.cs ├── ScheduleModel │ ├── ISchedule.cs │ ├── IScheduleOption.cs │ ├── Schedule.cs │ └── ScheduleConfig.cs ├── SiteModel │ ├── ISite.cs │ ├── Site.cs │ └── SiteConfig.cs ├── TaxonomyModel │ ├── ITaxonomy.cs │ ├── ITaxonomyPost.cs │ ├── ITerm.cs │ ├── ITermmeta.cs │ ├── Taxonomy.cs │ ├── TaxonomyConfig.cs │ ├── TaxonomyPost.cs │ ├── TaxonomyPostConfig.cs │ ├── Term.cs │ ├── TermConfig.cs │ ├── Termmeta.cs │ └── TermmetaConfig.cs └── UserModel │ ├── IUser.cs │ ├── IUserToken.cs │ ├── IUsermeta.cs │ ├── Policy │ ├── AspianClaimType.cs │ ├── AspianCoreClaimValue.cs │ └── AspianCorePolicy.cs │ ├── User.cs │ ├── UserConfig.cs │ ├── UserToken.cs │ ├── UserTokenConfig.cs │ ├── Usermeta.cs │ └── UsermetaConfig.cs ├── Aspian.Persistence ├── Aspian.Persistence.csproj ├── DataContext.cs ├── Migrations │ ├── 20200909114048_InitialCreate.Designer.cs │ ├── 20200909114048_InitialCreate.cs │ ├── 20200909130513_ScheduleModelsChanged.Designer.cs │ ├── 20200909130513_ScheduleModelsChanged.cs │ ├── 20200909142757_PostModelChanged.Designer.cs │ ├── 20200909142757_PostModelChanged.cs │ ├── 20200909143553_PostModelChanged1.Designer.cs │ ├── 20200909143553_PostModelChanged1.cs │ ├── 20200909143944_PostModelChanged2.Designer.cs │ ├── 20200909143944_PostModelChanged2.cs │ ├── 20200909144306_PostModelChanged3.Designer.cs │ ├── 20200909144306_PostModelChanged3.cs │ ├── 20200909163207_ScheduleOptionAdded.Designer.cs │ ├── 20200909163207_ScheduleOptionAdded.cs │ ├── 20200909193521_ScheduleOptionRemoved.Designer.cs │ ├── 20200909193521_ScheduleOptionRemoved.cs │ ├── 20201007110119_attachmendSizeFieldTypeChangedToLong.Designer.cs │ ├── 20201007110119_attachmendSizeFieldTypeChangedToLong.cs │ ├── 20201007150200_TusIdFieldAddedToAttachment.Designer.cs │ ├── 20201007150200_TusIdFieldAddedToAttachment.cs │ ├── 20201007151245_TusIdFieldIndexed.Designer.cs │ ├── 20201007151245_TusIdFieldIndexed.cs │ ├── 20201031151804_PublicFileNameAddedToAttachmentModel.Designer.cs │ ├── 20201031151804_PublicFileNameAddedToAttachmentModel.cs │ ├── 20201108085621_TusFileIdRemovedFromAttachment.Designer.cs │ ├── 20201108085621_TusFileIdRemovedFromAttachment.cs │ ├── 20201111180322_LinkAccessibilityAddedToAtachment.Designer.cs │ ├── 20201111180322_LinkAccessibilityAddedToAtachment.cs │ ├── 20201111182234_AttachmentConfigChanged.Designer.cs │ ├── 20201111182234_AttachmentConfigChanged.cs │ ├── 20201122143216_addThumnailPathToAttachment.Designer.cs │ ├── 20201122143216_addThumnailPathToAttachment.cs │ ├── 20201231145702_PostVisibilityFieldAdded.Designer.cs │ ├── 20201231145702_PostVisibilityFieldAdded.cs │ ├── 20210101095956_ChildPostAndOrderFieldsRemoved.Designer.cs │ ├── 20210101095956_ChildPostAndOrderFieldsRemoved.cs │ ├── 20210102094814_PostAttachmentModificationInfoFieldsRemoved.Designer.cs │ ├── 20210102094814_PostAttachmentModificationInfoFieldsRemoved.cs │ └── DataContextModelSnapshot.cs └── Seed.cs ├── Aspian.Web ├── Areas │ └── Admin │ │ └── API │ │ └── v1 │ │ └── Controllers │ │ ├── ActivitiesController.cs │ │ ├── AttachmentsController.cs │ │ ├── BaseAPIController.cs │ │ ├── CommentsController.cs │ │ ├── OptionsController.cs │ │ ├── PostsController.cs │ │ ├── SitesController.cs │ │ ├── TaxonomiesController.cs │ │ └── UserController.cs ├── Aspian.Web.csproj ├── Controllers │ └── HomeController.cs ├── Middleware │ └── API │ │ └── APIErrorHandlingMiddleware.cs ├── Models │ └── ErrorViewModel.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── Views │ ├── Home │ │ ├── Index.cshtml │ │ └── Privacy.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── Aspian.sln └── Infrastructure ├── Infrastructure.csproj ├── Logger └── ActivityLogger.cs ├── Option └── OptionAccessor.cs ├── Schedule ├── BackgroundTaskQueue.cs ├── QueuedHostedService.cs └── ScheduleTask.cs ├── Security ├── JwtGenerator.cs └── UserAccessor.cs ├── Upload ├── FtpServerSettings.cs ├── Tus │ ├── Extensions │ │ └── Internal │ │ │ ├── DateTimeOffsetExtensions.cs │ │ │ └── FileStreamExtensions.cs │ ├── Helpers │ │ └── TaskHelper.cs │ └── Stores │ │ ├── CustomTusDiskStore.cs │ │ ├── InternalFileId.cs │ │ ├── InternalFileRep.cs │ │ └── TusDiskFile.cs ├── TusUploadUtils.cs └── UploadAccessor.cs └── Utility └── SlugGenerator.cs /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/Aspian.Web/bin/Debug/netcoreapp3.1/Aspian.Web.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/Aspian.Web", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Aspian.Web/Aspian.Web.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/Aspian.Web/Aspian.Web.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/Aspian.Web/Aspian.Web.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/ActivityServices/AdminServices/DTOs/ActivityDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.ActivityModel; 3 | 4 | namespace Aspian.Application.Core.ActivityServices.AdminServices.DTOs 5 | { 6 | public class ActivityDto 7 | { 8 | public Guid Id { get; set; } 9 | public string Code { get; set; } 10 | public string Severity { get; set; } 11 | public string ObjectName { get; set; } 12 | public string Message { get; set; } 13 | public DateTime CreatedAt { get; set; } 14 | public string CreatedById { get; set; } 15 | public virtual UserDto CreatedBy { get; set; } 16 | public string UserAgent { get; set; } 17 | public string UserIPAddress { get; set; } 18 | public virtual SiteDto Site { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/ActivityServices/AdminServices/DTOs/MappingProfile.cs: -------------------------------------------------------------------------------- 1 | using Aspian.Domain.ActivityModel; 2 | using Aspian.Domain.SiteModel; 3 | using Aspian.Domain.UserModel; 4 | using AutoMapper; 5 | 6 | namespace Aspian.Application.Core.ActivityServices.AdminServices.DTOs 7 | { 8 | public class MappingProfile : Profile 9 | { 10 | public MappingProfile() 11 | { 12 | CreateMap(); 13 | CreateMap(); 14 | CreateMap(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/ActivityServices/AdminServices/DTOs/SiteDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.SiteModel; 3 | 4 | namespace Aspian.Application.Core.ActivityServices.AdminServices.DTOs 5 | { 6 | public class SiteDto 7 | { 8 | public Guid Id { get; set; } 9 | public string Domain { get; set; } 10 | public string Path { get; set; } 11 | public DateTime Registered { get; set; } 12 | public DateTime? LastUpdated { get; set; } 13 | public string SiteType { get; set; } 14 | public bool Activated { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/ActivityServices/AdminServices/DTOs/UserDto.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Application.Core.ActivityServices.AdminServices.DTOs 2 | { 3 | public class UserDto 4 | { 5 | public string Id { get; set; } 6 | public string DisplayName { get; set; } 7 | public string Email { get; set; } 8 | public string Bio { get; set; } 9 | public string Role { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/ActivityServices/AdminServices/List.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Aspian.Application.Core.ActivityServices.AdminServices.DTOs; 5 | using Aspian.Persistence; 6 | using AutoMapper; 7 | using MediatR; 8 | using Microsoft.EntityFrameworkCore; 9 | 10 | namespace Aspian.Application.Core.ActivityServices.AdminServices 11 | { 12 | public class List 13 | { 14 | public class Query : IRequest> { } 15 | 16 | public class Handler : IRequestHandler> 17 | { 18 | private readonly DataContext _context; 19 | private readonly IMapper _mapper; 20 | public Handler(DataContext context, IMapper mapper) 21 | { 22 | _mapper = mapper; 23 | _context = context; 24 | } 25 | 26 | public async Task> Handle(Query request, CancellationToken cancellationToken) 27 | { 28 | var activities = await _context.Activities.ToListAsync(); 29 | 30 | return _mapper.Map>(activities); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/Aspian.Application.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | net5.0 14 | 15 | -------------------------------------------------------------------------------- /Aspian.Application.Core/AttachmentServices/AdminServices/DTOs/AttachmentDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.AttachmentServices.AdminServices.DTOs 4 | { 5 | public class AttachmentDto 6 | { 7 | public Guid Id { get; set; } 8 | public string Type { get; set; } 9 | public string RelativePath { get; set; } 10 | public string MimeType { get; set; } 11 | public string FileName { get; set; } 12 | public string PublicFileName { get; set; } 13 | public string FileExtension { get; set; } 14 | public long FileSize { get; set; } 15 | public bool IsMain { get; set; } 16 | public DateTime CreatedAt { get; set; } 17 | public DateTime? ModifiedAt { get; set; } 18 | public virtual UserDto CreatedBy { get; set; } 19 | public virtual UserDto ModifiedBy { get; set; } 20 | public string UserAgent { get; set; } 21 | public string UserIPAddress { get; set; } 22 | public SiteDto Site { get; set; } 23 | } 24 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/AttachmentServices/AdminServices/DTOs/AttachmentUploadSettingsDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Aspian.Application.Core.AttachmentServices.AdminServices.DTOs 4 | { 5 | public class AttachmentUploadSettingsDto 6 | { 7 | public bool IsMultipleUploadAllowed { get; set; } 8 | public bool IsAutoProceedUploadAllowed { get; set; } 9 | public int UploadMaxAllowedNumberOfFiles { get; set; } 10 | public int UploadMinAllowedNumberOfFiles { get; set; } 11 | public long UploadMaxAllowedFileSize { get; set; } 12 | public List UploadAllowedFileTypes { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/AttachmentServices/AdminServices/DTOs/DownloadFileDto.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace Aspian.Application.Core.AttachmentServices.AdminServices.DTOs 4 | { 5 | public class DownloadFileDto 6 | { 7 | public string FileName { get; set; } 8 | public Stream Stream { get; set; } 9 | public string MimeType { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/AttachmentServices/AdminServices/DTOs/FileBrowserDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.AttachmentModel; 3 | 4 | namespace Aspian.Application.Core.AttachmentServices.AdminServices.DTOs 5 | { 6 | public class FileBrowserDto 7 | { 8 | public Guid Id { get; set; } 9 | public AttachmentTypeEnum Type { get; set; } 10 | public string MimeType { get; set; } 11 | public UploadLocationEnum UploadLocation { get; set; } 12 | public string RelativePath { get; set; } 13 | public string FileName { get; set; } 14 | public string PublicFileName { get; set; } 15 | public string FileExtension { get; set; } 16 | public long FileSize { get; set; } 17 | public DateTime CreatedAt { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/AttachmentServices/AdminServices/DTOs/GetImageDto.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace Aspian.Application.Core.AttachmentServices.AdminServices.DTOs 4 | { 5 | public class GetImageDto 6 | { 7 | public string FileName { get; set; } 8 | public MemoryStream Memory { get; set; } 9 | public string MimeType { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/AttachmentServices/AdminServices/DTOs/MappingProfile.cs: -------------------------------------------------------------------------------- 1 | using Aspian.Application.Core.AttachmentServices.AdminServices; 2 | using Aspian.Domain.AttachmentModel; 3 | using Aspian.Domain.SiteModel; 4 | using Aspian.Domain.UserModel; 5 | using AutoMapper; 6 | 7 | namespace Aspian.Application.Core.AttachmentServices.AdminServices.DTOs 8 | { 9 | public class MappingProfile : Profile 10 | { 11 | public MappingProfile() 12 | { 13 | CreateMap() 14 | .ForMember(d => d.CreatedAt, o => o.UseDestinationValue()) 15 | .ForMember(d => d.CreatedById, o => o.UseDestinationValue()); 16 | CreateMap(); 17 | CreateMap(); 18 | CreateMap(); 19 | CreateMap(); 20 | CreateMap(); 21 | CreateMap(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/AttachmentServices/AdminServices/DTOs/SiteDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.AttachmentServices.AdminServices.DTOs 4 | { 5 | public class SiteDto 6 | { 7 | public Guid Id { get; set; } 8 | public string Domain { get; set; } 9 | public string Path { get; set; } 10 | public DateTime Registered { get; set; } 11 | public DateTime? LastUpdated { get; set; } 12 | public string SiteType { get; set; } 13 | public bool Activated { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/AttachmentServices/AdminServices/DTOs/UserDto.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Application.Core.AttachmentServices.AdminServices.DTOs 2 | { 3 | public class UserDto 4 | { 5 | public string Id { get; set; } 6 | public string DisplayName { get; set; } 7 | public string Email { get; set; } 8 | public string Bio { get; set; } 9 | public string Role { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/AttachmentServices/AdminServices/FileBrowser.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.AttachmentServices.AdminServices.DTOs; 6 | using Aspian.Domain.AttachmentModel; 7 | using Aspian.Persistence; 8 | using AutoMapper; 9 | using MediatR; 10 | using Microsoft.EntityFrameworkCore; 11 | 12 | namespace Aspian.Application.Core.AttachmentServices.AdminServices 13 | { 14 | public class FileBrowser 15 | { 16 | public class Query : IRequest> 17 | { 18 | public AttachmentTypeEnum? Type { get; set; } 19 | } 20 | 21 | public class Handler : IRequestHandler> 22 | { 23 | private readonly DataContext _context; 24 | private readonly IMapper _mapper; 25 | public Handler(DataContext context, IMapper mapper) 26 | { 27 | _mapper = mapper; 28 | _context = context; 29 | } 30 | 31 | public async Task> Handle(Query request, CancellationToken cancellationToken) 32 | { 33 | List attachments; 34 | if (request.Type == null) 35 | { 36 | attachments = await _context.Attachments.ToListAsync(); 37 | } 38 | else 39 | { 40 | if (request.Type == AttachmentTypeEnum.Video || request.Type == AttachmentTypeEnum.Photo) 41 | { 42 | attachments = await _context.Attachments.Where(a => a.Type == request.Type).ToListAsync(); 43 | } 44 | else 45 | { 46 | attachments = await _context.Attachments 47 | .Where(a => a.Type != AttachmentTypeEnum.Video && a.Type != AttachmentTypeEnum.Photo) 48 | .ToListAsync(); 49 | } 50 | } 51 | 52 | return _mapper.Map>(attachments); 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/AttachmentServices/AdminServices/FileBrowserFileDetails.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Aspian.Application.Core.AttachmentServices.AdminServices.DTOs; 5 | using Aspian.Application.Core.Errors; 6 | using Aspian.Persistence; 7 | using AutoMapper; 8 | using FluentValidation; 9 | using MediatR; 10 | using Microsoft.EntityFrameworkCore; 11 | 12 | namespace Aspian.Application.Core.AttachmentServices.AdminServices 13 | { 14 | public class FileBrowserFileDetails 15 | { 16 | public class Query : IRequest 17 | { 18 | public string FileName { get; set; } 19 | } 20 | 21 | public class QueryValidator : AbstractValidator 22 | { 23 | public QueryValidator() 24 | { 25 | RuleFor(x => x.FileName).NotEmpty().MaximumLength(60); 26 | } 27 | } 28 | 29 | public class Handler : IRequestHandler 30 | { 31 | private readonly DataContext _context; 32 | private readonly IMapper _mapper; 33 | public Handler(DataContext context, IMapper mapper) 34 | { 35 | _mapper = mapper; 36 | _context = context; 37 | } 38 | 39 | public async Task Handle(Query request, CancellationToken cancellationToken) 40 | { 41 | var attachment = await _context.Attachments.SingleOrDefaultAsync(x => x.FileName == request.FileName); 42 | if (attachment == null) 43 | { 44 | throw new RestException(HttpStatusCode.NotFound, new { file = "not found!" }); 45 | } 46 | return _mapper.Map(attachment); 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/AttachmentServices/AdminServices/FileUploadResult.cs: -------------------------------------------------------------------------------- 1 | using Aspian.Domain.AttachmentModel; 2 | 3 | namespace Aspian.Application.Core.AttachmentServices.AdminServices 4 | { 5 | public class FileUploadResult 6 | { 7 | public AttachmentTypeEnum Type { get; set; } 8 | public UploadLocationEnum UploadLocation { get; set; } 9 | public string RelativePath { get; set; } 10 | public string MimeType { get; set; } 11 | public string FileName { get; set; } 12 | public string FileExtension { get; set; } 13 | public long FileSize { get; set; } 14 | public bool IsMain { get; set; } 15 | public string Result { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/CommentServices/AdminServices/Approve.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.Errors; 6 | using Aspian.Application.Core.Interfaces; 7 | using Aspian.Domain.ActivityModel; 8 | using Aspian.Domain.SiteModel; 9 | using Aspian.Persistence; 10 | using MediatR; 11 | using Microsoft.EntityFrameworkCore; 12 | 13 | namespace Aspian.Application.Core.CommentServices.AdminServices 14 | { 15 | public class Approve 16 | { 17 | public class Command : IRequest 18 | { 19 | public Guid Id { get; set; } 20 | } 21 | 22 | public class Handler : IRequestHandler 23 | { 24 | private readonly DataContext _context; 25 | private readonly IActivityLogger _logger; 26 | public Handler(DataContext context, IActivityLogger logger) 27 | { 28 | _logger = logger; 29 | _context = context; 30 | } 31 | 32 | public async Task Handle(Command request, CancellationToken cancellationToken) 33 | { 34 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 35 | var comment = await _context.Comments.FindAsync(request.Id); 36 | if (comment == null) 37 | throw new RestException(HttpStatusCode.NotFound, new { comment = "Not found!" }); 38 | 39 | if (comment.Approved) 40 | throw new RestException(HttpStatusCode.BadRequest, new {comment = "is already approved!"}); 41 | 42 | comment.Approved = true; 43 | 44 | var success = await _context.SaveChangesAsync() > 0; 45 | 46 | if (success) 47 | { 48 | await _logger.LogActivity( 49 | site.Id, 50 | ActivityCodeEnum.CommentApprove, 51 | ActivitySeverityEnum.Information, 52 | ActivityObjectEnum.Comment, 53 | $"The comment \"{comment.Content.Substring(0, 30)}\" sent by the user \"{comment.CreatedBy.UserName}\" approved"); 54 | 55 | return Unit.Value; 56 | } 57 | 58 | throw new Exception("Problem saving changes!"); 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/CommentServices/AdminServices/DTOs/CommentDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.CommentModel; 4 | 5 | namespace Aspian.Application.Core.CommentServices.AdminServices.DTOs 6 | { 7 | public class CommentDto 8 | { 9 | public Guid Id { get; set; } 10 | public string Content { get; set; } 11 | public bool Approved { get; set; } 12 | 13 | public DateTime CreatedAt { get; set; } 14 | public DateTime? ModifiedAt { get; set; } 15 | public string CreatedById { get; set; } 16 | public virtual UserDto CreatedBy { get; set; } 17 | public string ModifiedById { get; set; } 18 | public virtual UserDto ModifiedBy { get; set; } 19 | public Guid? ParentId { get; set; } 20 | public virtual ICollection Replies { get; set; } 21 | public Guid SiteId { get; set; } 22 | public Guid PostId { get; set; } 23 | public virtual ICollection Commentmetas { get; set; } 24 | //public virtual ICollection CommentHistories { get; set; } 25 | } 26 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/CommentServices/AdminServices/DTOs/CommentmetaDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.CommentServices.AdminServices.DTOs 4 | { 5 | public class CommentmetaDto 6 | { 7 | public Guid Id { get; set; } 8 | public DateTime CreatedAt { get; set; } 9 | public DateTime? ModifiedAt { get; set; } 10 | public string CreatedById { get; set; } 11 | public virtual UserDto CreatedBy { get; set; } 12 | public string ModifiedById { get; set; } 13 | public virtual UserDto ModifiedBy { get; set; } 14 | public string Key { get; set; } 15 | public string Value { get; set; } 16 | 17 | #region Navigation Properties 18 | public Guid CommentId { get; set; } 19 | #endregion 20 | } 21 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/CommentServices/AdminServices/DTOs/MappingProfile.cs: -------------------------------------------------------------------------------- 1 | using Aspian.Application.Core.CommentServices.AdminServices; 2 | using Aspian.Domain.CommentModel; 3 | using Aspian.Domain.UserModel; 4 | using AutoMapper; 5 | 6 | namespace Aspian.Application.Core.CommentServices.AdminServices.DTOs 7 | { 8 | public class MappingProfile : Profile 9 | { 10 | public MappingProfile() 11 | { 12 | CreateMap(); 13 | CreateMap(); 14 | CreateMap(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/CommentServices/AdminServices/DTOs/UserDto.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Application.Core.CommentServices.AdminServices.DTOs 2 | { 3 | public class UserDto 4 | { 5 | public string Id { get; set; } 6 | public string DisplayName { get; set; } 7 | public string Email { get; set; } 8 | public string Bio { get; set; } 9 | public string Role { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/CommentServices/AdminServices/Delete.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.Errors; 6 | using Aspian.Application.Core.Interfaces; 7 | using Aspian.Domain.ActivityModel; 8 | using Aspian.Domain.SiteModel; 9 | using Aspian.Persistence; 10 | using MediatR; 11 | using Microsoft.EntityFrameworkCore; 12 | 13 | namespace Aspian.Application.Core.CommentServices.AdminServices 14 | { 15 | public class Delete 16 | { 17 | public class Command : IRequest 18 | { 19 | public Guid Id { get; set; } 20 | } 21 | 22 | public class Handler : IRequestHandler 23 | { 24 | private readonly DataContext _context; 25 | private readonly IActivityLogger _logger; 26 | public Handler(DataContext context, IActivityLogger logger) 27 | { 28 | _logger = logger; 29 | _context = context; 30 | } 31 | 32 | public async Task Handle(Command request, CancellationToken cancellationToken) 33 | { 34 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 35 | var comment = await _context.Comments.FindAsync(request.Id); 36 | if (comment == null) 37 | throw new RestException(HttpStatusCode.NotFound, new { comment = "Not found!" }); 38 | 39 | var commentTruncatedContent = comment.Content.Substring(0, 30); 40 | var commentWriterUsername = comment.CreatedBy.UserName; 41 | 42 | _context.Comments.Remove(comment); 43 | 44 | var success = await _context.SaveChangesAsync() > 0; 45 | 46 | if (success) 47 | { 48 | await _logger.LogActivity( 49 | site.Id, 50 | ActivityCodeEnum.CommentDelete, 51 | ActivitySeverityEnum.Low, 52 | ActivityObjectEnum.Comment, 53 | $"The comment \"{commentTruncatedContent}\" written by the user \"{commentWriterUsername}\" has been deleted."); 54 | 55 | return Unit.Value; 56 | } 57 | 58 | throw new Exception("Problem saving changes!"); 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/CommentServices/AdminServices/Details.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.CommentServices.AdminServices.DTOs; 6 | using Aspian.Application.Core.Errors; 7 | using Aspian.Application.Core.Interfaces; 8 | using Aspian.Domain.ActivityModel; 9 | using Aspian.Domain.SiteModel; 10 | using Aspian.Persistence; 11 | using AutoMapper; 12 | using MediatR; 13 | using Microsoft.EntityFrameworkCore; 14 | 15 | namespace Aspian.Application.Core.CommentServices.AdminServices 16 | { 17 | public class Details 18 | { 19 | public class Query : IRequest 20 | { 21 | public Guid Id { get; set; } 22 | } 23 | 24 | public class Handler : IRequestHandler 25 | { 26 | private readonly DataContext _context; 27 | private readonly IMapper _mapper; 28 | private readonly IActivityLogger _logger; 29 | public Handler(DataContext context, IMapper mapper, IActivityLogger logger) 30 | { 31 | _logger = logger; 32 | _mapper = mapper; 33 | _context = context; 34 | } 35 | 36 | public async Task Handle(Query request, CancellationToken cancellationToken) 37 | { 38 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 39 | var comment = await _context.Comments.FindAsync(request.Id); 40 | if (comment == null) 41 | throw new RestException(HttpStatusCode.NotFound, new { comment = "Not found!" }); 42 | 43 | await _logger.LogActivity( 44 | site.Id, 45 | ActivityCodeEnum.CommentDetails, 46 | ActivitySeverityEnum.Information, 47 | ActivityObjectEnum.Comment, 48 | $"The comment \"{comment.Content.Substring(0, 30)}\" has been read."); 49 | 50 | return _mapper.Map(comment); 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/CommentServices/AdminServices/List.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.CommentServices.AdminServices.DTOs; 6 | using Aspian.Application.Core.Interfaces; 7 | using Aspian.Domain.ActivityModel; 8 | using Aspian.Domain.SiteModel; 9 | using Aspian.Persistence; 10 | using AutoMapper; 11 | using MediatR; 12 | using Microsoft.EntityFrameworkCore; 13 | 14 | namespace Aspian.Application.Core.CommentServices.AdminServices 15 | { 16 | public class List 17 | { 18 | public class Query : IRequest> { } 19 | 20 | public class Handler : IRequestHandler> 21 | { 22 | private readonly DataContext _context; 23 | private readonly IMapper _mapper; 24 | private readonly IActivityLogger _logger; 25 | public Handler(DataContext context, IMapper mapper, IActivityLogger logger) 26 | { 27 | _logger = logger; 28 | _mapper = mapper; 29 | _context = context; 30 | } 31 | 32 | public async Task> Handle(Query request, CancellationToken cancellationToken) 33 | { 34 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 35 | var comments = await _context.Comments.ToListAsync(); 36 | 37 | await _logger.LogActivity( 38 | site.Id, 39 | ActivityCodeEnum.CommentList, 40 | ActivitySeverityEnum.Information, 41 | ActivityObjectEnum.Comment, 42 | $"A list of all comments has been requested and recieved by user"); 43 | 44 | return _mapper.Map>(comments); 45 | } 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/Errors/RestException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | 4 | namespace Aspian.Application.Core.Errors 5 | { 6 | public class RestException : Exception 7 | { 8 | public RestException(HttpStatusCode code, object errors = null) 9 | { 10 | Code = code; 11 | Errors = errors; 12 | } 13 | 14 | public HttpStatusCode Code { get; } 15 | public object Errors { get; } 16 | } 17 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/Interfaces/IActivityLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Aspian.Domain.ActivityModel; 4 | 5 | namespace Aspian.Application.Core.Interfaces 6 | { 7 | public interface IActivityLogger 8 | { 9 | /// 10 | /// Add an activity in database by getting the and its , , and . 11 | /// 12 | /// The guid of current site. 13 | /// The code of an activity. 14 | /// The severity of an activity. 15 | /// The object name of an activity. 16 | /// The message or description of an activity. 17 | Task LogActivity(Guid siteId, ActivityCodeEnum code, ActivitySeverityEnum severity, ActivityObjectEnum objectName, string message); 18 | } 19 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/Interfaces/IBackgroundTaskQueue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace Aspian.Application.Core.Interfaces 6 | { 7 | public interface IBackgroundTaskQueue 8 | { 9 | void QueueBackgroundWorkItem(Func workItem); 10 | 11 | Task> DequeueAsync( 12 | CancellationToken cancellationToken); 13 | } 14 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/Interfaces/IOptionAccessor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using Aspian.Application.Core.OptionServices; 4 | using Aspian.Application.Core.OptionServices.AdminServices; 5 | using Aspian.Domain.OptionModel; 6 | using Aspian.Domain.SiteModel; 7 | 8 | namespace Aspian.Application.Core.Interfaces 9 | { 10 | public interface IOptionAccessor 11 | { 12 | /// 13 | /// Gets option values related to a specific option section by . 14 | /// 15 | /// 16 | /// Collection of option values related to an option section. 17 | /// 18 | /// The section name which must be a SectionEnum. 19 | /// The site module to which options are related and must be a SiteTypeEnum. 20 | Task> GetOptionValuesBySectionAsync(SectionEnum section, SiteTypeEnum siteType); 21 | 22 | /// 23 | /// Gets a specific option info by . 24 | /// 25 | /// 26 | /// Option key and value with its extra information. 27 | /// 28 | /// The option key which must be a KeyEnum. 29 | Task GetOptionmetaByKeyAsync(KeyEnum key); 30 | 31 | /// 32 | /// Gets a specific option info by . 33 | /// 34 | /// 35 | /// Option key and value with its extra information. 36 | /// 37 | /// The option key description which must be string. 38 | Task GetOptionmetaByKeyDescriptionAsync(string keyDescription); 39 | } 40 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/Interfaces/IScheduler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Aspian.Domain.ScheduleModel; 5 | 6 | namespace Aspian.Application.Core.Interfaces 7 | { 8 | public interface IScheduler 9 | { 10 | /// 11 | /// Sets and Queues a background task by getting , and . 12 | /// 13 | /// 14 | /// A Task. 15 | /// 16 | /// Type of schedule. 17 | /// The date and time of schedule. 18 | /// The Guid of the item you want to schedule. 19 | Task SetAndQueueTaskAsync(ScheduleTypeEnum scheduleType, DateTime scheduleFor, Guid scheduledItemId); 20 | 21 | /// 22 | /// Recovers all pending schedules after unexpected shutdowns. 23 | /// 24 | /// 25 | /// A Task. 26 | /// 27 | Task RecoverScheduledTasks(); 28 | } 29 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/Interfaces/ISlugGenerator.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Application.Core.Interfaces 2 | { 3 | public interface ISlugGenerator 4 | { 5 | string GenerateSlug(string phrase); 6 | } 7 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/Interfaces/IUserAccessor.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Application.Core.Interfaces 2 | { 3 | public interface IUserAccessor 4 | { 5 | string GetCurrentUsername(); 6 | string GetCurrentUserIpAddress(); 7 | string GetCurrentUserAgent(); 8 | } 9 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/OptionServices/AdminServices/DTOs/MappingProfile.cs: -------------------------------------------------------------------------------- 1 | using Aspian.Domain.OptionModel; 2 | using Aspian.Domain.SiteModel; 3 | using Aspian.Domain.UserModel; 4 | using AutoMapper; 5 | 6 | namespace Aspian.Application.Core.OptionServices.AdminServices.DTOs 7 | { 8 | public class MappingProfile : Profile 9 | { 10 | public MappingProfile() 11 | { 12 | CreateMap(); 13 | CreateMap(); 14 | CreateMap(); 15 | CreateMap(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/OptionServices/AdminServices/DTOs/OptionDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Aspian.Application.Core.OptionServices.AdminServices.DTOs 5 | { 6 | public class OptionDto 7 | { 8 | public string Section { get; set; } 9 | public string Description { get; set; } 10 | public virtual SiteDto Site { get; set; } 11 | public virtual ICollection Optionmetas { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/OptionServices/AdminServices/DTOs/OptionmetaDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.OptionServices.AdminServices.DTOs 4 | { 5 | public class OptionmetaDto 6 | { 7 | public string PublicKeyName { get; set; } 8 | public string Key { get; set; } 9 | public string KeyDescription { get; set; } 10 | public string Value { get; set; } 11 | public string ValueDescription { get; set; } 12 | public string DefaultValue { get; set; } 13 | public string DefaultValueDescription { get; set; } 14 | public string AdditionalInfo { get; set; } 15 | public DateTime? ModifiedDate { get; set; } 16 | public string ModifiedById { get; set; } 17 | public UserDto ModifiedBy { get; set; } 18 | public string UserAgent { get; set; } 19 | public string UserIPAddress { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/OptionServices/AdminServices/DTOs/SiteDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.OptionServices.AdminServices.DTOs 4 | { 5 | public class SiteDto 6 | { 7 | public string Domain { get; set; } 8 | public string Path { get; set; } 9 | public DateTime Registered { get; set; } 10 | public DateTime? LastUpdated { get; set; } 11 | public string SiteType { get; set; } 12 | public bool Activated { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/OptionServices/AdminServices/DTOs/UserDto.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Application.Core.OptionServices.AdminServices.DTOs 2 | { 3 | public class UserDto 4 | { 5 | public string DisplayName { get; set; } 6 | public string Token { get; set; } 7 | public string UserName { get; set; } 8 | public string Role { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/OptionServices/AdminServices/Edit.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Aspian.Application.Core.Errors; 7 | using Aspian.Application.Core.Interfaces; 8 | using Aspian.Application.Core.OptionServices.AdminServices.DTOs; 9 | using Aspian.Domain.ActivityModel; 10 | using Aspian.Domain.OptionModel; 11 | using Aspian.Domain.SiteModel; 12 | using Aspian.Persistence; 13 | using MediatR; 14 | using Microsoft.EntityFrameworkCore; 15 | 16 | namespace Aspian.Application.Core.OptionServices.AdminServices 17 | { 18 | public class Edit 19 | { 20 | public class Command : IRequest 21 | { 22 | public Guid Id { get; set; } 23 | public ValueEnum Value { get; set; } 24 | } 25 | 26 | public class Handler : IRequestHandler 27 | { 28 | private readonly DataContext _context; 29 | private readonly IActivityLogger _logger; 30 | public Handler(DataContext context, IActivityLogger logger) 31 | { 32 | _logger = logger; 33 | _context = context; 34 | } 35 | 36 | public async Task Handle(Command request, CancellationToken cancellationToken) 37 | { 38 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 39 | var optionmeta = await _context.Optionmetas.FindAsync(request.Id); 40 | if (optionmeta == null) 41 | throw new RestException(HttpStatusCode.NotFound, new { optionmeta = "Not found!" }); 42 | 43 | optionmeta.Value = request.Value; 44 | 45 | var success = await _context.SaveChangesAsync() > 0; 46 | 47 | if (success) 48 | { 49 | await _logger.LogActivity( 50 | site.Id, 51 | ActivityCodeEnum.OptionEdit, 52 | ActivitySeverityEnum.High, 53 | ActivityObjectEnum.Option, 54 | $"The option \"{optionmeta.KeyDescription}\" has been changed."); 55 | 56 | return Unit.Value; 57 | } 58 | 59 | throw new Exception("Problem saving changes!"); 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/OptionServices/AdminServices/List.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.Interfaces; 6 | using Aspian.Application.Core.OptionServices.AdminServices.DTOs; 7 | using Aspian.Domain.ActivityModel; 8 | using Aspian.Domain.OptionModel; 9 | using Aspian.Domain.SiteModel; 10 | using Aspian.Persistence; 11 | using AutoMapper; 12 | using MediatR; 13 | using Microsoft.EntityFrameworkCore; 14 | 15 | namespace Aspian.Application.Core.OptionServices.AdminServices 16 | { 17 | public class List 18 | { 19 | public class Query : IRequest> { } 20 | 21 | public class Handler : IRequestHandler> 22 | { 23 | private readonly DataContext _context; 24 | private readonly IMapper _mapper; 25 | private readonly IActivityLogger _logger; 26 | public Handler(DataContext context, IMapper mapper, IActivityLogger logger) 27 | { 28 | _logger = logger; 29 | _mapper = mapper; 30 | _context = context; 31 | } 32 | 33 | public async Task> Handle(Query request, CancellationToken cancellationToken) 34 | { 35 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 36 | var options = await _context.Options.ToListAsync(); 37 | 38 | await _logger.LogActivity( 39 | site.Id, 40 | ActivityCodeEnum.OptionList, 41 | ActivitySeverityEnum.Medium, 42 | ActivityObjectEnum.Option, 43 | $"A list of all options has been requested and recieved by user"); 44 | 45 | return _mapper.Map>(options); 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/OptionServices/AdminServices/OptionmetaResult.cs: -------------------------------------------------------------------------------- 1 | using Aspian.Domain.OptionModel; 2 | 3 | namespace Aspian.Application.Core.OptionServices.AdminServices 4 | { 5 | public class OptionmetaResult 6 | { 7 | public string PublicKeyName { get; set; } 8 | public KeyEnum Key { get; set; } 9 | public string KeyDescription { get; set; } 10 | public ValueEnum Value { get; set; } 11 | public string ValueDescription { get; set; } 12 | public string AdditionalInfo { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/OptionServices/AdminServices/RestoreDefaultOption.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.Errors; 6 | using Aspian.Application.Core.Interfaces; 7 | using Aspian.Domain.ActivityModel; 8 | using Aspian.Domain.SiteModel; 9 | using Aspian.Persistence; 10 | using MediatR; 11 | using Microsoft.EntityFrameworkCore; 12 | 13 | namespace Aspian.Application.Core.OptionServices.AdminServices 14 | { 15 | public class RestoreDefaultOption 16 | { 17 | public class Command : IRequest 18 | { 19 | public Guid Id { get; set; } 20 | } 21 | 22 | public class Handler : IRequestHandler 23 | { 24 | private readonly DataContext _context; 25 | private readonly IActivityLogger _logger; 26 | public Handler(DataContext context, IActivityLogger logger) 27 | { 28 | _logger = logger; 29 | _context = context; 30 | } 31 | 32 | public async Task Handle(Command request, CancellationToken cancellationToken) 33 | { 34 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 35 | var optionmeta = await _context.Optionmetas.FindAsync(request.Id); 36 | if (optionmeta == null) 37 | throw new RestException(HttpStatusCode.NotFound, new { optionmeta = "Not found!" }); 38 | 39 | optionmeta.Value = optionmeta.DefaultValue; 40 | 41 | var success = await _context.SaveChangesAsync() > 0; 42 | 43 | if (success) 44 | { 45 | await _logger.LogActivity( 46 | site.Id, 47 | ActivityCodeEnum.OptionRestoreDefaultOption, 48 | ActivitySeverityEnum.High, 49 | ActivityObjectEnum.Option, 50 | $"The option \"{optionmeta.KeyDescription}\" has been restored to default."); 51 | 52 | return Unit.Value; 53 | } 54 | 55 | throw new Exception("Problem saving changes!"); 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/AntParentPostTreeSelectDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 4 | { 5 | public class AntParentPostTreeSelectDto 6 | { 7 | public string Title { get; set; } 8 | public string Value { get; set; } 9 | public string Key { get; set; } 10 | public ICollection Children { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/AttachmentDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.AttachmentModel; 4 | 5 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 6 | { 7 | public class AttachmentDto 8 | { 9 | public Guid Id { get; set; } 10 | public AttachmentTypeEnum Type { get; set; } 11 | public string FileName { get; set; } 12 | public string PublicFileName { get; set; } 13 | public string FileExtension { get; set; } 14 | public string FileSize { get; set; } 15 | public string MimeType { get; set; } 16 | public string UploadLocation { get; set; } 17 | public string RelativePath { get; set; } 18 | public bool IsMain { get; set; } 19 | public DateTime CreatedAt { get; set; } 20 | public string CreatedById { get; set; } 21 | 22 | #region Navigation Properties 23 | public virtual ICollection Attachmentmetas { get; set; } 24 | 25 | #endregion 26 | } 27 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/AttachmentmetaDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 4 | { 5 | public class AttachmentmetaDto 6 | { 7 | public Guid Id { get; set; } 8 | public string MetaKey { get; set; } 9 | public string MetaValue { get; set; } 10 | public DateTime CreatedAt { get; set; } 11 | public string CreatedById { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/PhotoDto.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 2 | { 3 | public class PhotoDto 4 | { 5 | public string Type { get; set; } 6 | public string FileName { get; set; } 7 | public string FileExtension { get; set; } 8 | public string FileSize { get; set; } 9 | public string MimeType { get; set; } 10 | public string UploadLocation { get; set; } 11 | public string RelativePath { get; set; } 12 | public bool IsMain { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/PostAttachmentDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 4 | { 5 | public class PostAttachmentDto 6 | { 7 | public bool IsMain { get; set; } 8 | public virtual AttachmentDto Attachment { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/PostDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.AttachmentModel; 4 | using Aspian.Domain.PostModel; 5 | using Aspian.Domain.TaxonomyModel; 6 | using Aspian.Domain.UserModel; 7 | 8 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 9 | { 10 | public class PostDto 11 | { 12 | public Guid Id { get; set; } 13 | public string Title { get; set; } 14 | public string Subtitle { get; set; } 15 | public string Excerpt { get; set; } 16 | public string Content { get; set; } 17 | public string Slug { get; set; } 18 | public PostVisibility Visibility { get; set; } 19 | public PostStatusEnum PostStatus { get; set; } 20 | public DateTime? ScheduledFor { get; set; } 21 | public bool CommentAllowed { get; set; } 22 | public int ViewCount { get; set; } 23 | public PostTypeEnum Type { get; set; } 24 | public bool IsPinned { get; set; } 25 | public int PostHistories { get; set; } 26 | public int Comments { get; set; } 27 | public DateTime CreatedAt { get; set; } 28 | public DateTime? ModifiedAt { get; set; } 29 | public string UserAgent { get; set; } 30 | public string UserIPAddress { get; set; } 31 | 32 | 33 | #region Navigation Properties 34 | public virtual UserDto CreatedBy { get; set; } 35 | public UserDto ModifiedBy { get; set; } 36 | public virtual ICollection PostAttachments { get; set; } 37 | public virtual SiteDto Site { get; set; } 38 | public virtual ICollection TaxonomyPosts { get; set; } 39 | //public virtual ICollection Postmetas { get; set; } 40 | 41 | #endregion 42 | } 43 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/PostmetaDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 4 | { 5 | public class PostmetaDto 6 | { 7 | public Guid Id { get; set; } 8 | public string MetaKey { get; set; } 9 | public string MetaValue { get; set; } 10 | public DateTime CreatedAt { get; set; } 11 | public string CreatedById { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/SiteDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 4 | { 5 | public class SiteDto 6 | { 7 | public Guid Id { get; set; } 8 | public string Domain { get; set; } 9 | public string Path { get; set; } 10 | public DateTime Registered { get; set; } 11 | public DateTime? LastUpdated { get; set; } 12 | public string SiteType { get; set; } 13 | public bool Activated { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/TaxonomyDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.TaxonomyModel; 4 | 5 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 6 | { 7 | public class TaxonomyDto 8 | { 9 | public Guid Id { get; set; } 10 | public TaxonomyTypeEnum Type { get; set; } 11 | 12 | 13 | #region Navigaiton Properties 14 | public virtual TermDto Term { get; set; } 15 | #endregion 16 | } 17 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/TaxonomyPostDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.TaxonomyModel; 3 | 4 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 5 | { 6 | public class TaxonomyPostDto 7 | { 8 | public virtual TaxonomyDto Taxonomy { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/TermDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.TaxonomyModel; 4 | 5 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 6 | { 7 | public class TermDto 8 | { 9 | public Guid Id { get; set; } 10 | public string Name { get; set; } 11 | 12 | } 13 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/TermmetaDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 4 | { 5 | public class TermmetaDto 6 | { 7 | public Guid Id { get; set; } 8 | public string Key { get; set; } 9 | public string Value { get; set; } 10 | public DateTime CreatedAt { get; set; } 11 | public string CreatedById { get; set; } 12 | 13 | } 14 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/DTOs/UserDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Aspian.Application.Core.PostServices.AdminServices.DTOs 4 | { 5 | public class UserDto 6 | { 7 | public string Id { get; set; } 8 | public string DisplayName { get; set; } 9 | public string UserName { get; set; } 10 | public string Email { get; set; } 11 | public string Bio { get; set; } 12 | public string Role { get; set; } 13 | public PhotoDto ProfilePhoto { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/Details.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using Aspian.Application.Core.Errors; 7 | using Aspian.Application.Core.Interfaces; 8 | using Aspian.Application.Core.PostServices.AdminServices.DTOs; 9 | using Aspian.Domain.ActivityModel; 10 | using Aspian.Domain.PostModel; 11 | using Aspian.Domain.SiteModel; 12 | using Aspian.Persistence; 13 | using AutoMapper; 14 | using FluentValidation; 15 | using MediatR; 16 | using Microsoft.EntityFrameworkCore; 17 | 18 | namespace Aspian.Application.Core.PostServices.AdminServices 19 | { 20 | public class Details 21 | { 22 | public class Query : IRequest 23 | { 24 | public Guid Id { get; set; } 25 | } 26 | 27 | public class Handler : IRequestHandler 28 | { 29 | private readonly DataContext _context; 30 | private readonly IMapper _mapper; 31 | private readonly IActivityLogger _logger; 32 | public Handler(DataContext context, IMapper mapper, IActivityLogger logger) 33 | { 34 | _logger = logger; 35 | _mapper = mapper; 36 | _context = context; 37 | } 38 | 39 | public async Task Handle(Query request, CancellationToken cancellationToken) 40 | { 41 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 42 | var post = await _context.Posts.FindAsync(request.Id); 43 | 44 | if (post == null) 45 | throw new RestException(HttpStatusCode.NotFound, new { post = "Not found!" }); 46 | 47 | var postTitleSubstring = post.Title.Length > 30 ? post.Title.Substring(0, 30) + "..." : post.Title; 48 | await _logger.LogActivity( 49 | site.Id, 50 | ActivityCodeEnum.PostDetails, 51 | ActivitySeverityEnum.Information, 52 | ActivityObjectEnum.Post, 53 | $"The post \"{postTitleSubstring}\" has been read."); 54 | 55 | return _mapper.Map(post); 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/PostServices/AdminServices/ParentPostTreeSelectAntd.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.PostServices.AdminServices.DTOs; 6 | using Aspian.Persistence; 7 | using AutoMapper; 8 | using MediatR; 9 | using Microsoft.EntityFrameworkCore; 10 | 11 | namespace Aspian.Application.Core.PostServices.AdminServices 12 | { 13 | public class ParentPostTreeSelectAntd 14 | { 15 | public class Query : IRequest> { } 16 | 17 | public class Handler : IRequestHandler> 18 | { 19 | private readonly DataContext _context; 20 | private readonly IMapper _mapper; 21 | public Handler(DataContext context, IMapper mapper) 22 | { 23 | _mapper = mapper; 24 | _context = context; 25 | } 26 | 27 | public async Task> Handle(Query request, CancellationToken cancellationToken) 28 | { 29 | var posts = await _context.Posts.ToListAsync(); 30 | return _mapper.Map>(posts); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/SiteServices/AdminServices/DTOs/MappingProfile.cs: -------------------------------------------------------------------------------- 1 | using Aspian.Domain.SiteModel; 2 | using Aspian.Domain.UserModel; 3 | using AutoMapper; 4 | 5 | namespace Aspian.Application.Core.SiteServices.AdminServices.DTOs 6 | { 7 | public class MappingProfile : Profile 8 | { 9 | public MappingProfile() 10 | { 11 | CreateMap(); 12 | CreateMap(); 13 | 14 | CreateMap() 15 | .ForMember(d => d.Id, o => o.UseDestinationValue()) 16 | .ForMember(d => d.CreatedAt, o => o.UseDestinationValue()); 17 | 18 | CreateMap() 19 | .ForMember(d => d.Id, o => o.UseDestinationValue()) 20 | .ForMember(d => d.CreatedAt, o => o.UseDestinationValue()); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/SiteServices/AdminServices/DTOs/SiteDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.SiteModel; 3 | 4 | namespace Aspian.Application.Core.SiteServices.AdminServices.DTOs 5 | { 6 | public class SiteDto 7 | { 8 | public Guid Id { get; set; } 9 | public string Domain { get; set; } 10 | public string Path { get; set; } 11 | public string SiteType { get; set; } 12 | public bool IsActivated { get; set; } 13 | public DateTime? ModuleActivatedAt { get; set; } 14 | public DateTime? ModuleExpiresAt { get; set; } 15 | public DateTime? MainHostActivatedAt { get; set; } 16 | public DateTime? MainHostExpiresAt { get; set; } 17 | public long MainHostCapacity { get; set; } 18 | public long MainHostAvailableSpace { get; set; } 19 | public bool HasDownloadHost { get; set; } 20 | public DateTime? DownloadHostActivatedAt { get; set; } 21 | public DateTime? DownloadHostExpiresAt { get; set; } 22 | public long? DownloadHostCapacity { get; set; } 23 | public long? DownloadHostAvailableSpace { get; set; } 24 | public DateTime CreatedAt { get; set; } 25 | public DateTime? ModifiedAt { get; set; } 26 | public virtual UserDto ModifiedBy { get; set; } 27 | } 28 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/SiteServices/AdminServices/DTOs/UserDto.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Application.Core.SiteServices.AdminServices.DTOs 2 | { 3 | public class UserDto 4 | { 5 | public string Id { get; set; } 6 | public string DisplayName { get; set; } 7 | public string Email { get; set; } 8 | public string Bio { get; set; } 9 | public string Role { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/SiteServices/AdminServices/Details.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.Errors; 6 | using Aspian.Application.Core.Interfaces; 7 | using Aspian.Application.Core.SiteServices.AdminServices.DTOs; 8 | using Aspian.Domain.ActivityModel; 9 | using Aspian.Domain.SiteModel; 10 | using Aspian.Persistence; 11 | using AutoMapper; 12 | using MediatR; 13 | using Microsoft.EntityFrameworkCore; 14 | 15 | namespace Aspian.Application.Core.SiteServices.AdminServices 16 | { 17 | public class Details 18 | { 19 | public class Query : IRequest 20 | { 21 | public SiteTypeEnum SiteType { get; set; } 22 | } 23 | 24 | public class Handler : IRequestHandler 25 | { 26 | private readonly DataContext _context; 27 | private readonly IMapper _mapper; 28 | private readonly IActivityLogger _logger; 29 | public Handler(DataContext context, IMapper mapper, IActivityLogger logger) 30 | { 31 | _logger = logger; 32 | _mapper = mapper; 33 | _context = context; 34 | } 35 | 36 | public async Task Handle(Query request, CancellationToken cancellationToken) 37 | { 38 | var site = await _context.Sites.SingleOrDefaultAsync(x => x.SiteType == request.SiteType); 39 | 40 | if (site == null) 41 | throw new RestException(HttpStatusCode.NotFound, new { site = "Not found!" }); 42 | 43 | await _logger.LogActivity( 44 | site.Id, 45 | ActivityCodeEnum.SiteDetails, 46 | ActivitySeverityEnum.Information, 47 | ActivityObjectEnum.Site, 48 | $"Details of the site \"{site.SiteType.ToString()}\" has been read."); 49 | 50 | return _mapper.Map(site); 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/SiteServices/AdminServices/Edit.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.Errors; 6 | using Aspian.Domain.SiteModel; 7 | using Aspian.Persistence; 8 | using AutoMapper; 9 | using MediatR; 10 | 11 | namespace Aspian.Application.Core.SiteServices.AdminServices 12 | { 13 | public class Edit 14 | { 15 | public class Command : IRequest 16 | { 17 | public Guid Id { get; set; } 18 | public string Domain { get; set; } 19 | public string Path { get; set; } 20 | public SiteTypeEnum SiteType { get; set; } 21 | } 22 | 23 | public class Handler : IRequestHandler 24 | { 25 | private readonly DataContext _context; 26 | private readonly IMapper _mapper; 27 | public Handler(DataContext context, IMapper mapper) 28 | { 29 | _mapper = mapper; 30 | _context = context; 31 | } 32 | 33 | public async Task Handle(Command request, CancellationToken cancellationToken) 34 | { 35 | var site = await _context.Sites.FindAsync(request.Id); 36 | 37 | if (site == null) 38 | throw new RestException(HttpStatusCode.NotFound, new {Site = "not found!"}); 39 | 40 | _mapper.Map(request, site); 41 | 42 | var success = await _context.SaveChangesAsync() > 0; 43 | 44 | if (success) return Unit.Value; 45 | 46 | throw new Exception("Problem saving changes!"); 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/SiteServices/AdminServices/List.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Aspian.Application.Core.Interfaces; 5 | using Aspian.Application.Core.SiteServices.AdminServices.DTOs; 6 | using Aspian.Domain.ActivityModel; 7 | using Aspian.Domain.SiteModel; 8 | using Aspian.Persistence; 9 | using AutoMapper; 10 | using MediatR; 11 | using Microsoft.EntityFrameworkCore; 12 | 13 | namespace Aspian.Application.Core.SiteServices.AdminServices 14 | { 15 | public class List 16 | { 17 | public class Query : IRequest> { } 18 | 19 | public class Handler : IRequestHandler> 20 | { 21 | private readonly DataContext _context; 22 | private readonly IMapper _mapper; 23 | private readonly IActivityLogger _logger; 24 | public Handler(DataContext context, IMapper mapper, IActivityLogger logger) 25 | { 26 | _logger = logger; 27 | _mapper = mapper; 28 | _context = context; 29 | } 30 | 31 | public async Task> Handle(Query request, CancellationToken cancellationToken) 32 | { 33 | var site = await _context.Sites.SingleOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 34 | var Sites = await _context.Sites.ToListAsync(); 35 | 36 | await _logger.LogActivity( 37 | site.Id, 38 | ActivityCodeEnum.SiteList, 39 | ActivitySeverityEnum.Information, 40 | ActivityObjectEnum.Site, 41 | "Get a List of all sites infromation."); 42 | 43 | return _mapper.Map>(Sites); 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/TaxonomyServices/AdminServices/CategoryTreeSelectAntd.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.TaxonomyServices.AdminServices.DTOs; 6 | using Aspian.Domain.TaxonomyModel; 7 | using Aspian.Persistence; 8 | using AutoMapper; 9 | using MediatR; 10 | using Microsoft.EntityFrameworkCore; 11 | 12 | namespace Aspian.Application.Core.TaxonomyServices.AdminServices 13 | { 14 | public class CategoryTreeSelectAntd 15 | { 16 | public class Query : IRequest> { } 17 | 18 | public class Handler : IRequestHandler> 19 | { 20 | private readonly DataContext _context; 21 | private readonly IMapper _mapper; 22 | public Handler(DataContext context, IMapper mapper) 23 | { 24 | _mapper = mapper; 25 | _context = context; 26 | } 27 | 28 | public async Task> Handle(Query request, CancellationToken cancellationToken) 29 | { 30 | var categories = await _context.Taxonomies.Where(x => x.Type == TaxonomyTypeEnum.category && x.ParentId == null).ToListAsync(); 31 | return _mapper.Map>(categories); 32 | } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/TaxonomyServices/AdminServices/DTOs/AntdCategoryTreeSelectDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Aspian.Application.Core.TaxonomyServices.AdminServices.DTOs 4 | { 5 | public class AntdCategoryTreeSelectDto 6 | { 7 | public string Title { get; set; } 8 | public string Value { get; set; } 9 | public string Key { get; set; } 10 | public ICollection Children { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/TaxonomyServices/AdminServices/DTOs/MappingProfile.cs: -------------------------------------------------------------------------------- 1 | using Aspian.Domain.PostModel; 2 | using Aspian.Domain.TaxonomyModel; 3 | using Aspian.Domain.UserModel; 4 | using AutoMapper; 5 | 6 | namespace Aspian.Application.Core.TaxonomyServices.AdminServices.DTOs 7 | { 8 | public class MappingProfile : Profile 9 | { 10 | public MappingProfile() 11 | { 12 | CreateMap(); 13 | CreateMap(); 14 | CreateMap() 15 | .ForMember(d => d.CreatedAt, o => o.UseDestinationValue()) 16 | .ForMember(d => d.CreatedById, o => o.UseDestinationValue()); 17 | CreateMap(); 18 | CreateMap(); 19 | CreateMap() 20 | .ForPath(d => d.Term.Id, o => o.Ignore()) 21 | .ForPath(d => d.Term.Name, o => o.MapFrom(s => s.Term.Name)) 22 | .ForPath(d => d.Term.Slug, o => o.MapFrom(s => s.Term.Slug)); 23 | CreateMap() 24 | .ForMember(d => d.CreatedAt, o => o.UseDestinationValue()) 25 | .ForMember(d => d.CreatedById, o => o.UseDestinationValue()) 26 | .ForPath(d => d.Term.Id, o => o.Ignore()) 27 | .ForPath(d => d.Term.Name, o => o.MapFrom(s => s.Term.Name)) 28 | .ForPath(d => d.Term.Slug, o => o.MapFrom(s => s.Term.Slug)); 29 | CreateMap(); 30 | 31 | CreateMap() 32 | .ForMember(d => d.Title, o => o.MapFrom(s => s.Term.Name)) 33 | .ForMember(d => d.Value, o => o.MapFrom(s => s.Id)) 34 | .ForMember(d => d.Key, o => o.MapFrom(s => s.Id)) 35 | .ForMember(d => d.Children, o => o.MapFrom(s => s.ChildTaxonomies)); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/TaxonomyServices/AdminServices/DTOs/PostDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.TaxonomyServices.AdminServices.DTOs 4 | { 5 | public class PostDto 6 | { 7 | public Guid Id { get; set; } 8 | public string Title { get; set; } 9 | public string Subtitle { get; set; } 10 | public string Excerpt { get; set; } 11 | public string Content { get; set; } 12 | public string Slug { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/TaxonomyServices/AdminServices/DTOs/TaxonomyDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text.Json.Serialization; 4 | 5 | namespace Aspian.Application.Core.TaxonomyServices.AdminServices.DTOs 6 | { 7 | public class TaxonomyDto 8 | { 9 | public Guid Id { get; set; } 10 | public DateTime CreatedAt { get; set; } 11 | public DateTime? ModifiedAt { get; set; } 12 | public string CreatedById { get; set; } 13 | public virtual UserDto CreatedBy { get; set; } 14 | public string ModifiedById { get; set; } 15 | public virtual UserDto ModifiedBy { get; set; } 16 | public string UserAgent { get; set; } 17 | public string UserIPAddress { get; set; } 18 | public string Type { get; set; } 19 | public string Description { get; set; } 20 | public virtual TermDto Term { get; set; } 21 | public Guid? ParentId { get; set; } 22 | //public virtual TaxonomyDto Parent { get; set; } 23 | public virtual ICollection ChildTaxonomies { get; set; } 24 | [JsonPropertyName("posts")] 25 | public virtual ICollection TaxonomyPosts { get; set; } 26 | } 27 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/TaxonomyServices/AdminServices/DTOs/TaxonomyPostDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.TaxonomyServices.AdminServices.DTOs 4 | { 5 | public class TaxonomyPostDto 6 | { 7 | public Guid PostId { get; set; } 8 | public virtual PostDto Post { get; set; } 9 | public Guid TaxonomyId { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/TaxonomyServices/AdminServices/DTOs/TermDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Application.Core.TaxonomyServices.AdminServices.DTOs 4 | { 5 | public class TermDto 6 | { 7 | public Guid Id { get; set; } 8 | public DateTime CreatedAt { get; set; } 9 | public DateTime? ModifiedAt { get; set; } 10 | public string CreatedById { get; set; } 11 | public virtual UserDto CreatedBy { get; set; } 12 | public string ModifiedById { get; set; } 13 | public virtual UserDto ModifiedBy { get; set; } 14 | public string UserAgent { get; set; } 15 | public string UserIPAddress { get; set; } 16 | public string Name { get; set; } 17 | public string Slug { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/TaxonomyServices/AdminServices/DTOs/UserDto.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Application.Core.TaxonomyServices.AdminServices.DTOs 2 | { 3 | public class UserDto 4 | { 5 | public string DisplayName { get; set; } 6 | public string Email { get; set; } 7 | public string Bio { get; set; } 8 | public string Role { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/TaxonomyServices/AdminServices/Delete.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.Errors; 6 | using Aspian.Application.Core.Interfaces; 7 | using Aspian.Domain.ActivityModel; 8 | using Aspian.Domain.SiteModel; 9 | using Aspian.Persistence; 10 | using MediatR; 11 | using Microsoft.EntityFrameworkCore; 12 | 13 | namespace Aspian.Application.Core.TaxonomyServices.AdminServices 14 | { 15 | public class Delete 16 | { 17 | public class Command : IRequest 18 | { 19 | public Guid Id { get; set; } 20 | } 21 | 22 | public class Handler : IRequestHandler 23 | { 24 | private readonly DataContext _context; 25 | private readonly IActivityLogger _logger; 26 | public Handler(DataContext context, IActivityLogger logger) 27 | { 28 | _logger = logger; 29 | _context = context; 30 | } 31 | 32 | public async Task Handle(Command request, CancellationToken cancellationToken) 33 | { 34 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 35 | var taxonomy = await _context.Taxonomies.FindAsync(request.Id); 36 | 37 | if (taxonomy == null) 38 | throw new RestException(HttpStatusCode.NotFound, new { taxonomy = "Not found!" }); 39 | 40 | var taxonomyType = taxonomy.Type.ToString(); 41 | var taxonomyTermName = taxonomy.Term.Name; 42 | 43 | _context.Remove(taxonomy); 44 | 45 | var success = await _context.SaveChangesAsync() > 0; 46 | 47 | if (success) 48 | { 49 | await _logger.LogActivity( 50 | site.Id, 51 | ActivityCodeEnum.TaxonomyDelete, 52 | ActivitySeverityEnum.High, 53 | ActivityObjectEnum.Taxonomy, 54 | $"The taxonomy with type of \"{taxonomyType}\" and the term name \"{taxonomyTermName}\" has been deleted."); 55 | 56 | return Unit.Value; 57 | } 58 | 59 | throw new Exception("Problem saving changes!"); 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/TaxonomyServices/AdminServices/Details.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.Errors; 6 | using Aspian.Application.Core.Interfaces; 7 | using Aspian.Application.Core.TaxonomyServices.AdminServices.DTOs; 8 | using Aspian.Domain.ActivityModel; 9 | using Aspian.Domain.SiteModel; 10 | using Aspian.Domain.TaxonomyModel; 11 | using Aspian.Persistence; 12 | using AutoMapper; 13 | using MediatR; 14 | using Microsoft.EntityFrameworkCore; 15 | 16 | namespace Aspian.Application.Core.TaxonomyServices.AdminServices 17 | { 18 | public class Details 19 | { 20 | public class Query : IRequest 21 | { 22 | public Guid Id { get; set; } 23 | } 24 | 25 | public class Handler : IRequestHandler 26 | { 27 | private readonly DataContext _context; 28 | private readonly IMapper _mapper; 29 | private readonly IActivityLogger _logger; 30 | 31 | public Handler(DataContext context, IMapper mapper, IActivityLogger logger) 32 | { 33 | _logger = logger; 34 | _mapper = mapper; 35 | _context = context; 36 | } 37 | 38 | public async Task Handle(Query request, CancellationToken cancellationToken) 39 | { 40 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 41 | var taxonomy = await _context.Taxonomies.FindAsync(request.Id); 42 | 43 | if (taxonomy == null) 44 | throw new RestException(HttpStatusCode.NotFound, new { taxonomy = "Not found!" }); 45 | 46 | await _logger.LogActivity( 47 | site.Id, 48 | ActivityCodeEnum.TaxonomyDetails, 49 | ActivitySeverityEnum.Information, 50 | ActivityObjectEnum.Taxonomy, 51 | $"The taxonomy with type of \"{taxonomy.Type.ToString()}\" and the term name \"{taxonomy.Term.Name}\" has been read."); 52 | 53 | return _mapper.Map(taxonomy); 54 | } 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/TaxonomyServices/AdminServices/List.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.Interfaces; 6 | using Aspian.Application.Core.TaxonomyServices.AdminServices.DTOs; 7 | using Aspian.Domain.ActivityModel; 8 | using Aspian.Domain.SiteModel; 9 | using Aspian.Domain.TaxonomyModel; 10 | using Aspian.Persistence; 11 | using AutoMapper; 12 | using MediatR; 13 | using Microsoft.EntityFrameworkCore; 14 | 15 | namespace Aspian.Application.Core.TaxonomyServices.AdminServices 16 | { 17 | public class List 18 | { 19 | public class Query : IRequest> 20 | { 21 | public TaxonomyTypeEnum? TaxonomyType { get; set; } 22 | } 23 | 24 | public class Handler : IRequestHandler> 25 | { 26 | private readonly DataContext _context; 27 | private readonly IMapper _mapper; 28 | private readonly IActivityLogger _logger; 29 | 30 | public Handler(DataContext context, IMapper mapper, IActivityLogger logger) 31 | { 32 | _logger = logger; 33 | _context = context; 34 | _mapper = mapper; 35 | } 36 | 37 | public async Task> Handle(Query request, CancellationToken cancellationToken) 38 | { 39 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 40 | var taxonomies = request.TaxonomyType == null ? 41 | await _context.Taxonomies.ToListAsync() : 42 | await _context.Taxonomies.Where(x => x.Type == request.TaxonomyType).ToListAsync(); 43 | 44 | await _logger.LogActivity( 45 | site.Id, 46 | ActivityCodeEnum.TaxonomyList, 47 | ActivitySeverityEnum.Information, 48 | ActivityObjectEnum.Taxonomy, 49 | "A list of all taxonomies has been requested and recieved by user"); 50 | 51 | return _mapper.Map>(taxonomies); 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/UserServices/AdminServices/CurrentUser.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Aspian.Application.Core.Interfaces; 5 | using Aspian.Application.Core.UserServices.AdminServices.DTOs; 6 | using Aspian.Domain.ActivityModel; 7 | using Aspian.Domain.AttachmentModel; 8 | using Aspian.Domain.SiteModel; 9 | using Aspian.Domain.UserModel; 10 | using Aspian.Persistence; 11 | using AutoMapper; 12 | using MediatR; 13 | using Microsoft.AspNetCore.Identity; 14 | using Microsoft.EntityFrameworkCore; 15 | 16 | namespace Aspian.Application.Core.UserServices.AdminServices 17 | { 18 | public class CurrentUser 19 | { 20 | public class Query : IRequest { } 21 | 22 | public class Handler : IRequestHandler 23 | { 24 | private readonly UserManager _userManager; 25 | private readonly IUserAccessor _userAccessor; 26 | public Handler(UserManager userManager, IUserAccessor userAccessor) 27 | { 28 | _userAccessor = userAccessor; 29 | _userManager = userManager; 30 | 31 | } 32 | 33 | public async Task Handle(Query request, CancellationToken cancellationToken) 34 | { 35 | var user = await _userManager.FindByNameAsync(_userAccessor.GetCurrentUsername()); 36 | 37 | return new CurrentUserDto 38 | { 39 | DisplayName = user.DisplayName, 40 | UserName = user.UserName, 41 | Role = user.Role, 42 | //ProfilePhotoName = user.CreatedAttachments?.FirstOrDefault(x => x.Type == AttachmentTypeEnum.Photo && x.IsMain)?.FileName 43 | }; 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/UserServices/AdminServices/DTOs/CurrentUserDto.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Application.Core.UserServices.AdminServices.DTOs 2 | { 3 | public class CurrentUserDto 4 | { 5 | public string DisplayName { get; set; } 6 | public string UserName { get; set; } 7 | public string Role { get; set; } 8 | public string ProfilePhotoName { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/UserServices/AdminServices/DTOs/MappingProfile.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Aspian.Domain.ActivityModel; 3 | using Aspian.Domain.AttachmentModel; 4 | using Aspian.Domain.CommentModel; 5 | using Aspian.Domain.PostModel; 6 | using Aspian.Domain.SiteModel; 7 | using Aspian.Domain.TaxonomyModel; 8 | using Aspian.Domain.UserModel; 9 | using AutoMapper; 10 | 11 | namespace Aspian.Application.Core.UserServices.AdminServices.DTOs 12 | { 13 | public class MappingProfile : Profile 14 | { 15 | public MappingProfile() 16 | { 17 | CreateMap(); 18 | CreateMap(); 19 | 20 | CreateMap(); 21 | CreateMap(); 22 | 23 | CreateMap() 24 | .ForMember(d => d.Taxonomies, o => o.MapFrom(s => s.CreatedTaxonomies.Count)) 25 | .ForMember(d => d.Posts, o => o.MapFrom(s => s.CreatedPosts.Count)) 26 | .ForMember(d => d.Attachments, o => o.MapFrom(s => s.CreatedAttachments.Count)) 27 | .ForMember(d => d.Activites, o => o.MapFrom(s => s.Activities.Count)) 28 | .ForMember(d => d.Photo, o => o.MapFrom(s => s.CreatedAttachments.SingleOrDefault(x => x.Type == AttachmentTypeEnum.Photo && x.IsMain))); 29 | 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/UserServices/AdminServices/DTOs/PhotoDto.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Application.Core.UserServices.AdminServices.DTOs 2 | { 3 | public class PhotoDto 4 | { 5 | public string Type { get; set; } 6 | public string FileName { get; set; } 7 | public string FileExtension { get; set; } 8 | public string FileSize { get; set; } 9 | public string MimeType { get; set; } 10 | public string UploadLocation { get; set; } 11 | public string RelativePath { get; set; } 12 | public bool IsMain { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/UserServices/AdminServices/DTOs/RefreshTokenDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace Aspian.Application.Core.UserServices.AdminServices.DTOs 5 | { 6 | public class RefreshTokenDto 7 | { 8 | public string JWT { get; set; } 9 | [JsonIgnore] 10 | public string RefreshToken { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/UserServices/AdminServices/DTOs/UserDto.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace Aspian.Application.Core.UserServices.AdminServices.DTOs 4 | { 5 | public class UserDto 6 | { 7 | public string DisplayName { get; set; } 8 | public string Token { get; set; } 9 | public string UserName { get; set; } 10 | public string Role { get; set; } 11 | public string ProfilePhotoName { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/UserServices/AdminServices/DTOs/UserListDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Aspian.Application.Core.UserServices.AdminServices.DTOs 5 | { 6 | public class UserListDto 7 | { 8 | public string DisplayName { get; set; } 9 | public string UserName { get; set; } 10 | public string Email { get; set; } 11 | public string Role { get; set; } 12 | public PhotoDto Photo { get; set; } 13 | public DateTime CreatedAt { get; set; } 14 | public DateTime? ModifiedAt { get; set; } 15 | public string UserAgent { get; set; } 16 | public string UserIPAddress { get; set; } 17 | public DateTime? LastLoginDate { get; set; } 18 | public int Taxonomies { get; set; } 19 | public int Posts { get; set; } 20 | public int Attachments { get; set; } 21 | public int Comments { get; set; } 22 | public int Activites { get; set; } 23 | } 24 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/UserServices/AdminServices/DTOs/UserProfileDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Aspian.Application.Core.UserServices.AdminServices.DTOs 4 | { 5 | public class UserProfileDto 6 | { 7 | public string DisplayName { get; set; } 8 | public string UserName { get; set; } 9 | public string Bio { get; set; } 10 | public string Role { get; set; } 11 | public PhotoDto Photo { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/UserServices/AdminServices/List.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Aspian.Application.Core.UserServices.AdminServices.DTOs; 5 | using Aspian.Persistence; 6 | using AutoMapper; 7 | using MediatR; 8 | using Microsoft.EntityFrameworkCore; 9 | 10 | namespace Aspian.Application.Core.UserServices.AdminServices 11 | { 12 | public class List 13 | { 14 | public class Query : IRequest> { } 15 | 16 | public class Handler : IRequestHandler> 17 | { 18 | private readonly DataContext _context; 19 | private readonly IMapper _mapper; 20 | public Handler(DataContext context, IMapper mapper) 21 | { 22 | _mapper = mapper; 23 | _context = context; 24 | } 25 | 26 | public async Task> Handle(Query request, CancellationToken cancellationToken) 27 | { 28 | var users = await _context.Users.ToListAsync(); 29 | 30 | return _mapper.Map>(users); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/UserServices/AdminServices/UnlockUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.Errors; 6 | using Aspian.Application.Core.Interfaces; 7 | using Aspian.Domain.ActivityModel; 8 | using Aspian.Domain.SiteModel; 9 | using Aspian.Domain.UserModel; 10 | using Aspian.Persistence; 11 | using MediatR; 12 | using Microsoft.AspNetCore.Identity; 13 | using Microsoft.EntityFrameworkCore; 14 | 15 | namespace Aspian.Application.Core.UserServices.AdminServices 16 | { 17 | public class UnlockUser 18 | { 19 | public class Command : IRequest 20 | { 21 | public string UserName { get; set; } 22 | } 23 | 24 | public class Handler : IRequestHandler 25 | { 26 | private readonly DataContext _context; 27 | private readonly UserManager _userManager; 28 | private readonly IActivityLogger _logger; 29 | public Handler(DataContext context, UserManager userManager, IActivityLogger logger) 30 | { 31 | _logger = logger; 32 | _userManager = userManager; 33 | _context = context; 34 | } 35 | 36 | public async Task Handle(Command request, CancellationToken cancellationToken) 37 | { 38 | var site = await _context.Sites.SingleOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 39 | var user = await _userManager.FindByNameAsync(request.UserName); 40 | 41 | if (user == null) 42 | throw new RestException(HttpStatusCode.NotFound, new { User = "not found!" }); 43 | 44 | var result = await _userManager.SetLockoutEndDateAsync(user, DateTimeOffset.UtcNow.AddDays(-1)); 45 | 46 | if (result.Succeeded) 47 | { 48 | await _logger.LogActivity( 49 | site.Id, 50 | ActivityCodeEnum.UserUnlock, 51 | ActivitySeverityEnum.High, 52 | ActivityObjectEnum.User, 53 | $"The user {user.UserName} has been unlocked by Admin."); 54 | 55 | return Unit.Value; 56 | } 57 | 58 | throw new Exception("Problem saving changes!"); 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/UserServices/AdminServices/UserProfile.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Aspian.Application.Core.Interfaces; 6 | using Aspian.Application.Core.UserServices.AdminServices.DTOs; 7 | using Aspian.Domain.ActivityModel; 8 | using Aspian.Domain.AttachmentModel; 9 | using Aspian.Domain.SiteModel; 10 | using Aspian.Persistence; 11 | using AutoMapper; 12 | using MediatR; 13 | using Microsoft.EntityFrameworkCore; 14 | 15 | namespace Aspian.Application.Core.UserServices.AdminServices 16 | { 17 | public class UserProfile 18 | { 19 | public class Query : IRequest 20 | { 21 | public string UserName { get; set; } 22 | } 23 | 24 | public class Handler : IRequestHandler 25 | { 26 | private readonly DataContext _context; 27 | private readonly IMapper _mapper; 28 | private readonly IActivityLogger _logger; 29 | public Handler(DataContext context, IMapper mapper, IActivityLogger logger) 30 | { 31 | _logger = logger; 32 | _mapper = mapper; 33 | _context = context; 34 | } 35 | 36 | public async Task Handle(Query request, CancellationToken cancellationToken) 37 | { 38 | var site = await _context.Sites.FirstOrDefaultAsync(x => x.SiteType == SiteTypeEnum.Blog); 39 | var user = await _context.Users.SingleOrDefaultAsync(x => x.UserName == request.UserName); 40 | 41 | var userProfileDto = _mapper.Map(user); 42 | userProfileDto.Photo = _mapper.Map(user.CreatedAttachments.FirstOrDefault(x => x.Type == AttachmentTypeEnum.Photo && x.IsMain)); 43 | 44 | await _logger.LogActivity( 45 | site.Id, 46 | ActivityCodeEnum.UserProfile, 47 | ActivitySeverityEnum.Information, 48 | ActivityObjectEnum.User, 49 | $"A user profile with the username \"{user.UserName}\" has been reviewed."); 50 | 51 | return userProfileDto; 52 | 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Aspian.Application.Core/Validators/ValidatorExtensions.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Aspian.Application.Core.Validators 4 | { 5 | public static class ValidatorExtensions 6 | { 7 | public static IRuleBuilder Password(this IRuleBuilder ruleBuilder) 8 | { 9 | var options = ruleBuilder 10 | .NotEmpty() 11 | .MinimumLength(6).WithMessage("Password must be at least 6 characters") 12 | .Matches("[A-Z]").WithMessage("Password must contain 1 uppercase letter") 13 | .Matches("[a-z]").WithMessage("Password must have at least 1 lowercase character") 14 | .Matches("[0-9]").WithMessage("Password must contain a number") 15 | .Matches("[^a-zA-Z0-9]").WithMessage("Password must contain non alphanumeric"); 16 | 17 | return options; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Aspian.Domain/ActivityModel/Activity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.BaseModel; 4 | using Aspian.Domain.SiteModel; 5 | using Aspian.Domain.UserModel; 6 | 7 | namespace Aspian.Domain.ActivityModel 8 | { 9 | public class Activity : IActivity 10 | { 11 | public Guid Id { get; set; } 12 | public ActivityCodeEnum Code { get; set; } 13 | public ActivitySeverityEnum Severity { get; set; } 14 | public ActivityObjectEnum ObjectName { get; set; } 15 | public string Message { get; set; } 16 | public DateTime CreatedAt { get; set; } 17 | public string CreatedById { get; set; } 18 | public virtual User CreatedBy { get; set; } 19 | public string UserAgent { get; set; } 20 | public string UserIPAddress { get; set; } 21 | 22 | 23 | #region Navigation Properties 24 | public Guid SiteId { get; set; } 25 | public virtual Site Site { get; set; } 26 | #endregion 27 | } 28 | 29 | 30 | } -------------------------------------------------------------------------------- /Aspian.Domain/ActivityModel/ActivityConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 3 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 4 | 5 | namespace Aspian.Domain.ActivityModel 6 | { 7 | public class ActivityConfig : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | var activitySeverityConverter = new EnumToStringConverter(); 12 | builder 13 | .Property(a => a.Severity) 14 | .HasConversion(activitySeverityConverter); 15 | 16 | var activityObjectConverter = new EnumToStringConverter(); 17 | builder 18 | .Property(a => a.ObjectName) 19 | .HasConversion(activityObjectConverter); 20 | 21 | builder 22 | .HasOne(a => a.CreatedBy) 23 | .WithMany(u => u.Activities) 24 | .HasForeignKey(a => a.CreatedById); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Aspian.Domain/ActivityModel/IActivity.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Aspian.Domain.BaseModel; 3 | 4 | namespace Aspian.Domain.ActivityModel 5 | { 6 | public interface IActivity : IEntityBase, IEntityCreate, IEntityInfo 7 | { 8 | ActivityCodeEnum Code { get; set; } 9 | ActivitySeverityEnum Severity { get; set; } 10 | ActivityObjectEnum ObjectName { get; set; } 11 | string Message { get; set; } 12 | 13 | } 14 | 15 | public enum ActivitySeverityEnum 16 | { 17 | Information, 18 | Low, 19 | Medium, 20 | High, 21 | Critical 22 | } 23 | 24 | public enum ActivityObjectEnum 25 | { 26 | Site = 1, 27 | Option = 2, 28 | Taxonomy = 3, 29 | Post = 4, 30 | Comment = 5, 31 | Attachemnt = 6, 32 | User = 7 33 | } 34 | 35 | public enum ActivityCodeEnum 36 | { 37 | SiteList = 1002, 38 | SiteDetails = 1003, 39 | 40 | OptionList = 2002, 41 | OptionEdit = 2003, 42 | OptionRestoreDefaultOption = 2004, 43 | OptionRestoreDefaultOptions = 2005, 44 | 45 | TaxonomyCreate = 3001, 46 | TaxonomyList = 3002, 47 | TaxonomyDetails = 3003, 48 | TaxonomyEdit = 3004, 49 | TaxonomyDelete = 3005, 50 | 51 | PostCreate = 4001, 52 | PostList = 4002, 53 | PostDetails = 4003, 54 | PostEdit = 4004, 55 | PostDelete = 4005, 56 | 57 | CommentCreate = 5001, 58 | CommentList = 5002, 59 | CommentDetails = 5003, 60 | CommentEdit = 5004, 61 | CommentDelete = 5005, 62 | CommentApprove = 5006, 63 | 64 | AttachmentAdd = 6001, 65 | AttachmentDownload = 6002, 66 | AttachmentList = 6003, 67 | AttachmentGetImage = 6004, 68 | AttachmentSetMainPhoto = 6005, 69 | AttachmentDelete = 6006, 70 | 71 | UserRegister = 7001, 72 | UserLogin = 7002, 73 | UserProfile = 7003, 74 | UserCurrent = 7004, 75 | UserEditProfile = 7005, 76 | UserChangePassword = 7006, 77 | UserLockout = 7007, 78 | UserUnlock = 7008 79 | 80 | } 81 | } -------------------------------------------------------------------------------- /Aspian.Domain/Aspian.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net5.0 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Aspian.Domain/AttachmentModel/Attachment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.BaseModel; 4 | using Aspian.Domain.PostModel; 5 | using Aspian.Domain.SiteModel; 6 | using Aspian.Domain.UserModel; 7 | 8 | namespace Aspian.Domain.AttachmentModel 9 | { 10 | public class Attachment : Entitymeta, IAttachment 11 | { 12 | public AttachmentTypeEnum Type { get; set; } 13 | public string FileName { get; set; } 14 | public string PublicFileName { get; set; } 15 | public string FileExtension { get; set; } 16 | public long FileSize { get; set; } 17 | public string MimeType { get; set; } 18 | public UploadLinkAccessibilityEnum LinkAccessibility { get; set; } 19 | public UploadLocationEnum UploadLocation { get; set; } 20 | public string RelativePath { get; set; } 21 | public string ThumbnailPath { get; set; } 22 | public bool IsMain { get; set; } 23 | 24 | #region Navigation Properties 25 | public virtual ICollection PostAttachments { get; set; } 26 | public virtual ICollection Attachmentmetas { get; set; } 27 | 28 | public Guid SiteId { get; set; } 29 | public virtual Site Site { get; set; } 30 | 31 | #endregion 32 | } 33 | } -------------------------------------------------------------------------------- /Aspian.Domain/AttachmentModel/AttachmentConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 3 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 4 | 5 | namespace Aspian.Domain.AttachmentModel 6 | { 7 | public class AttachmentConfig : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | var attachmentTypeConverter = new EnumToStringConverter(); 12 | builder 13 | .Property(a => a.Type) 14 | .HasConversion(attachmentTypeConverter); 15 | 16 | var UploadLocationConverter = new EnumToStringConverter(); 17 | builder 18 | .Property(a => a.UploadLocation) 19 | .HasConversion(UploadLocationConverter); 20 | 21 | var uploadLinkAccessibilityConverter = new EnumToStringConverter(); 22 | builder 23 | .Property(a => a.LinkAccessibility) 24 | .HasConversion(uploadLinkAccessibilityConverter); 25 | 26 | builder 27 | .HasIndex(a => a.FileName) 28 | .IsUnique(); 29 | 30 | builder 31 | .HasOne(a => a.CreatedBy) 32 | .WithMany(u => u.CreatedAttachments) 33 | .HasForeignKey(a => a.CreatedById); 34 | builder 35 | .HasOne(a => a.ModifiedBy) 36 | .WithMany(u => u.ModifiedAttachments) 37 | .HasForeignKey(a => a.ModifiedById); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Aspian.Domain/AttachmentModel/Attachmentmeta.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.BaseModel; 3 | 4 | namespace Aspian.Domain.AttachmentModel 5 | { 6 | public class Attachmentmeta : Entitymeta, IAttachmentmeta 7 | { 8 | public string MetaKey { get; set; } 9 | public string MetaValue { get; set; } 10 | 11 | #region Navigation Properties 12 | public Guid AttachmentId { get; set; } 13 | public virtual Attachment Attachment { get; set; } 14 | #endregion 15 | } 16 | } -------------------------------------------------------------------------------- /Aspian.Domain/AttachmentModel/AttachmentmetaConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 3 | 4 | namespace Aspian.Domain.AttachmentModel 5 | { 6 | public class AttachmentmetaConfig : IEntityTypeConfiguration 7 | { 8 | public void Configure(EntityTypeBuilder builder) 9 | { 10 | builder 11 | .HasOne(am => am.CreatedBy) 12 | .WithMany(u => u.CreatedAttachmentmetas) 13 | .HasForeignKey(am => am.CreatedById); 14 | builder 15 | .HasOne(am => am.ModifiedBy) 16 | .WithMany(u => u.ModifiedAttachmentmetas) 17 | .HasForeignKey(am => am.ModifiedById); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Aspian.Domain/AttachmentModel/IAttachment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.BaseModel; 4 | using Aspian.Domain.PostModel; 5 | using Aspian.Domain.SiteModel; 6 | using Aspian.Domain.UserModel; 7 | 8 | namespace Aspian.Domain.AttachmentModel 9 | { 10 | public interface IAttachment : IEntitymeta 11 | { 12 | AttachmentTypeEnum Type { get; set; } 13 | string FileName { get; set; } 14 | string PublicFileName { get; set; } 15 | string FileExtension { get; set; } 16 | long FileSize { get; set; } 17 | string MimeType { get; set; } 18 | UploadLinkAccessibilityEnum LinkAccessibility { get; set; } 19 | UploadLocationEnum UploadLocation { get; set; } 20 | string RelativePath { get; set; } 21 | string ThumbnailPath { get; set; } 22 | bool IsMain { get; set; } 23 | 24 | #region Navigation Properties 25 | ICollection PostAttachments { get; set; } 26 | ICollection Attachmentmetas { get; set; } 27 | 28 | Guid SiteId { get; set; } 29 | Site Site { get; set; } 30 | #endregion 31 | } 32 | 33 | public enum AttachmentTypeEnum 34 | { 35 | Photo = 0, 36 | Video = 1, 37 | Audio = 2, 38 | PDF = 3, 39 | TextFile = 4, 40 | Compressed = 5, 41 | Other = 6 42 | } 43 | 44 | public enum UploadLocationEnum 45 | { 46 | LocalHost, 47 | FtpServer 48 | } 49 | 50 | public enum UploadLinkAccessibilityEnum 51 | { 52 | Public, 53 | Private 54 | } 55 | } -------------------------------------------------------------------------------- /Aspian.Domain/AttachmentModel/IAttachmentmeta.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.BaseModel; 3 | 4 | namespace Aspian.Domain.AttachmentModel 5 | { 6 | public interface IAttachmentmeta : IEntitymeta 7 | { 8 | string MetaKey { get; set; } 9 | string MetaValue { get; set; } 10 | 11 | #region Navigation Properties 12 | Guid AttachmentId { get; set; } 13 | Attachment Attachment { get; set; } 14 | #endregion 15 | } 16 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/EntityBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Domain.BaseModel 4 | { 5 | public class EntityBase : IEntityBase 6 | { 7 | public Guid Id { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/EntityCreate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.UserModel; 3 | 4 | namespace Aspian.Domain.BaseModel 5 | { 6 | public class EntityCreate : IEntityCreate 7 | { 8 | public DateTime CreatedAt { get; set; } 9 | public string CreatedById { get; set; } 10 | public virtual User CreatedBy { get; set; } 11 | 12 | } 13 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/EntityInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Domain.BaseModel 2 | { 3 | public class EntityInfo : IEntityInfo 4 | { 5 | public string UserAgent { get; set; } 6 | public string UserIPAddress { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/EntityModify.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.UserModel; 3 | 4 | namespace Aspian.Domain.BaseModel 5 | { 6 | public class EntityModify : IEntityModify 7 | { 8 | public DateTime? ModifiedAt { get; set; } 9 | public string ModifiedById { get; set; } 10 | public virtual User ModifiedBy { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/Entitymeta.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.UserModel; 3 | 4 | namespace Aspian.Domain.BaseModel 5 | { 6 | public class Entitymeta : IEntitymeta 7 | { 8 | public Guid Id { get; set; } 9 | public DateTime CreatedAt { get; set; } 10 | public DateTime? ModifiedAt { get; set; } 11 | public string CreatedById { get; set; } 12 | public virtual User CreatedBy { get; set; } 13 | public string ModifiedById { get; set; } 14 | public virtual User ModifiedBy { get; set; } 15 | public string UserAgent { get; set; } 16 | public string UserIPAddress { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/IEntity.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Domain.BaseModel 2 | { 3 | public interface IEntity 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/IEntityBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Aspian.Domain.BaseModel 4 | { 5 | public interface IEntityBase : IEntity 6 | { 7 | Guid Id { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/IEntityCreate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.UserModel; 3 | 4 | namespace Aspian.Domain.BaseModel 5 | { 6 | public interface IEntityCreate : IEntity, IEntityMetadata 7 | { 8 | DateTime CreatedAt { get; set; } 9 | string CreatedById { get; set; } 10 | User CreatedBy { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/IEntityInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Domain.BaseModel 2 | { 3 | public interface IEntityInfo : IEntity, IEntityMetadata 4 | { 5 | string UserAgent { get; set; } 6 | string UserIPAddress { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/IEntityMetadata.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Domain.BaseModel 2 | { 3 | public interface IEntityMetadata 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/IEntityModify.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.UserModel; 3 | 4 | namespace Aspian.Domain.BaseModel 5 | { 6 | public interface IEntityModify : IEntity, IEntityMetadata 7 | { 8 | DateTime? ModifiedAt { get; set; } 9 | string ModifiedById { get; set; } 10 | User ModifiedBy { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /Aspian.Domain/BaseModel/IEntitymeta.cs: -------------------------------------------------------------------------------- 1 | namespace Aspian.Domain.BaseModel 2 | { 3 | public interface IEntitymeta : IEntity, IEntityBase, IEntityCreate, IEntityModify, IEntityInfo, IEntityMetadata 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Aspian.Domain/CommentModel/Comment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.BaseModel; 4 | using Aspian.Domain.PostModel; 5 | using Aspian.Domain.SiteModel; 6 | 7 | namespace Aspian.Domain.CommentModel 8 | { 9 | public class Comment : Entitymeta, IComment 10 | { 11 | public string Content { get; set; } 12 | public bool Approved { get; set; } 13 | 14 | 15 | 16 | #region Navigation Properties 17 | public Guid? ParentId { get; set; } 18 | public virtual Comment Parent { get; set; } 19 | public virtual ICollection Replies { get; set; } 20 | public Guid SiteId { get; set; } 21 | public virtual Site Site { get; set; } 22 | public Guid PostId { get; set; } 23 | public virtual Post Post { get; set; } 24 | public virtual ICollection Commentmetas { get; set; } 25 | public virtual ICollection CommentHistories { get; set; } 26 | #endregion 27 | } 28 | } -------------------------------------------------------------------------------- /Aspian.Domain/CommentModel/CommentConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 3 | 4 | namespace Aspian.Domain.CommentModel 5 | { 6 | public class CommentConfig : IEntityTypeConfiguration 7 | { 8 | public void Configure(EntityTypeBuilder builder) 9 | { 10 | builder 11 | .HasOne(c => c.CreatedBy) 12 | .WithMany(u => u.CreatedComments) 13 | .HasForeignKey(c => c.CreatedById); 14 | 15 | builder 16 | .HasOne(c => c.ModifiedBy) 17 | .WithMany(u => u.ModifiedComments) 18 | .HasForeignKey(c => c.ModifiedById); 19 | 20 | builder 21 | .HasMany(c => c.Replies) 22 | .WithOne(c => c.Parent) 23 | .HasForeignKey(c => c.ParentId) 24 | .OnDelete(DeleteBehavior.NoAction); 25 | 26 | builder 27 | .HasOne(s => s.Site) 28 | .WithMany(c => c.Comments) 29 | .HasForeignKey(s => s.SiteId) 30 | .OnDelete(DeleteBehavior.ClientSetNull); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Aspian.Domain/CommentModel/CommentHistory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.BaseModel; 3 | using Aspian.Domain.UserModel; 4 | 5 | namespace Aspian.Domain.CommentModel 6 | { 7 | public class CommentHistory : EntityBase, ICommentHistory 8 | { 9 | public string LastContent { get; set; } 10 | public DateTime CreatedAt { get; set; } 11 | public string CreatedById { get; set; } 12 | public virtual User CreatedBy { get; set; } 13 | public string UserAgent { get; set; } 14 | public string UserIPAddress { get; set; } 15 | 16 | 17 | #region Navigaiotn Properties 18 | public Guid CommentId { get; set; } 19 | public virtual Comment Comment { get; set; } 20 | #endregion 21 | } 22 | } -------------------------------------------------------------------------------- /Aspian.Domain/CommentModel/CommentHistoryConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 3 | 4 | namespace Aspian.Domain.CommentModel 5 | { 6 | public class CommentHistoryConfig : IEntityTypeConfiguration 7 | { 8 | public void Configure(EntityTypeBuilder builder) 9 | { 10 | builder 11 | .HasOne(ch => ch.CreatedBy) 12 | .WithMany(u => u.CreatedCommentHistories) 13 | .HasForeignKey(ch => ch.CreatedById); 14 | 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Aspian.Domain/CommentModel/Commentmeta.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.BaseModel; 3 | 4 | namespace Aspian.Domain.CommentModel 5 | { 6 | public class Commentmeta : Entitymeta, ICommentmeta 7 | { 8 | public string Key { get; set; } 9 | public string Value { get; set; } 10 | 11 | #region Navigation Properties 12 | public Guid CommentId { get; set; } 13 | public virtual Comment Comment { get; set; } 14 | #endregion 15 | } 16 | } -------------------------------------------------------------------------------- /Aspian.Domain/CommentModel/CommentmetaConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 3 | 4 | namespace Aspian.Domain.CommentModel 5 | { 6 | public class CommentmetaConfig : IEntityTypeConfiguration 7 | { 8 | public void Configure(EntityTypeBuilder builder) 9 | { 10 | builder 11 | .HasOne(cm => cm.CreatedBy) 12 | .WithMany(u => u.CreatedCommentmetas) 13 | .HasForeignKey(cm => cm.CreatedById); 14 | 15 | builder 16 | .HasOne(cm => cm.ModifiedBy) 17 | .WithMany(u => u.ModifiedCommentmetas) 18 | .HasForeignKey(cm => cm.ModifiedById); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Aspian.Domain/CommentModel/IComment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.BaseModel; 4 | using Aspian.Domain.PostModel; 5 | using Aspian.Domain.SiteModel; 6 | 7 | namespace Aspian.Domain.CommentModel 8 | { 9 | public interface IComment : IEntitymeta 10 | { 11 | string Content { get; set; } 12 | bool Approved { get; set; } 13 | 14 | 15 | #region Navigation Properties 16 | Guid? ParentId { get; set; } 17 | Comment Parent { get; set; } 18 | ICollection Replies { get; set; } 19 | Guid SiteId { get; set; } 20 | Site Site { get; set; } 21 | Guid PostId { get; set; } 22 | Post Post { get; set; } 23 | ICollection Commentmetas { get; set; } 24 | ICollection CommentHistories { get; set; } 25 | #endregion 26 | } 27 | } -------------------------------------------------------------------------------- /Aspian.Domain/CommentModel/ICommentHistory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.BaseModel; 3 | 4 | namespace Aspian.Domain.CommentModel 5 | { 6 | public interface ICommentHistory : IEntityBase, IEntityCreate, IEntityInfo 7 | { 8 | string LastContent { get; set; } 9 | 10 | 11 | #region Navigaiotn Properties 12 | Guid CommentId { get; set; } 13 | Comment Comment { get; set; } 14 | #endregion 15 | } 16 | } -------------------------------------------------------------------------------- /Aspian.Domain/CommentModel/ICommentmeta.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Aspian.Domain.BaseModel; 3 | 4 | namespace Aspian.Domain.CommentModel 5 | { 6 | public interface ICommentmeta : IEntitymeta 7 | { 8 | string Key { get; set; } 9 | string Value { get; set; } 10 | 11 | 12 | #region Navigation Properties 13 | Guid CommentId { get; set; } 14 | Comment Comment { get; set; } 15 | #endregion 16 | } 17 | } -------------------------------------------------------------------------------- /Aspian.Domain/OptionModel/IOption.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.BaseModel; 4 | using Aspian.Domain.SiteModel; 5 | 6 | namespace Aspian.Domain.OptionModel 7 | { 8 | public interface IOption : IEntityBase 9 | { 10 | SectionEnum Section { get; set; } 11 | string Description { get; set; } 12 | 13 | 14 | #region Navigation Properties 15 | Guid SiteId { get; set; } 16 | Site Site { get; set; } 17 | ICollection Optionmetas { get; set; } 18 | #endregion 19 | } 20 | 21 | public enum SectionEnum 22 | { 23 | AdminActivity, 24 | Comment, 25 | AdminPost, 26 | AdminTaxonomy, 27 | User, 28 | AdminAttachment, 29 | AdminAttachmentFileTypes 30 | } 31 | } -------------------------------------------------------------------------------- /Aspian.Domain/OptionModel/Option.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Aspian.Domain.BaseModel; 4 | using Aspian.Domain.SiteModel; 5 | 6 | namespace Aspian.Domain.OptionModel 7 | { 8 | public class Option : EntityBase, IOption 9 | { 10 | public SectionEnum Section { get; set; } 11 | public string Description { get; set; } 12 | 13 | 14 | #region Navigation Properties 15 | public Guid SiteId { get; set; } 16 | public virtual Site Site { get; set; } 17 | public virtual ICollection Optionmetas { get; set; } 18 | #endregion 19 | } 20 | 21 | 22 | } -------------------------------------------------------------------------------- /Aspian.Domain/OptionModel/OptionConfig.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 3 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 4 | 5 | namespace Aspian.Domain.OptionModel 6 | { 7 | public class OptionConfig : IEntityTypeConfiguration