33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using System;
|
|
using CandyHouseBase.Exceptions;
|
|
using CandyHouseBase.Extensions;
|
|
using CandyHouseBase.Infrastructure;
|
|
|
|
namespace CandyHouseBase.DataModels
|
|
{
|
|
public class ProductionDataModel : IValidation
|
|
{
|
|
public string Id { get; private set; }
|
|
public string PekarId { get; private set; }
|
|
public string ProductId { get; private set; }
|
|
public DateTime ProductionDate { get; private set; }
|
|
public int Quantity { get; private set; }
|
|
|
|
public ProductionDataModel(string id, string pekarId, string productId, DateTime productionDate, int quantity)
|
|
{
|
|
Id = id;
|
|
PekarId = pekarId;
|
|
ProductId = productId;
|
|
ProductionDate = productionDate;
|
|
Quantity = quantity;
|
|
}
|
|
|
|
public void Validate()
|
|
{
|
|
if (!Id.IsGuid()) throw new ValidationException("Id must be a GUID");
|
|
if (!PekarId.IsGuid()) throw new ValidationException("PekarId must be a GUID");
|
|
if (!ProductId.IsGuid()) throw new ValidationException("ProductId must be a GUID");
|
|
if (Quantity <= 0) throw new ValidationException("Quantity must be positive");
|
|
}
|
|
}
|
|
} |