Archived
Added first app template
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace app.Model
|
||||
{
|
||||
public enum AuthRoles
|
||||
{
|
||||
Normal = 0,
|
||||
Admin = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using app.Model.DTOs;
|
||||
|
||||
namespace app.Model
|
||||
{
|
||||
public class AuthUser : IAutoGenerateDateFields
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string EMail { get; set; }
|
||||
public string Password { get; set; }
|
||||
public AuthRoles AuthRole { get; set; }
|
||||
public string RefreshToken { get; set; }
|
||||
public string ConfirmationId { get; set; }
|
||||
public string ForgotPasswordId { get; set; }
|
||||
public DateTime RefreshTokenExpiryTime { get; set; }
|
||||
public DateTimeOffset CreatedOn { get; set; }
|
||||
public DateTimeOffset LastModifiedOn { get; set; }
|
||||
|
||||
public AuthUserDTO ToAuthUserDTO()
|
||||
{
|
||||
return new AuthUserDTO
|
||||
{
|
||||
Id = this.Id,
|
||||
FirstName = this.FirstName,
|
||||
LastName = this.LastName,
|
||||
EMail = this.EMail,
|
||||
IsConfirmed = this.ConfirmationId == null,
|
||||
AuthRole = this.AuthRole
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace app.Model.DTOs
|
||||
{
|
||||
public class AdminUpdateUserDTO
|
||||
{
|
||||
public AuthUserDTO AuthUserDTO { get; set; }
|
||||
public AuthUserDTO NewAuthUserDTO { get; set; }
|
||||
public bool ChangePassword { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace app.Model.DTOs
|
||||
{
|
||||
public class ApiVersionDTO
|
||||
{
|
||||
public string Major { get; set; }
|
||||
public string Minor { get; set; }
|
||||
public string Micro { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace app.Model.DTOs
|
||||
{
|
||||
public class AuthUserDTO
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string EMail { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool IsConfirmed { get; set; }
|
||||
public AuthRoles AuthRole { get; set; }
|
||||
|
||||
public AuthUser ToAuthUser()
|
||||
{
|
||||
return new AuthUser
|
||||
{
|
||||
Id = this.Id,
|
||||
FirstName = this.FirstName,
|
||||
LastName = this.LastName,
|
||||
EMail = this.EMail,
|
||||
Password = this.Password,
|
||||
AuthRole = this.AuthRole
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace app.Model.DTOs
|
||||
{
|
||||
public class EMailStringDTO
|
||||
{
|
||||
public string EMail { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace app.Model.DTOs
|
||||
{
|
||||
public class GetFilteredAuthUsersResultDTO
|
||||
{
|
||||
public List<AuthUserDTO> Users { get; set; }
|
||||
public int TotalCount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace app.Model.DTOs
|
||||
{
|
||||
public class ResetPasswordDTO
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace app.Model.DTOs
|
||||
{
|
||||
public class SettingsDTO
|
||||
{
|
||||
public string WebVersion { get; set; }
|
||||
public string ApiVersion { get; set; }
|
||||
public string ConfigPath { get; set; }
|
||||
public string WebBaseURL { get; set; }
|
||||
public string ApiBaseURL { get; set; }
|
||||
|
||||
public int TokenExpireTime { get; set; }
|
||||
public int RefreshTokenExpireTime { get; set; }
|
||||
|
||||
public string MailUser { get; set; }
|
||||
public int MailPort { get; set; }
|
||||
public string MailHost { get; set; }
|
||||
public string MailTransceiver { get; set; }
|
||||
public string MailTransceiverAddress { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace app.Model.DTOs
|
||||
{
|
||||
public class TokenDTO
|
||||
{
|
||||
public string Token { get; set; }
|
||||
public string RefreshToken { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace app.Model.DTOs
|
||||
{
|
||||
public class UpdateUserDTO
|
||||
{
|
||||
public AuthUserDTO AuthUserDTO { get; set; }
|
||||
public AuthUserDTO NewAuthUserDTO { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace app.Model.DTOs
|
||||
{
|
||||
public abstract class UserDTO
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool NotifyWhenLogin { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace app.Model.Filters
|
||||
{
|
||||
public enum ErrorType {
|
||||
ValidationError,
|
||||
Exception
|
||||
}
|
||||
|
||||
public class ErrorDto {
|
||||
public ServiceErrorCode ErrorCode { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public ErrorDto(string message)
|
||||
: this(ServiceErrorCode.Unknown, message) {
|
||||
}
|
||||
|
||||
public ErrorDto(ServiceErrorCode errorCode, string message) {
|
||||
Message = message;
|
||||
ErrorCode = errorCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Threading;
|
||||
namespace app.Model.Filters
|
||||
{
|
||||
public enum ServiceErrorCode
|
||||
{
|
||||
Unknown = 0,
|
||||
|
||||
InvalidDependencies = 1,
|
||||
InvalidData = 2,
|
||||
NotFound = 3,
|
||||
DataAlreadyExists = 4,
|
||||
UnableToAdd = 5,
|
||||
UnableToDelete = 6,
|
||||
|
||||
InvalidUser = 7,
|
||||
|
||||
ConnectionFailed = 8,
|
||||
Timeout = 9,
|
||||
MailError = 10
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace app.Model.Filters
|
||||
{
|
||||
public class ServiceException: Exception {
|
||||
public ServiceErrorCode ErrorCode { get; set; }
|
||||
public string ErrorMessage { get; set; }
|
||||
public string Nameof { get; set; }
|
||||
|
||||
|
||||
public ServiceException(ServiceErrorCode errorCode, string errorMessage) {
|
||||
ErrorCode = errorCode;
|
||||
ErrorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public string GetMessage() {
|
||||
return ErrorMessage;
|
||||
}
|
||||
public string GetDetailedMessage() {
|
||||
return $"{nameof(ServiceException)} - ErrorCode: {ErrorCode} - ErrorMessage: {ErrorMessage}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace app.Model {
|
||||
public interface IAutoGenerateDateFields {
|
||||
DateTimeOffset CreatedOn { get; set; }
|
||||
DateTimeOffset LastModifiedOn { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NLog" Version="4.7.13"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user