feat(bll, dal): distributionPeriod - добавили типы, адаптировали методы
This commit is contained in:
@@ -15,4 +15,8 @@
|
|||||||
<PackageReference Include="RabbitMQ.Client" Version="6.5.0" />
|
<PackageReference Include="RabbitMQ.Client" Version="6.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\PARR.Constants\PARR.Constants.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,18 +1,75 @@
|
|||||||
using PARR.BLL.Services.Interfaces;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PARR.BLL.Services.Interfaces;
|
||||||
|
using PARR.Constants;
|
||||||
|
|
||||||
namespace PARR.BLL.Services.Implementations
|
namespace PARR.BLL.Services.Implementations
|
||||||
{
|
{
|
||||||
internal class CalendarService : ICalendarService
|
internal class CalendarService : ICalendarService
|
||||||
{
|
{
|
||||||
private DateOnly GetEndPeriodDate(DateOnly startPeriod, TimeSpan distributionPeriod)
|
private readonly ILogger<CalendarService> logger;
|
||||||
|
|
||||||
|
public CalendarService(ILogger<CalendarService> logger)
|
||||||
{
|
{
|
||||||
return startPeriod.AddDays(distributionPeriod.Days).AddDays(-1);
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DateOnly GetEndPeriodDate(DateOnly startPeriod, DistributionPeriodTypeEnum periodType, string distributionPeriod)
|
||||||
|
{
|
||||||
|
//TODO: подходит для NextRun
|
||||||
|
|
||||||
|
switch (periodType)
|
||||||
|
{
|
||||||
|
case (DistributionPeriodTypeEnum.Day):
|
||||||
|
return startPeriod.AddDays(ParseInt(distributionPeriod));
|
||||||
|
|
||||||
|
case (DistributionPeriodTypeEnum.Month):
|
||||||
|
return startPeriod.AddMonths(ParseInt(distributionPeriod));
|
||||||
|
|
||||||
|
case (DistributionPeriodTypeEnum.Year):
|
||||||
|
return startPeriod.AddYears(ParseInt(distributionPeriod));
|
||||||
|
|
||||||
|
//case (DistributionPeriodTypeEnum.TimeSpan):
|
||||||
|
// var timeSpan = ParseTimeSpan(distributionPeriod);
|
||||||
|
// return timeSpan.Days > 0 ? startPeriod.AddDays();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<DateOnly> GetWorkDatesForPeriod(DateOnly startPeriod, TimeSpan distributionPeriod, GetWeekendsDelegate getWeekends)
|
//return startPeriod.AddDays(duration.Days).AddDays(-1);
|
||||||
|
return startPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int ParseInt(string value)
|
||||||
{
|
{
|
||||||
var endPeriod = GetEndPeriodDate(startPeriod, distributionPeriod);
|
try
|
||||||
|
{
|
||||||
|
return int.Parse(value);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, $"{nameof(CalendarService)}, получение конца периода. Не смог распарсить string в int для значения {value}.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//private TimeSpan ParseTimeSpan(string value)
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// return TimeSpan.Parse(value);
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// logger.LogError(ex, $"{nameof(CalendarService)}, получение конца периода. Не смог распарсить string в TimeSpan для значения {value}.");
|
||||||
|
// return new TimeSpan(0);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//public List<DateOnly> GetWorkDatesForPeriod(DateOnly startPeriod, TimeSpan duration, GetWeekendsDelegate getWeekends)
|
||||||
|
public List<DateOnly> GetWorkDatesForPeriod(DateOnly startPeriod, DistributionPeriodTypeEnum periodType, string distributionPeriod, GetWeekendsDelegate getWeekends)
|
||||||
|
{
|
||||||
|
var endPeriod = GetEndPeriodDate(startPeriod, periodType, distributionPeriod);
|
||||||
|
|
||||||
//не получилось сделать асинхронным
|
//не получилось сделать асинхронным
|
||||||
var weekends = getWeekends.Invoke(startPeriod, endPeriod).ToList(); //.ToListAsync();
|
var weekends = getWeekends.Invoke(startPeriod, endPeriod).ToList(); //.ToListAsync();
|
||||||
@@ -43,8 +100,8 @@ namespace PARR.BLL.Services.Implementations
|
|||||||
var currentDay = startPeriod;
|
var currentDay = startPeriod;
|
||||||
while (currentDay <= EndPeriod)
|
while (currentDay <= EndPeriod)
|
||||||
{
|
{
|
||||||
// 29 дней, потому что в феврале 28, чтоб не париться, сделали так
|
//!!!!!!!! 29 дней, потому что в феврале 28, чтоб не париться, сделали так
|
||||||
//if (currentDay.Day < 29) - не делаем, так как в таблице DistributionPeriods указали 28 дней
|
if (currentDay.Day < 29)
|
||||||
workDaysList.Add(currentDay);
|
workDaysList.Add(currentDay);
|
||||||
|
|
||||||
currentDay = currentDay.AddDays(1);
|
currentDay = currentDay.AddDays(1);
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace PARR.BLL.Services.Interfaces
|
using PARR.Constants;
|
||||||
|
|
||||||
|
namespace PARR.BLL.Services.Interfaces
|
||||||
{
|
{
|
||||||
public delegate IQueryable<DateOnly> GetWeekendsDelegate(DateOnly start, DateOnly end);
|
public delegate IQueryable<DateOnly> GetWeekendsDelegate(DateOnly start, DateOnly end);
|
||||||
|
|
||||||
@@ -8,9 +10,10 @@
|
|||||||
/// Получить только рабочие дни за период
|
/// Получить только рабочие дни за период
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="startPeriod"></param>
|
/// <param name="startPeriod"></param>
|
||||||
|
/// <param name="typePeriod"></param>
|
||||||
/// <param name="distributionPeriod"></param>
|
/// <param name="distributionPeriod"></param>
|
||||||
/// <param name="getWeekends"></param>
|
/// <param name="getWeekends"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
List<DateOnly> GetWorkDatesForPeriod(DateOnly startPeriod, TimeSpan distributionPeriod, GetWeekendsDelegate getWeekends);
|
List<DateOnly> GetWorkDatesForPeriod(DateOnly startPeriod, DistributionPeriodTypeEnum periodType, string distributionPeriod, GetWeekendsDelegate getWeekends);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
PARR.Constants/DistributionPeriodTypeEnum.cs
Normal file
13
PARR.Constants/DistributionPeriodTypeEnum.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace PARR.Constants
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Тип периода распределения РР
|
||||||
|
/// </summary>
|
||||||
|
public enum DistributionPeriodTypeEnum
|
||||||
|
{
|
||||||
|
Day,
|
||||||
|
Month,
|
||||||
|
Year
|
||||||
|
//TimeSpan
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -362,10 +362,21 @@ namespace PARR.DAL.Context
|
|||||||
modelBuilder.Entity<DistributionPeriod>(f =>
|
modelBuilder.Entity<DistributionPeriod>(f =>
|
||||||
{
|
{
|
||||||
f.HasData(
|
f.HasData(
|
||||||
new() { Id = new Guid("3A7341A8-085C-461C-BABC-6B78DD5D2C67"), Name = "Ежемесячно", Duration = new TimeSpan(28, 0, 0, 0) },
|
new() { Id = new Guid("3A7341A8-085C-461C-BABC-6B78DD5D2C67"), Name = "Ежемесячно", Duration = "1", Type = DistributionPeriodTypeEnum.Month.ToString() },
|
||||||
new() { Id = new Guid("0AD2DFDB-3833-46D9-979A-C408B7EADC6C"), Name = "Каждые 90 дней", Duration = new TimeSpan(90, 0, 0, 0) }
|
new() { Id = new Guid("0AD2DFDB-3833-46D9-979A-C408B7EADC6C"), Name = "Каждые 90 дней", Duration = "90", Type = DistributionPeriodTypeEnum.Day.ToString() }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<DistributionPeriodType>(f =>
|
||||||
|
{
|
||||||
|
f.HasData(
|
||||||
|
new() { Type = DistributionPeriodTypeEnum.Day.ToString(), Description = "День" },
|
||||||
|
new() { Type = DistributionPeriodTypeEnum.Month.ToString(), Description = "Месяц" },
|
||||||
|
new() { Type = DistributionPeriodTypeEnum.Year.ToString(), Description = "Год" }
|
||||||
|
//new() { Type = DistributionPeriodTypeEnum.TimeSpan.ToString(), Description = "TimeSpan" }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
2931
PARR.DAL/Migrations/20240701061944_tblDistributionPerioadAddTypes.Designer.cs
generated
Normal file
2931
PARR.DAL/Migrations/20240701061944_tblDistributionPerioadAddTypes.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,123 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||||||
|
|
||||||
|
namespace PARR.DAL.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class tblDistributionPerioadAddTypes : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "Duration",
|
||||||
|
table: "DistributionPeriods",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(TimeSpan),
|
||||||
|
oldType: "interval");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Type",
|
||||||
|
table: "DistributionPeriods",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "DistributionPeriodTypes",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Type = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Description = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_DistributionPeriodTypes", x => x.Type);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "DistributionPeriodTypes",
|
||||||
|
columns: new[] { "Type", "Description" },
|
||||||
|
values: new object[,]
|
||||||
|
{
|
||||||
|
{ "Day", "День" },
|
||||||
|
{ "Month", "Месяц" },
|
||||||
|
{ "TimeSpan", "TimeSpan" },
|
||||||
|
{ "Year", "Год" }
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "DistributionPeriods",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: new Guid("0ad2dfdb-3833-46d9-979a-c408b7eadc6c"),
|
||||||
|
columns: new[] { "Duration", "Type" },
|
||||||
|
values: new object[] { "90", "Day" });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "DistributionPeriods",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: new Guid("3a7341a8-085c-461c-babc-6b78dd5d2c67"),
|
||||||
|
columns: new[] { "Duration", "Type" },
|
||||||
|
values: new object[] { "1", "Month" });
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_DistributionPeriods_Type",
|
||||||
|
table: "DistributionPeriods",
|
||||||
|
column: "Type");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_DistributionPeriods_DistributionPeriodTypes_Type",
|
||||||
|
table: "DistributionPeriods",
|
||||||
|
column: "Type",
|
||||||
|
principalTable: "DistributionPeriodTypes",
|
||||||
|
principalColumn: "Type",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_DistributionPeriods_DistributionPeriodTypes_Type",
|
||||||
|
table: "DistributionPeriods");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "DistributionPeriodTypes");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_DistributionPeriods_Type",
|
||||||
|
table: "DistributionPeriods");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Type",
|
||||||
|
table: "DistributionPeriods");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<TimeSpan>(
|
||||||
|
name: "Duration",
|
||||||
|
table: "DistributionPeriods",
|
||||||
|
type: "interval",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "text");
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "DistributionPeriods",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: new Guid("0ad2dfdb-3833-46d9-979a-c408b7eadc6c"),
|
||||||
|
column: "Duration",
|
||||||
|
value: new TimeSpan(90, 0, 0, 0, 0));
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "DistributionPeriods",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: new Guid("3a7341a8-085c-461c-babc-6b78dd5d2c67"),
|
||||||
|
column: "Duration",
|
||||||
|
value: new TimeSpan(28, 0, 0, 0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2926
PARR.DAL/Migrations/20240701065100_tblDistributionPeriodTypeRemoveTimeSpan.Designer.cs
generated
Normal file
2926
PARR.DAL/Migrations/20240701065100_tblDistributionPeriodTypeRemoveTimeSpan.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace PARR.DAL.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class tblDistributionPeriodTypeRemoveTimeSpan : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "DistributionPeriodTypes",
|
||||||
|
keyColumn: "Type",
|
||||||
|
keyValue: "TimeSpan");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "DistributionPeriodTypes",
|
||||||
|
columns: new[] { "Type", "Description" },
|
||||||
|
values: new object[] { "TimeSpan", "TimeSpan" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -309,29 +309,69 @@ namespace PARR.DAL.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<TimeSpan>("Duration")
|
b.Property<string>("Duration")
|
||||||
.HasColumnType("interval");
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("Type");
|
||||||
|
|
||||||
b.ToTable("DistributionPeriods");
|
b.ToTable("DistributionPeriods");
|
||||||
|
|
||||||
b.HasData(
|
b.HasData(
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = new Guid("3a7341a8-085c-461c-babc-6b78dd5d2c67"),
|
Id = new Guid("3a7341a8-085c-461c-babc-6b78dd5d2c67"),
|
||||||
Duration = new TimeSpan(28, 0, 0, 0, 0),
|
Duration = "1",
|
||||||
Name = "Ежемесячно"
|
Name = "Ежемесячно",
|
||||||
|
Type = "Month"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = new Guid("0ad2dfdb-3833-46d9-979a-c408b7eadc6c"),
|
Id = new Guid("0ad2dfdb-3833-46d9-979a-c408b7eadc6c"),
|
||||||
Duration = new TimeSpan(90, 0, 0, 0, 0),
|
Duration = "90",
|
||||||
Name = "Каждые 90 дней"
|
Name = "Каждые 90 дней",
|
||||||
|
Type = "Day"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PARR.DAL.Models.DistributionPeriodType", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Type");
|
||||||
|
|
||||||
|
b.ToTable("DistributionPeriodTypes");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Type = "Day",
|
||||||
|
Description = "День"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Type = "Month",
|
||||||
|
Description = "Месяц"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Type = "Year",
|
||||||
|
Description = "Год"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2450,6 +2490,17 @@ namespace PARR.DAL.Migrations
|
|||||||
b.Navigation("Work");
|
b.Navigation("Work");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PARR.DAL.Models.DistributionPeriod", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("PARR.DAL.Models.DistributionPeriodType", "DistributionPeriodType")
|
||||||
|
.WithMany("Periods")
|
||||||
|
.HasForeignKey("Type")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("DistributionPeriodType");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PARR.DAL.Models.EsppSchTypeConfig", b =>
|
modelBuilder.Entity("PARR.DAL.Models.EsppSchTypeConfig", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("PARR.DAL.Models.EsppSchType", "EsppSchType")
|
b.HasOne("PARR.DAL.Models.EsppSchType", "EsppSchType")
|
||||||
@@ -2736,6 +2787,11 @@ namespace PARR.DAL.Migrations
|
|||||||
b.Navigation("EsppSchTypeValues");
|
b.Navigation("EsppSchTypeValues");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PARR.DAL.Models.DistributionPeriodType", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Periods");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PARR.DAL.Models.EkStatus", b =>
|
modelBuilder.Entity("PARR.DAL.Models.EkStatus", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Hosts");
|
b.Navigation("Hosts");
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using PARR.DAL.Models.Base;
|
using PARR.Constants;
|
||||||
|
using PARR.DAL.Models.Base;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
@@ -21,9 +22,45 @@ namespace PARR.DAL.Models
|
|||||||
|
|
||||||
public required string Name { get; set; }
|
public required string Name { get; set; }
|
||||||
|
|
||||||
public TimeSpan Duration { 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<EsppSchTypeValue> EsppSchTypeValues { get; set; } = new HashSet<EsppSchTypeValue>();
|
public ICollection<EsppSchTypeValue> EsppSchTypeValues { get; set; } = new HashSet<EsppSchTypeValue>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
PARR.DAL/Models/DistributionPeriodType.cs
Normal file
16
PARR.DAL/Models/DistributionPeriodType.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace PARR.DAL.Models
|
||||||
|
{
|
||||||
|
[Table("DistributionPeriodTypes")]
|
||||||
|
public class DistributionPeriodType
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public required string Type { get; set; }
|
||||||
|
|
||||||
|
public required string Description { get; set; }
|
||||||
|
|
||||||
|
public ICollection<DistributionPeriod> Periods { get; set; } = new HashSet<DistributionPeriod>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ using PARR.DAL.Services.Interfaces;
|
|||||||
using PARR.EsppApi;
|
using PARR.EsppApi;
|
||||||
using PARR.EsppApi.Constants;
|
using PARR.EsppApi.Constants;
|
||||||
using PARR.EsppApi.Models.Query;
|
using PARR.EsppApi.Models.Query;
|
||||||
|
using System.Net.WebSockets;
|
||||||
|
|
||||||
namespace PARR.Test
|
namespace PARR.Test
|
||||||
{
|
{
|
||||||
@@ -62,6 +63,16 @@ namespace PARR.Test
|
|||||||
|
|
||||||
// var aaa = await service!.Get().ToListAsync();
|
// var aaa = await service!.Get().ToListAsync();
|
||||||
|
|
||||||
|
// foreach (var aaaItem in aaa) {
|
||||||
|
|
||||||
|
// var bbbb = aaaItem.AddDate;
|
||||||
|
|
||||||
|
|
||||||
|
// var now = DateTimeOffset.UtcNow;
|
||||||
|
// var newwww = now.AddMicroseconds(bbbb.);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user