28 lines
918 B
C#
28 lines
918 B
C#
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using CandyHouseBase.Exceptions;
|
||
|
using CandyHouseBase.Extensions;
|
||
|
using CandyHouseBase.Infrastructure;
|
||
|
|
||
|
namespace CandyHouseBase.DataModels
|
||
|
{
|
||
|
public class SupplyDataModel : IValidation
|
||
|
{
|
||
|
public string Id { get; private set; }
|
||
|
public DateTime SupplyDate { get; private set; }
|
||
|
public List<SupplyItemDataModel> SupplyItems { get; private set; }
|
||
|
|
||
|
public SupplyDataModel(string id, DateTime supplyDate, List<SupplyItemDataModel> supplyItems)
|
||
|
{
|
||
|
Id = id;
|
||
|
SupplyDate = supplyDate;
|
||
|
SupplyItems = supplyItems;
|
||
|
}
|
||
|
|
||
|
public void Validate()
|
||
|
{
|
||
|
if (!Id.IsGuid()) throw new ValidationException("Id must be a GUID");
|
||
|
if (SupplyItems == null || SupplyItems.Count == 0) throw new ValidationException("Supply must contain at least one item");
|
||
|
}
|
||
|
}
|
||
|
}
|