Files
parr_api/PARR.DAL/Models/DistributionPeriod.cs

70 lines
2.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using PARR.DAL.Models.Job;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
/// <summary>
/// Период автоматического распеделения РР
/// </summary>
[Table("DistributionPeriods", Schema = DatabaseSchemas.Schedule)]
public class DistributionPeriod : IBaseEntity
{
[Key]
public Guid Id { get; set; }
[NotMapped]
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
public required string Duration { get; set; }
public required string Type { get; set; }
//public DateTimeOffset AddDate
//{
// get
// {
// var typeEnum = Enum.Parse(typeof(DistributionPeriodTypeEnum), Type);
// switch (typeEnum)
// {
// case (DistributionPeriodTypeEnum.Day):
// int.TryParse(Duration, out var intDays);
// return new DateTimeOffset().AddDays(intDays);
// case (DistributionPeriodTypeEnum.Month):
// int.TryParse(Duration, out var intMonth);
// return new DateTimeOffset().AddMonths(intMonth);
// case (DistributionPeriodTypeEnum.Year):
// int.TryParse(Duration, out var intYear);
// return new DateTimeOffset().AddYears(intYear);
// case (DistributionPeriodTypeEnum.TimeSpan):
// TimeSpan.TryParse(Duration, out var timeSpan);
// return new DateTimeOffset().Add(timeSpan);
// }
// return new DateTimeOffset();
// }
//}
[ForeignKey(nameof(Type))]
public DistributionPeriodType? DistributionPeriodType { get; set; }
public ICollection<JobGroupDistributionConfig> GroupDistributionConfig { get; set; } = new HashSet<JobGroupDistributionConfig>();
//public ICollection<EsppSchTypeValue> EsppSchTypeValues { get; set; } = new HashSet<EsppSchTypeValue>();
}
}