diff --git a/src/API/Features/CreateLinkCommand.cs b/src/API/Features/CreateLinkCommand.cs index 4465eba4..1da0026d 100644 --- a/src/API/Features/CreateLinkCommand.cs +++ b/src/API/Features/CreateLinkCommand.cs @@ -1,5 +1,6 @@ using Elf.Api.Data; using Elf.Api.TokenGenerator; +using Elf.Shared; using Microsoft.EntityFrameworkCore; namespace Elf.Api.Features; diff --git a/src/API/Features/EditLinkCommand.cs b/src/API/Features/EditLinkCommand.cs index b6c7729d..fe7705e8 100644 --- a/src/API/Features/EditLinkCommand.cs +++ b/src/API/Features/EditLinkCommand.cs @@ -1,4 +1,5 @@ using Elf.Api.Data; +using Elf.Shared; using Microsoft.EntityFrameworkCore; namespace Elf.Api.Features; diff --git a/src/Admin/Components/Pages/EditLinkDialog.razor b/src/Admin/Components/Pages/EditLinkDialog.razor index e8d71afe..f30691db 100644 --- a/src/Admin/Components/Pages/EditLinkDialog.razor +++ b/src/Admin/Components/Pages/EditLinkDialog.razor @@ -1,4 +1,4 @@ -@implements IDialogContentComponent +@implements IDialogContentComponent @inject HttpClient Http @inject IMessageService MessageService @@ -40,7 +40,7 @@ @code { [Parameter] - public LinkEditModel Content { get; set; } = default!; + public LinkEditModelUI Content { get; set; } = default!; [CascadingParameter] public FluentDialog Dialog { get; set; } diff --git a/src/Admin/Components/Pages/Links.razor.cs b/src/Admin/Components/Pages/Links.razor.cs index e51a55e9..8de3c655 100644 --- a/src/Admin/Components/Pages/Links.razor.cs +++ b/src/Admin/Components/Pages/Links.razor.cs @@ -168,14 +168,14 @@ private async Task New() PreventScroll = true }; - var editModel = new LinkEditModel() { IsEnabled = true, TTL = 3600 }; + var editModel = new LinkEditModelUI { IsEnabled = true, TTL = 3600 }; IDialogReference dialog = await DialogService.ShowDialogAsync(editModel, parameters); DialogResult result = await dialog.Result; if (!result.Cancelled && result.Data is not null) { - var diagResult = result.Data as LinkEditModel; + var diagResult = result.Data as LinkEditModelUI; IsBusy = true; @@ -259,7 +259,7 @@ private async Task Edit(LinkModel link) PreventScroll = true }; - var editModel = new LinkEditModel() + var editModel = new LinkEditModelUI { OriginUrl = link.OriginUrl, Note = link.Note, @@ -275,7 +275,7 @@ private async Task Edit(LinkModel link) if (!result.Cancelled && result.Data is not null) { - var diagResult = result.Data as LinkEditModel; + var diagResult = result.Data as LinkEditModelUI; IsBusy = true; diff --git a/src/Admin/Models/LinkModels.cs b/src/Admin/Models/LinkModels.cs index 3144e170..0f00dac7 100644 --- a/src/Admin/Models/LinkModels.cs +++ b/src/Admin/Models/LinkModels.cs @@ -23,34 +23,8 @@ public class LinkModel public int Hits { get; set; } } -public class LinkEditModel +public class LinkEditModelUI : LinkEditModel { - [Required] - [MinLength(1)] - [MaxLength(256)] - [DataType(DataType.Url)] - [Display(Name = "Origin Url")] - public string OriginUrl { get; set; } - - [Display(Name = "Note")] - public string Note { get; set; } - - [Display(Name = "Aka")] - [MaxLength(32)] - [RegularExpression("(?!-)([a-z0-9-]+)", - ErrorMessage = "Aka can only accept lower case English letters (a-z) and numbers (0-9) with/out hyphen (-) in middle.")] - public string AkaName { get; set; } - - [Required] - [Display(Name = "Enable")] - public bool IsEnabled { get; set; } - - [Display(Name = "TTL (seconds)")] - [Range(0, 24 * 60 * 60)] - public int TTL { get; set; } - - public string[] Tags { get; set; } - [JsonIgnore] public IEnumerable SelectedTags { get; set; } = Array.Empty(); } \ No newline at end of file diff --git a/src/API/Models/LinkEditModel.cs b/src/Elf.Shared/LinkEditModel.cs similarity index 96% rename from src/API/Models/LinkEditModel.cs rename to src/Elf.Shared/LinkEditModel.cs index c4dfb860..67524070 100644 --- a/src/API/Models/LinkEditModel.cs +++ b/src/Elf.Shared/LinkEditModel.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace Elf.Api.Models; +namespace Elf.Shared; public class LinkEditModel {