38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using ElectricalRepairServiceContract.Exceptions;
|
|
using ElectricalRepairServiceContract.Extensions;
|
|
using ElectricalRepairServiceContract.Interfaces;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ElectricalRepairServiceContract.DataModels
|
|
{
|
|
public class DetailDeliveryDataModel : IValidation
|
|
{
|
|
public string Id { get; private set; }
|
|
public string DetailId { get; private set; }
|
|
public int Amount { get; private set; }
|
|
public DateTime Date { get; private set; }
|
|
|
|
public DetailDeliveryDataModel(string id, string detailId, int amount, DateTime date)
|
|
{
|
|
Id = id;
|
|
DetailId = detailId;
|
|
Amount = amount;
|
|
Date = date;
|
|
}
|
|
|
|
public void Validate()
|
|
{
|
|
if (Id.IsEmpty())
|
|
throw new ValidationException("Field Id is empty");
|
|
if (!Id.IsGuid())
|
|
throw new ValidationException("The value in the field Id is not a unique identifier");
|
|
if (Amount <= 0)
|
|
throw new ValidationException("The Amount must be more then 0");
|
|
}
|
|
}
|
|
}
|