Retructured solution
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
namespace LiteCharms.Features.Customers.Commands;
|
||||
|
||||
public class UpdateCustomerCommand : IRequest<Result>
|
||||
{
|
||||
public Guid CustomerId { get; set; }
|
||||
|
||||
public string? Company { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
|
||||
public string? LastName { get; set; }
|
||||
|
||||
public string? Tax { get; set; }
|
||||
|
||||
public string? Email { get; set; }
|
||||
|
||||
public string? Discord { get; set; }
|
||||
|
||||
public string? Slack { get; set; }
|
||||
|
||||
public string? LinkedIn { get; set; }
|
||||
|
||||
public string? Whatsapp { get; set; }
|
||||
|
||||
public string? Website { get; set; }
|
||||
|
||||
public string? Phone { get; set; }
|
||||
|
||||
public string? Address { get; set; }
|
||||
|
||||
public string? City { get; set; }
|
||||
|
||||
public string? Region { get; set; }
|
||||
|
||||
public string? Country { get; set; }
|
||||
|
||||
public string? PostalCode { get; set; }
|
||||
|
||||
private UpdateCustomerCommand(Guid customerId, string name, string lastName, string? company, string? tax, string email, string? discord, string? slack, string? linkedIn, string? whatsapp, string? website, string? phone, string? address, string? city, string? region, string? country, string? postalCode)
|
||||
{
|
||||
CustomerId = customerId;
|
||||
Name = name;
|
||||
LastName = lastName;
|
||||
Company = company;
|
||||
Tax = tax;
|
||||
Email = email;
|
||||
Discord = discord;
|
||||
Slack = slack;
|
||||
LinkedIn = linkedIn;
|
||||
Whatsapp = whatsapp;
|
||||
Website = website;
|
||||
Phone = phone;
|
||||
Address = address;
|
||||
City = city;
|
||||
Region = region;
|
||||
Country = country;
|
||||
PostalCode = postalCode;
|
||||
}
|
||||
|
||||
public static UpdateCustomerCommand Create(Guid customerId, string name, string lastName, string? company, string? tax, string email, string? discord, string? slack, string? linkedIn, string? whatsapp, string? website, string? phone, string? address, string? city, string? region, string? country, string? postalCode)
|
||||
{
|
||||
if (customerId == Guid.Empty)
|
||||
throw new ArgumentException("Customer ID is required.", nameof(customerId));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(name) && string.IsNullOrWhiteSpace(lastName) && string.IsNullOrWhiteSpace(email))
|
||||
throw new ArgumentException("At the following fields must be provided: Name, LastName, Email");
|
||||
|
||||
return new(customerId, name, lastName, company, tax, email, discord, slack, linkedIn, whatsapp, website, phone, address, city, region, country, postalCode);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user