Update Models

This commit is contained in:
Tech Garage 2024-01-25 20:36:44 +03:30
parent 0dad0d1a04
commit c36204dbb9
27 changed files with 509 additions and 5 deletions

View file

@ -0,0 +1,21 @@
using SQLite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models
{
public class DataUsage
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public int UserID { get; set; }
public int RX { get; set; }
public int TX { get; set; }
public bool UserReset { get; set; }
public string? ResetNotes { get; set; }
public DateTime CreationTime { get; set; }
}
}

View file

@ -0,0 +1,22 @@
using SQLite;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models
{
public class LastKnownTraffic
{
[Key]
public int UserID { get; set; }
[DefaultValue(0)]
public int RX { get; set; }
[DefaultValue(0)]
public int TX { get; set; }
public DateTime CreationTime { get; set; }
}
}

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models.Mikrotik
{
public class DNSUpdateModel
{
public List<string> Servers { get; set; }
}
}

View file

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models.Mikrotik
{
public class IPAddressViewModel
{
public int Id { get; set; }
public string ActualInterface { get; set; }
public string Address { get; set; }
public bool Enabled { get; set; }
public bool Dynamic { get; set; }
public string Interface { get; set; }
public bool Valid { get; set; }
public string Network { get; set; }
}
}

View file

@ -0,0 +1,32 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models.Mikrotik
{
public class IPPoolViewModel
{
public int Id { get; set; }
public string Name { get; set; }
public List<string> Ranges { get; set; }
public string NextPool { get; set; }
}
public class PoolCreateModel
{
public string Name { get; set; }
public string? Next { get; set; }
public string Ranges { get; set; }
}
public class PoolUpdateModel
{
public string Id { get; set; }
public string Name { get; set; }
public string? Next { get; set; }
public string Ranges { get; set; }
}
}

View file

@ -1,6 +1,11 @@
namespace MTWireGuard.Application.Models.Mikrotik
{
public class MTIdentityViewModel
public class IdentityViewModel
{
public string Name { get; set; }
}
public class IdentityUpdateModel
{
public string Name { get; set; }
}

View file

@ -0,0 +1,33 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models.Mikrotik
{
public class SchedulerViewModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Owner { get; set; }
public DateOnly StartDate { get; set; }
public TimeSpan StartTime { get; set; }
public TimeSpan Interval { get; set; }
public List<string> Policies { get; set; }
public int RunCount { get; set; }
public DateTime NextRun { get; set; }
public string OnEvent { get; set; }
public bool Enabled { get; set; }
}
public class SchedulerCreateModel
{
public string Name { get; set; }
public DateOnly? StartDate { get; set; }
public TimeSpan? StartTime { get; set; }
public TimeSpan? Interval { get; set; }
public List<string>? Policies { get; set; }
public string? OnEvent { get; set; }
}
}

View file

@ -0,0 +1,30 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models.Mikrotik
{
public class ScriptViewModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Owner { get; set; }
public string Source { get; set; }
public DateTime LastStarted { get; set; }
public int RunCount { get; set; }
public List<string> Policies { get; set; }
public bool IsValid { get; set; }
public bool DontRequiredPermissions { get; set; }
}
public class ScriptCreateModel
{
public string Name { get; set; }
public List<string> Policies { get; set; }
public string Source { get; set; }
public bool DontRequiredPermissions { get; set; }
}
}

View file

@ -13,6 +13,12 @@ namespace MTWireGuard.Application.Models.Mikrotik
public string PublicKey { get; set; }
public DateTime? Expire { get; set; }
public int? ExpireID { get; set; }
public int RX { get; set; }
public int TX { get; set; }
public int TrafficLimit { get; set; }
public string? DNSAddress { get; set; }
public bool InheritDNS { get; set; }
public bool InheritIP { get; set; }
}
public class WGPeerViewModel
@ -31,6 +37,12 @@ namespace MTWireGuard.Application.Models.Mikrotik
public long UploadBytes { get; set; }
public bool IsDifferent { get; set; }
public string Expire { get; set; }
public int Traffic { get; set; }
public uint TrafficUsed { get; set; }
public string LastHandshake { get; set; }
public string DNSAddress { get; set; }
public bool InheritDNS { get; set; }
public bool InheritIP { get; set; }
}
public class UserCreateModel
@ -45,7 +57,11 @@ namespace MTWireGuard.Application.Models.Mikrotik
public string PublicKey { get; set; }
public string PresharedKey { get; set; }
public string PersistentKeepalive { get; set; }
public DateTime Expire { get; set; }
public DateTime? Expire { get; set; } = null;
public int Traffic { get; set; }
public string DNSAddress { get; set; }
public bool InheritDNS { get; set; }
public bool InheritIP { get; set; }
}
public class UserSyncModel
@ -69,5 +85,9 @@ namespace MTWireGuard.Application.Models.Mikrotik
public string PresharedKey { get; set; }
public int PersistentKeepalive { get; set; }
public DateTime Expire { get; set; }
public int Traffic { get; set; }
public string DNSAddress { get; set; }
public bool InheritDNS { get; set; }
public bool InheritIP { get; set; }
}
}

View file

@ -1,5 +1,14 @@
namespace MTWireGuard.Application.Models.Mikrotik
{
public class WGServerDBModel
{
public int Id { get; set; }
public string? DNSAddress { get; set; }
public bool InheritDNS { get; set; }
public bool UseIPPool { get; set; }
public int? IPPoolId { get; set; }
}
public class WGServerViewModel
{
public int Id { get; set; }
@ -10,6 +19,11 @@
public string PrivateKey { get; set; }
public string PublicKey { get; set; }
public bool Running { get; set; }
public string IPAddress { get; set; }
public string DNSAddress { get; set; }
public bool InheritDNS { get; set; }
public bool UseIPPool { get; set; }
public string IPPool { get; set; }
}
public class ServerCreateModel
@ -19,14 +33,24 @@
public string ListenPort { get; set; }
public string MTU { get; set; }
public string PrivateKey { get; set; }
public string IPAddress { get; set; }
public bool UseIPPool { get; set; }
public int IPPoolId { get; set; }
public bool InheritDNS { get; set; }
public string DNSAddress { get; set; }
}
public class ServerUpdateModel
{
public int Id { get; set; }
public string Name { get; set; }
public ushort ListenPort { get; set; }
public ushort MTU { get; set; }
public string PrivateKey { get; set; }
public ushort? ListenPort { get; set; }
public ushort? MTU { get; set; }
public string? PrivateKey { get; set; }
public string? IPAddress { get; set; }
public bool UseIPPool { get; set; }
public int? IPPoolId { get; set; }
public bool InheritDNS { get; set; }
public string? DNSAddress { get; set; }
}
}

View file

@ -0,0 +1,14 @@
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
namespace MTWireGuard.Application.Models.Requests
{
public class ChangeStateRequest
{
[FromRoute(Name = "id"), Required]
public int Id { get; set; }
[FromBody, Required]
public bool Enabled { get; set; }
}
}

View file

@ -0,0 +1,22 @@
namespace MTWireGuard.Application.Models.Requests
{
public class CreateClientRequest
{
public string Name { get; set; }
public string? Endpoint { get; set; }
public ushort? EndpointPort { get; set; }
public string? AllowedAddress { get; set; }
public string? PresharedKey { get; set; }
public string PrivateKey { get; set; }
public string PublicKey { get; set; }
public string Interface { get; set; }
public int? KeepAlive { get; set; }
public bool Enabled { get; set; }
public string? Expire { get; set; }
public string? Password { get; set; }
public int? Traffic { get; set; }
public bool InheritIP { get; set; }
public bool InheritDNS { get; set; }
public string? DNSAddress { get; set; }
}
}

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models.Requests
{
public class CreatePoolRequest
{
public string Name { get; set; }
public string? Next { get; set; }
public List<string> Ranges { get; set; }
}
}

View file

@ -0,0 +1,10 @@
namespace MTWireGuard.Application.Models.Requests
{
public class CreateScriptRequest
{
public string Name { get; set; }
public List<string> Policy { get; set; }
public string Source { get; set; }
public bool DontRequiredPermissions { get; set; }
}
}

View file

@ -0,0 +1,25 @@
namespace MTWireGuard.Application.Models.Requests
{
public class CreateServerRequest
{
public string Name { get; set; }
public ushort Port { get; set; } = 13231;
public ushort MTU { get; set; } = 1420;
public string PrivateKey { get; set; }
public bool Enabled { get; set; }
public string IPAddress { get; set; }
public bool UseIPPool { get; set; }
public int IPPoolId { get; set; }
public bool InheritDNS { get; set; }
public string DNSAddress { get; set; }
}
}

View file

@ -0,0 +1,7 @@
namespace MTWireGuard.Application.Models.Requests
{
public class DeleteRequest
{
public int Id { get; set; }
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models.Requests
{
public class LoginRequest
{
public string Username { get; set; }
public string Password { get; set; }
}
}

View file

@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
namespace MTWireGuard.Application.Models.Requests
{
public class SyncUserRequest
{
[FromRoute(Name = "id"), Required]
public int ID { get; set; }
[Required(ErrorMessage = "Username is required.")]
public string Name { get; set; }
[Required(ErrorMessage = "Password is required.")]
public string Password { get; set; }
[Required(ErrorMessage = "PrivateKey is required.")]
public string PrivateKey { get; set; }
[Required(ErrorMessage = "PublicKey is required.")]
public string PublicKey { get; set; }
}
}

View file

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
namespace MTWireGuard.Application.Models.Requests
{
public class UpdateClientRequest
{
[FromRoute(Name = "id"), Required]
public int ID { get; set; }
public string? Name { get; set; }
public string? Endpoint { get; set; }
public ushort? EndpointPort { get; set; }
public string? AllowedAddress { get; set; }
public string? PresharedKey { get; set; }
public string? PrivateKey { get; set; }
public string? PublicKey { get; set; }
public string Interface { get; set; }
public int? KeepAlive { get; set; }
public string? Expire { get; set; }
public string? Password { get; set; }
public int? Traffic { get; set; }
public bool InheritIP { get; set; }
public bool InheritDNS { get; set; }
public string? DNSAddress { get; set; }
}
}

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models.Requests
{
public class UpdateDNSRequest
{
public List<string> Servers { get; set; }
}
}

View file

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models.Requests
{
public class UpdateIPPoolRequest
{
public int Id { get; set; }
public string Name { get; set; }
public string? Next { get; set; }
public List<string> Ranges { get; set; }
}
}

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models.Requests
{
public class UpdateIdentityRequest
{
public string Name { get; set; }
}
}

View file

@ -0,0 +1,25 @@
namespace MTWireGuard.Application.Models.Requests
{
public class UpdateServerRequest
{
public int Id { get; set; }
public string Name { get; set; }
public ushort? Port { get; set; }
public ushort? MTU { get; set; }
public string? PrivateKey { get; set; }
public string? IPAddress { get; set; }
public bool UseIPPool { get; set; }
public int? IPPoolId { get; set; }
public bool InheritDNS { get; set; }
public string? DNSAddress { get; set; }
}
}

View file

@ -0,0 +1,9 @@
namespace MTWireGuard.Application.Models.Models.Responses
{
public class ToastMessage
{
public string Title { get; set; }
public string Body { get; set; }
public string Background { get; set; }
}
}

View file

@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
namespace MTWireGuard.Application.Models.Models.Responses
{
public class ToastResult : IActionResult
{
private readonly ToastMessage _result;
public ToastResult(ToastMessage message)
{
_result = message;
}
public async Task ExecuteResultAsync(ActionContext context)
{
var objectResult = new ObjectResult(_result);
await objectResult.ExecuteResultAsync(context);
}
}
}

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models
{
public class UsageObject
{
public string Id { get; set; }
public int RX { get; set; }
public int TX { get; set; }
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTWireGuard.Application.Models
{
public class UserActivityUpdate
{
public int Id { get; set; }
public string LastHandshake { get; set; }
}
}