feat(bll, dal): WeekendDayService + БД. CalendarService - получение рабочих дней за период
This commit is contained in:
@@ -53,6 +53,8 @@ namespace PARR.DAL.Context
|
||||
public DbSet<Models.Role> Roles { get; set; }
|
||||
public DbSet<UsersInRole> UsersInRoles { get; set; }
|
||||
|
||||
public DbSet<WeekendDay> WeekendDays { get; set; }
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
||||
2778
PARR.DAL/Migrations/20240701003839_tblWeekendDaysCreate.Designer.cs
generated
Normal file
2778
PARR.DAL/Migrations/20240701003839_tblWeekendDaysCreate.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
34
PARR.DAL/Migrations/20240701003839_tblWeekendDaysCreate.cs
Normal file
34
PARR.DAL/Migrations/20240701003839_tblWeekendDaysCreate.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class tblWeekendDaysCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "WeekendDays",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Date = table.Column<DateOnly>(type: "date", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_WeekendDays", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "WeekendDays");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2204,6 +2204,20 @@ namespace PARR.DAL.Migrations
|
||||
b.ToTable("UsersInRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.WeekendDay", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("WeekendDays");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Work", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
||||
21
PARR.DAL/Models/WeekendDay.cs
Normal file
21
PARR.DAL/Models/WeekendDay.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models
|
||||
{
|
||||
[Table("WeekendDays")]
|
||||
public class WeekendDay : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
|
||||
public DateOnly Date { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,7 @@ namespace PARR.DAL
|
||||
services.AddTransient<ITaskStatusService, TaskStatusService>();
|
||||
services.AddTransient<IEkStatusService, EkStatusService>();
|
||||
services.AddTransient<IEsppSchTypeScheduleService, EsppSchTypeScheduleService>();
|
||||
services.AddTransient<IWeekendDayService, WeekendDayService>();
|
||||
|
||||
// TransformServices
|
||||
services.AddTransient<IEsppScheduleTransformService, EsppScheduleTransformService>();
|
||||
|
||||
32
PARR.DAL/Services/Implementations/WeekendDayService.cs
Normal file
32
PARR.DAL/Services/Implementations/WeekendDayService.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class WeekendDayService : BaseService<WeekendDay>, IWeekendDayService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<WeekendDayService> logger;
|
||||
|
||||
protected override DbSet<WeekendDay> EntitySet => dataContext.WeekendDays;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
|
||||
public WeekendDayService(DataContext dataContext, ILogger<WeekendDayService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public IQueryable<DateOnly> GetWeekends(DateOnly start, DateOnly end)
|
||||
{
|
||||
return EntitySet.Where(t => t.Date >= start && t.Date <= end).Select(t => t.Date);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
10
PARR.DAL/Services/Interfaces/IWeekendDayService.cs
Normal file
10
PARR.DAL/Services/Interfaces/IWeekendDayService.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IWeekendDayService : IBaseService<WeekendDay>
|
||||
{
|
||||
IQueryable<DateOnly> GetWeekends(DateOnly start, DateOnly end);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user