all tests and some changes
This commit is contained in:
@@ -1,22 +1,19 @@
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
|
||||
public class RequestDataModel(string id, string workerId, double sum,
|
||||
public class RequestDataModel(string id, string workerId, string email, double sum,
|
||||
bool isCancel, List<InstallationRequestDataModel> softwares) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
public string WorkerId { get; private set; } = workerId;
|
||||
public DateTime RequestDate { get; private set; } = DateTime.UtcNow;
|
||||
public string Email { get; private set; } = email;
|
||||
public double Sum { get; private set; } = sum;
|
||||
public bool IsCancel { get; private set; } = isCancel;
|
||||
public List<InstallationRequestDataModel> Softwares { get; private set; } = softwares;
|
||||
@@ -30,6 +27,10 @@ public class RequestDataModel(string id, string workerId, double sum,
|
||||
throw new ValidationException("Field WorkerId is empty");
|
||||
if (!WorkerId.IsGuid())
|
||||
throw new ValidationException("The value in the field WorkerId is not a unique identifier");
|
||||
if (Email.IsEmpty())
|
||||
throw new ValidationException("Worker Email is empty");
|
||||
if (!Regex.IsMatch(Email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$"))
|
||||
throw new ValidationException("Field Email is not a email");
|
||||
if (Sum <= 0)
|
||||
throw new ValidationException("Field Sum is less than or equal to 0");
|
||||
if ((Softwares?.Count ?? 0) == 0)
|
||||
|
||||
Reference in New Issue
Block a user