From f7475da15aeffc04434036a92fc41f61336faba3 Mon Sep 17 00:00:00 2001 From: Hafiz Adewuyi Date: Thu, 15 Aug 2024 23:11:34 +0300 Subject: [PATCH] Use the CreateDto in all POST/PUT requests to avoid validation problems. (#92) --- Application/Validation/CreateSuggestedNameValidator.cs | 2 -- Application/Validation/GeoLocationValidator.cs | 9 ++------- Core/Dto/Request/CreateSuggestedNameDto.cs | 9 +++------ Core/Dto/Request/NameDto.cs | 10 ++++------ 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Application/Validation/CreateSuggestedNameValidator.cs b/Application/Validation/CreateSuggestedNameValidator.cs index 6c52f1d..2b44837 100644 --- a/Application/Validation/CreateSuggestedNameValidator.cs +++ b/Application/Validation/CreateSuggestedNameValidator.cs @@ -1,6 +1,4 @@ using Core.Dto.Request; -using Core.Dto.Response; -using Core.Enums; using FluentValidation; namespace Application.Validation diff --git a/Application/Validation/GeoLocationValidator.cs b/Application/Validation/GeoLocationValidator.cs index 1a002b1..233e46e 100644 --- a/Application/Validation/GeoLocationValidator.cs +++ b/Application/Validation/GeoLocationValidator.cs @@ -1,15 +1,10 @@ -using Core.Dto.Response; +using Core.Dto.Request; using Core.Repositories; using FluentValidation; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Application.Validation { - public class GeoLocationValidator : AbstractValidator + public class GeoLocationValidator : AbstractValidator { private readonly IGeoLocationsRepository _geoLocationsRepository; diff --git a/Core/Dto/Request/CreateSuggestedNameDto.cs b/Core/Dto/Request/CreateSuggestedNameDto.cs index 4d9b021..de0cb9c 100644 --- a/Core/Dto/Request/CreateSuggestedNameDto.cs +++ b/Core/Dto/Request/CreateSuggestedNameDto.cs @@ -1,17 +1,14 @@ - -using Core.Dto.Response; - -namespace Core.Dto.Request; +namespace Core.Dto.Request; public record CreateSuggestedNameDto { public string Name { get; init; } public string Details { get; init; } public string Email { get; init; } - public List GeoLocation { get; set; } + public List GeoLocation { get; set; } public CreateSuggestedNameDto() { - GeoLocation = new List(); + GeoLocation = new List(); } } diff --git a/Core/Dto/Request/NameDto.cs b/Core/Dto/Request/NameDto.cs index 6df72c4..beb674e 100644 --- a/Core/Dto/Request/NameDto.cs +++ b/Core/Dto/Request/NameDto.cs @@ -1,6 +1,4 @@ -using Core.Dto.Response; -using Core.Enums; -using System.ComponentModel.DataAnnotations; +using Core.Enums; namespace Core.Dto.Request { @@ -14,7 +12,7 @@ public abstract class NameDto public State? State { get; set; } public List Etymology { get; set; } public List Videos { get; set; } - public List GeoLocation { get; set; } + public List GeoLocation { get; set; } public CommaSeparatedString? FamousPeople { get; set; } @@ -34,14 +32,14 @@ public NameDto(string name, string meaning) Meaning = meaning ?? throw new ArgumentNullException(nameof(meaning)); Etymology = new List(); Videos = new List(); - GeoLocation = new List(); + GeoLocation = new List(); } public NameDto() { Etymology = new List(); Videos = new List(); - GeoLocation = new List(); + GeoLocation = new List(); } } }