Files
monorepo/LCU.API.Internal.RepoApi/LCU.API.Internal.RepoApi.Repos/Models/RepoCompanySelection.cs
T
2026-03-13 09:27:34 -05:00

48 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using LCU.API.Collections.CollectionsApiLib.Models;
namespace LCU.API.Internal.RepoApi.Repos.Models
{
public class RepoCompanySelection : IValidatableObject
{
public int? Id { get; set; }
[Required]
public int? CollateralId { get; set; }
public RepoType RepoType { get; set; }
public int? RepoCompanyId { get; set; }
public DateTime? RepoCompanyAssignmentDate { get; set; }
public DateTime? DateRepoed { get; set; }
public DateTime? DateTimeCreated { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var failedValidations = new List<ValidationResult>();
// This cannot be a required field on account of it resulting in a SQL error
if (RepoType == null)
{
failedValidations.Add(new ValidationResult("Repo Company Selection: The RepoType cannot be blank"));
}
if (RepoCompanyAssignmentDate > DateRepoed)
{
failedValidations.Add(new ValidationResult("Repo Company Selection: The date repoed cannot come before the date assigned."));
}
if (RepoCompanyId != null && RepoCompanyAssignmentDate == null)
{
failedValidations.Add(new ValidationResult("Repo Company Selection: The Repo Company Assignment date cannot be null when a Repo Company is set."));
}
return failedValidations;
}
}
}