Implemented domain order. Fixed some bugs
This commit is contained in:
15
Moonlight/App/Models/Forms/DomainOrderDataModel.cs
Normal file
15
Moonlight/App/Models/Forms/DomainOrderDataModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Moonlight.App.Database.Entities;
|
||||
|
||||
namespace Moonlight.App.Models.Forms;
|
||||
|
||||
public class DomainOrderDataModel
|
||||
{
|
||||
[Required(ErrorMessage = "You need to specify a name")]
|
||||
[MaxLength(32, ErrorMessage = "The max lenght for the name is 32 characters")]
|
||||
[RegularExpression(@"^[a-z]+$", ErrorMessage = "The name should only consist of lower case characters")]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
[Required(ErrorMessage = "You need to specify a shared domain")]
|
||||
public SharedDomain SharedDomain { get; set; }
|
||||
}
|
||||
@@ -48,6 +48,28 @@ public class DomainService
|
||||
);
|
||||
}
|
||||
|
||||
public Task<Domain> Create(string domain, SharedDomain sharedDomain, User user)
|
||||
{
|
||||
if (DomainRepository.Get().Where(x => x.SharedDomain.Id == sharedDomain.Id).Any(x => x.Name == domain))
|
||||
throw new DisplayException("A domain with this name does already exist for this shared domain");
|
||||
|
||||
var res = DomainRepository.Add(new()
|
||||
{
|
||||
Name = domain,
|
||||
SharedDomain = sharedDomain,
|
||||
Owner = user
|
||||
});
|
||||
|
||||
return Task.FromResult(res);
|
||||
}
|
||||
|
||||
public Task Delete(Domain domain)
|
||||
{
|
||||
DomainRepository.Delete(domain);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task<Zone[]>
|
||||
GetAvailableDomains() // This method returns all available domains which are not added as a shared domain
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user