30 lines
977 B
C#
30 lines
977 B
C#
|
using System;
|
||
|
using CandyHouseBase.Enums;
|
||
|
using CandyHouseBase.Exceptions;
|
||
|
using CandyHouseBase.Extensions;
|
||
|
using CandyHouseBase.Infrastructure;
|
||
|
|
||
|
namespace CandyHouseBase.DataModels
|
||
|
{
|
||
|
public class PositionDataModel : IValidation
|
||
|
{
|
||
|
public string Id { get; set; }
|
||
|
public PositionType Type { get; set; }
|
||
|
public string Title { get; set; }
|
||
|
|
||
|
public PositionDataModel(string id, PositionType type, string title)
|
||
|
{
|
||
|
Id = id;
|
||
|
Type = type;
|
||
|
Title = title;
|
||
|
}
|
||
|
|
||
|
public void Validate()
|
||
|
{
|
||
|
if (Id.IsEmpty()) throw new ValidationException("Field Id is empty");
|
||
|
if (!Id.IsGuid()) throw new ValidationException("Id must be a GUID");
|
||
|
if (string.IsNullOrEmpty(Title)) throw new ValidationException("Field Title is empty");
|
||
|
if (!Enum.IsDefined(typeof(PositionType), Type)) throw new ValidationException("Invalid PositionType");
|
||
|
}
|
||
|
}
|
||
|
}
|