fix: sonarqube code smell

This commit is contained in:
Jean Gatto
2024-03-01 07:54:44 -03:00
parent 1c8cf9918d
commit 00b225d015
2 changed files with 4 additions and 2 deletions
@@ -1,3 +1,4 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Ardalis.Result;
@@ -38,7 +39,7 @@ public class UpdateCustomerCommandHandler(
// Instantiating the Email value object.
var emailResult = Email.Create(request.Email);
if (!emailResult.IsSuccess)
return Result.Error([.. emailResult.Errors]);
return Result.Error(emailResult.Errors.ToArray());
// Checking if there is already a customer with the email address.
if (await _repository.ExistsByEmailAsync(emailResult.Value, customer.Id))
+2 -1
View File
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using Ardalis.Result;
using Shop.Domain.Entities.CustomerAggregate;
using Shop.Domain.ValueObjects;
@@ -16,7 +17,7 @@ public static class CustomerFactory
{
var emailResult = Email.Create(email);
return !emailResult.IsSuccess
? Result<Customer>.Error([.. emailResult.Errors])
? Result<Customer>.Error(emailResult.Errors.ToArray())
: Result<Customer>.Success(new Customer(firstName, lastName, gender, emailResult.Value, dateOfBirth));
}