diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/ApiModels/RequestReferences/CompanyReference.cs b/src/backend/api/Fusion.Resources.Api/Controllers/ApiModels/RequestReferences/CompanyReference.cs deleted file mode 100644 index 80131b2a5..000000000 --- a/src/backend/api/Fusion.Resources.Api/Controllers/ApiModels/RequestReferences/CompanyReference.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace Fusion.Resources.Api.Controllers -{ - public class CompanyReference - { - public Guid Id { get; set; } - public string? Identifier { get; set; } - } -} diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Contracts/ContractsController.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Contracts/ContractsController.cs deleted file mode 100644 index efc5a61f9..000000000 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Contracts/ContractsController.cs +++ /dev/null @@ -1,106 +0,0 @@ -using Fusion.Integration; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using System; -using System.Net.Http; -using Microsoft.AspNetCore.Http; - -namespace Fusion.Resources.Api.Controllers -{ - [Authorize] - [ApiController] - public class ContractsController : ResourceControllerBase - { - - [Obsolete] - [HttpGet("/projects/{projectIdentifier}/contracts")] - public ActionResult GetProjectAllocatedContract([FromRoute]PathProjectIdentifier projectIdentifier) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpGet("/projects/{projectIdentifier}/contracts/{contractId}")] - public ActionResult GetProjectContract([FromRoute]PathProjectIdentifier projectIdentifier, Guid contractId) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpGet("/projects/{projectIdentifier}/available-contracts")] - public ActionResult GetProjectAvailableContracts( - [FromRoute]PathProjectIdentifier projectIdentifier, - [FromServices] IHttpClientFactory httpClientFactory, - [FromServices] IFusionContextResolver contextResolver) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPost("/projects/{projectIdentifier}/contracts")] - public ActionResult AllocateProjectContract([FromRoute]PathProjectIdentifier projectIdentifier, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPut("/projects/{projectIdentifier}/contracts/{contractIdentifier}")] - public ActionResult UpdateProjectContract([FromRoute]PathProjectIdentifier projectIdentifier, Guid contractIdentifier, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPut("/projects/{projectIdentifier}/contracts/{contractIdentifier}/external-company-representative")] - public ActionResult EnsureContractExternalCompanyRep([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPut("/projects/{projectIdentifier}/contracts/{contractIdentifier}/external-contract-responsible")] - public ActionResult EnsureContractExternalContractResp([FromRoute]PathProjectIdentifier projectIdentifier, Guid contractIdentifier, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - #region Role delegation - - [Obsolete] - [HttpGet("/projects/{projectIdentifier}/contracts/{contractIdentifier}/delegated-roles")] - public ActionResult GetContractDelegatedRoles([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPost("/projects/{projectIdentifier}/contracts/{contractIdentifier}/delegated-roles")] - public ActionResult CreateContractDelegatedRole([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpDelete("/projects/{projectIdentifier}/contracts/{contractIdentifier}/delegated-roles/{roleId}")] - public ActionResult DeleteContractDelegatedRole([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid roleId) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPatch("/projects/{projectIdentifier}/contracts/{contractIdentifier}/delegated-roles/{roleId}")] - public ActionResult UpdateContractDelegatedRole([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid roleId, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpOptions("/projects/{projectIdentifier}/contracts/{contractIdentifier}/delegated-roles")] - public ActionResult CheckContractDelegationAccess([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, [FromQuery] string classification) - { - return StatusCode(StatusCodes.Status410Gone); - } - - #endregion - } -} diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Extensions/ContextResolverExtensions.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Extensions/ContextResolverExtensions.cs deleted file mode 100644 index b2309e7cd..000000000 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Extensions/ContextResolverExtensions.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace Fusion.Integration -{ - public static class ContextResolverExtensions - { - public static async Task ResolveProjectMasterAsync(this IFusionContextResolver contextResolver, Resources.Api.Controllers.PathProjectIdentifier identifier) - { - var context = await contextResolver.ResolveContextAsync(ContextIdentifier.FromExternalId(identifier.ProjectId), FusionContextType.OrgChart); - - if (context == null) - throw new ProjectMasterNotFoundError(identifier); - - var projectMasterContext = await contextResolver.RelationsFirstOrDefaultAsync(context, FusionContextType.ProjectMaster); - - if (projectMasterContext == null) - throw new ProjectMasterNotFoundError(identifier); - - return projectMasterContext; - } - - public class ProjectMasterNotFoundError : Exception - { - public ProjectMasterNotFoundError(Resources.Api.Controllers.PathProjectIdentifier projectIdentifier) : - base($"Unable to find project master for '{projectIdentifier.Name} ({projectIdentifier.OriginalIdentifier})'") - { - } - } - } -} diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Mpp/MppController.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Mpp/MppController.cs deleted file mode 100644 index 710cac855..000000000 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Mpp/MppController.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using System; -using Microsoft.AspNetCore.Http; - -namespace Fusion.Resources.Api.Controllers.Mpp -{ - [Authorize] - [ApiController] - public class MppController : ResourceControllerBase - { - [Obsolete] - [HttpDelete("/projects/{projectIdentifier}/contracts/{contractIdentifier}/mpp/positions/{positionId}")] - public ActionResult DeleteContractPosition([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid positionId) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpOptions("/projects/{projectIdentifier}/contracts/{contractIdentifier}/mpp/positions")] - public ActionResult CheckDeleteAccess([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier) - { - return StatusCode(StatusCodes.Status410Gone); - } - } -} diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/ApiModels/ApiAccountStatus.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/ApiModels/ApiAccountStatus.cs deleted file mode 100644 index 4fb050bcc..000000000 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/ApiModels/ApiAccountStatus.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Fusion.Resources.Api.Controllers -{ - public enum ApiAccountStatus { Available, InviteSent, NoAccount } -} diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/ApiModels/ApiPersonnelDiscipline.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/ApiModels/ApiPersonnelDiscipline.cs deleted file mode 100644 index f7c3ff40c..000000000 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/ApiModels/ApiPersonnelDiscipline.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Fusion.Resources.Domain; - -namespace Fusion.Resources.Api.Controllers -{ - public class ApiPersonnelDiscipline - { - public ApiPersonnelDiscipline(string discipline) - { - Name = discipline; - } - public ApiPersonnelDiscipline(QueryPersonnelDiscipline discipline) - { - Name = discipline.Name; - } - - public string Name { get; set; } - } - - -} diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/PersonnelController.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/PersonnelController.cs deleted file mode 100644 index 41b272f75..000000000 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/PersonnelController.cs +++ /dev/null @@ -1,106 +0,0 @@ -using Fusion.AspNetCore.OData; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using System; -using System.Collections.Generic; -using Microsoft.AspNetCore.Http; - -namespace Fusion.Resources.Api.Controllers -{ - - [Authorize] - [ApiController] - public class PersonnelController : ResourceControllerBase - { - [Obsolete] - [HttpGet("resources/personnel")] - public ActionResult GetPersonnel([FromQuery] ODataQueryParams query) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpGet("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/personnel")] - public ActionResult GetContractPersonnel([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, [FromQuery] ODataQueryParams query) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpGet("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/personnel/{personIdentifier}")] - public ActionResult GetContractPersonnel([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, string personIdentifier) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPost("resources/personnel/{personIdentifier}/refresh")] - public ActionResult RefreshPersonnel(string personIdentifier) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPost("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/personnel")] - public ActionResult CreateContractPersonnel([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPost("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/personnel-collection")] - public ActionResult CreateContractPersonnelBatch([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, [FromBody] IEnumerable requests) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPost("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/personnel/refresh")] - public ActionResult RefreshContractPersonnel([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPut("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/personnel/{personIdentifier}")] - public ActionResult UpdateContractPersonnel([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, string personIdentifier, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpDelete("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/personnel/{personIdentifier}")] - public ActionResult DeleteContractPersonnel([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, string personIdentifier) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPut("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/personnel/preferred-contact")] - public ActionResult UpdatePersonnelPreferredContactMails([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpOptions("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/personnel/preferred-contact")] - public ActionResult CheckContractorMailValid([FromQuery] string mail) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpOptions("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/personnel/{personIdentifier}/replace")] - public ActionResult CheckReplaceContractPersonnelAccess([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, string personIdentifier) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPost("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/personnel/{personIdentifier}/replace")] - public ActionResult ReplaceContractPersonnel([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, string personIdentifier, [FromBody] object request, [FromQuery] bool force) - { - return StatusCode(StatusCodes.Status410Gone); - } - } -} diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/Requests/PersonnelDisciplineEntity.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/Requests/PersonnelDisciplineEntity.cs deleted file mode 100644 index 778202d93..000000000 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Personnel/Requests/PersonnelDisciplineEntity.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Fusion.Resources.Api.Controllers -{ - public class PersonnelDisciplineEntity - { - public string Name { get; set; } = null!; - } -} diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Requests/RequestsController.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Requests/RequestsController.cs deleted file mode 100644 index ce3c7a8e2..000000000 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Requests/RequestsController.cs +++ /dev/null @@ -1,144 +0,0 @@ -using Fusion.AspNetCore.OData; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using System; -using Microsoft.AspNetCore.Http; - -namespace Fusion.Resources.Api.Controllers -{ - [Authorize] - [ApiController] - public class RequestsController : ResourceControllerBase - { - /// - /// - /// OData: - /// $expand = originalPosition - /// - /// - /// - /// - /// - /// - [Obsolete] - [HttpGet("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests")] - public ActionResult GetContractRequests([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, [FromQuery] ODataQueryParams query) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpGet("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests/{requestId}")] - public ActionResult GetContractRequestById([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId, [FromQuery] ODataQueryParams query) - { - return StatusCode(StatusCodes.Status410Gone); - } - - - /// - /// - /// - /// Validations: - /// - Only one change request for a specific position can be active at the same time. - /// -> Bad Request, Invalid operation. - /// - /// - The original position id has to be a valid position. - /// -> Bad Request - /// - /// - /// - /// - /// - [Obsolete] - [HttpPost("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests")] - public ActionResult CreatePersonnelRequest([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPut("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests/{requestId}")] - public ActionResult UpdatePersonnelRequest([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPost("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests/{requestId}/approve")] - public ActionResult ApproveContractorPersonnelRequest([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPost("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests/{requestId}/reject")] - public ActionResult RejectContractorPersonnelRequest([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId, [FromBody] object request) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [HttpDelete("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests/{requestId}")] - public ActionResult DeleteContractorRequestById([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPost("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests/{requestId}/provision")] - public ActionResult ProvisionContractorRequest([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId) - { - return StatusCode(StatusCodes.Status410Gone); - } - - #region Comments - - [Obsolete] - [HttpPost("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests/{requestId}/comments")] - public ActionResult AddRequestComment([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId, [FromBody] RequestCommentRequest create) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpPut("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests/{requestId}/comments/{commentId}")] - public ActionResult UpdateRequestComment( - [FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId, Guid commentId, [FromBody] RequestCommentRequest update) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpDelete("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests/{requestId}/comments/{commentId}")] - public ActionResult DeleteRequestComment([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId, Guid commentId) - { - return StatusCode(StatusCodes.Status410Gone); - } - - #endregion Comments - - #region Options - - [Obsolete] - [HttpOptions("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests")] - public ActionResult CheckAccessCreateRequests([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpOptions("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests/{requestId}")] - public ActionResult CheckAccessUpdateRequest([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId) - { - return StatusCode(StatusCodes.Status410Gone); - } - - [Obsolete] - [HttpOptions("/projects/{projectIdentifier}/contracts/{contractIdentifier}/resources/requests/{requestId}/actions/{actionName}")] - public ActionResult CheckAccessRequestAction([FromRoute] PathProjectIdentifier projectIdentifier, Guid contractIdentifier, Guid requestId, string actionName) - { - return StatusCode(StatusCodes.Status410Gone); - } - - #endregion - } -} diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Validation/CustomValidatorExtensions.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Validation/CustomValidatorExtensions.cs index e7924f9ed..5a9c94398 100644 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Validation/CustomValidatorExtensions.cs +++ b/src/backend/api/Fusion.Resources.Api/Controllers/Validation/CustomValidatorExtensions.cs @@ -11,24 +11,6 @@ namespace Fusion.Resources.Api.Controllers public static class CustomValidatorExtensions { - public static IRuleBuilderOptionsConditions BeValidPerson(this IRuleBuilder ruleBuilder) - { - return ruleBuilder.Custom((person, context) => - { - if (person != null) - { - if (person.AzureUniquePersonId.HasValue && person.AzureUniquePersonId == Guid.Empty) - context.AddFailure(new ValidationFailure($"{context.JsPropertyName()}.azureUniqueId", "Person unique object id cannot be empty-guid when provided.")); - - if (!string.IsNullOrEmpty(person.Mail) && !ValidationHelper.IsValidEmail(person.Mail)) - context.AddFailure(new ValidationFailure($"{context.JsPropertyName()}.mail", "Invalid mail address", person.Mail)); - - if (person.AzureUniquePersonId is null && string.IsNullOrEmpty(person.Mail)) - context.AddFailure(new ValidationFailure(context.JsPropertyName(), "Either azureUniqueId or mail must be specified")); - } - }); - } - public static IRuleBuilderOptions BeValidBasePosition(this IRuleBuilder ruleBuilder, IProjectOrgResolver projectOrgResolver) { var result = ruleBuilder.CustomAsync(async (bpref, context, ct) => @@ -75,29 +57,6 @@ public static IRuleBuilderOptions BeValidBasePosition< return (IRuleBuilderOptions)result; } - public static IRuleBuilderOptions BeExistingCompanyPositionId(this IRuleBuilder ruleBuilder, IProjectOrgResolver projectOrgResolver) - { - var result = ruleBuilder.CustomAsync(async (positionId, context, ct) => - { - if (positionId.HasValue) - { - var position = await projectOrgResolver.ResolvePositionAsync(positionId.Value); - - if (position == null) - { - context.AddFailure(new ValidationFailure($"{context.JsPropertyName()}", $"Position with id '{positionId}' does not exist in org service.")); - } - - if (position != null && position.ContractId != null) - { - context.AddFailure(new ValidationFailure($"{context.JsPropertyName()}", $"Position with id '{positionId}' exisits, but belongs to contract {position.Contract?.ContractNumber}.")); - } - } - }); - - return (IRuleBuilderOptions)result; - } - public static IRuleBuilderOptionsConditions?> BeValidProposedChanges(this IRuleBuilder?> ruleBuilder) { return ruleBuilder.Custom((prop, context) => @@ -156,15 +115,5 @@ public static string ToLowerFirstChar(this string input) public static string JsPropertyName(this ValidationContext context) => context.PropertyName.ToLowerFirstChar(); - - /// - /// The preferred contact mail should try to weed out main private mail domains. - /// - public static IRuleBuilderOptions NotHaveInvalidMailDomain(this IRuleBuilder ruleBuilder) - { - - return ruleBuilder.SetValidator(new EmailDomainValidator()) - .WithMessage("Mail domain should not be private. Most major private mail domains are rejected (gmail, hotmail, icloud etc.)"); - } } } diff --git a/src/backend/api/Fusion.Resources.Api/Controllers/Validation/EmailDomainValidator.cs b/src/backend/api/Fusion.Resources.Api/Controllers/Validation/EmailDomainValidator.cs deleted file mode 100644 index 06ee90243..000000000 --- a/src/backend/api/Fusion.Resources.Api/Controllers/Validation/EmailDomainValidator.cs +++ /dev/null @@ -1,50 +0,0 @@ -using FluentValidation; -using FluentValidation.Validators; -using System; -using System.Linq; - -namespace Fusion.Resources.Api.Controllers -{ - /// - /// Validator for invalid mail domains for preferred contact mails. - /// This is an attempt to weed out most of the private mail addresses to try and force usage of company mails only. - /// As we cannot cover all domains this is only a best effort (or maybe just 'an attempt' :p) approach. - /// - public class EmailDomainValidator : PropertyValidator - { - private static string[] InvalidDomains = new[] - { - "gmail.com", - "hotmail.com", - "aol.com", - "ymail.com", - "yahoo.no", - "yahoo.com", - "outlook.com", - "zohomail.eu", - "mail.com", - "protonmail.com", - "icloud.com", - "gmx.com", - "gmx.us", - "yandex.com" - }; - - public override string Name => "EmailDomainValidator"; - - public override bool IsValid(ValidationContext context, string? value) - { - if (!string.IsNullOrEmpty(value) && value.Contains("@")) - { - var domain = value.Split("@").Last(); - if (InvalidDomains.Contains(domain, StringComparer.OrdinalIgnoreCase)) - return false; - } - - return true; - } - } - - - -}