init
This commit is contained in:
parent
f7d51508b5
commit
6d8c193512
@ -8,7 +8,7 @@ namespace Demo.domain.Models
|
||||
{
|
||||
public class GroupLocalEntity
|
||||
{
|
||||
public required int Id { get; set; }
|
||||
public int Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ namespace Demo.Data.RemoteData.RemoteDataBase
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseNpgsql();
|
||||
optionsBuilder.UseNpgsql("Host=localhost; Database=presencedb; Username=postgres; Password=123");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
|
@ -37,48 +37,28 @@ public class GroupRepositoryImpl: IGroupRepository
|
||||
}
|
||||
|
||||
// Метод для обновления существующей группы
|
||||
public void UpdateGroup(GroupLocalEntity group)
|
||||
public void UpdateGroupById(int groupId, GroupLocalEntity updatedGroup)
|
||||
{
|
||||
var existingGroup = GetGroupById(group.Id);
|
||||
if (existingGroup == null) throw new GroupNotFoundException(group.Id);
|
||||
var existingGroup = GetGroupById(groupId);
|
||||
if (existingGroup == null) throw new GroupNotFoundException(groupId);
|
||||
}
|
||||
|
||||
public void RemoveGroupById(GroupLocalEntity group)
|
||||
public void RemoveGroupById(int groupId)
|
||||
{
|
||||
var existingGroup = GetGroupById(group.Id);
|
||||
if (existingGroup == null) throw new GroupNotFoundException(group.Id);
|
||||
var existingGroup = GetGroupById(groupId);
|
||||
if (existingGroup == null) throw new GroupNotFoundException(groupId);
|
||||
if (_groups.Contains(existingGroup))
|
||||
{
|
||||
_groups.Remove(existingGroup);
|
||||
}
|
||||
}
|
||||
|
||||
public List<GroupLocalEntity> GetAllGroup()
|
||||
bool IGroupRepository.RemoveGroupById(int groupID)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool RemoveGroupById(int groupID)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
bool IGroupRepository.AddGroup(GroupLocalEntity newGroup)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<GroupDao> GetAllGroupDao()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool RemoveGroupByIdDao(int groupID)
|
||||
List<GroupDao> IGroupRepository.GetAllGroups()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -88,22 +68,12 @@ public class GroupRepositoryImpl: IGroupRepository
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public GroupDao GetGroupByIdDao(int groupID)
|
||||
GroupDao IGroupRepository.GetGroupById(int groupID)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool AddGroup(GroupDao newGroup)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool UpdateGroupByIdDao(int groupID, GroupDao updatedGroup)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool AddGroupDao(GroupDao newGroup)
|
||||
public bool AddGroup(string Name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -10,18 +10,10 @@ namespace Demo.Data.Repository
|
||||
{
|
||||
public interface IGroupRepository
|
||||
{
|
||||
List<GroupLocalEntity> GetAllGroup();
|
||||
List<GroupDao> GetAllGroups();
|
||||
bool RemoveGroupById(int groupID);
|
||||
bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup);
|
||||
GroupLocalEntity GetGroupById(int groupID);
|
||||
bool AddGroup(GroupLocalEntity newGroup);
|
||||
|
||||
|
||||
|
||||
List<GroupDao> GetAllGroupDao();
|
||||
bool RemoveGroupByIdDao(int groupID);
|
||||
bool UpdateGroupByIdDao(int groupID, GroupDao updatedGroup);
|
||||
GroupDao GetGroupByIdDao(int groupID);
|
||||
bool AddGroupDao(GroupDao newGroup);
|
||||
bool UpdateGroupById(int groupID, GroupDao updatedGroup);
|
||||
GroupDao GetGroupById(int groupID);
|
||||
bool AddGroup(string Name);
|
||||
}
|
||||
}
|
@ -16,12 +16,5 @@ namespace Demo.Data.Repository
|
||||
List<PresenceLocalEntity> GetPresenceByDateAndGroup(DateTime date, int groupId);
|
||||
void SavePresence(List<PresenceLocalEntity> presences);
|
||||
List<PresenceLocalEntity> GetPresenceByGroup(int groupId);
|
||||
|
||||
|
||||
|
||||
|
||||
List<PresenceDao> GetPresenceByDateAndGroupDao(DateTime date, int groupId);
|
||||
void SavePresenceDao(List<PresenceDao> presences);
|
||||
List<PresenceDao> GetPresenceByGroupDao(int groupId);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace Demo.Data.Repository
|
||||
}
|
||||
|
||||
// Метод для добавления новой группы
|
||||
public bool AddGroupDao(GroupDao newGroup)
|
||||
public bool AddGroup(GroupDao newGroup)
|
||||
{
|
||||
var groupDao = new GroupDao
|
||||
{
|
||||
@ -30,7 +30,7 @@ namespace Demo.Data.Repository
|
||||
}
|
||||
|
||||
// Метод для получения группы по ID
|
||||
public GroupDao GetGroupByIdDao(int groupId)
|
||||
public GroupDao GetGroupById(int groupId)
|
||||
{
|
||||
var groupDao = _remoteDatabaseContext.Groups
|
||||
.Include(g => g.Users)
|
||||
@ -51,7 +51,7 @@ namespace Demo.Data.Repository
|
||||
}
|
||||
|
||||
// Метод для получения всех групп
|
||||
public List<GroupDao> GetAllGroupDao()
|
||||
public List<GroupDao> GetAllGroups()
|
||||
{
|
||||
return _remoteDatabaseContext.Groups
|
||||
.Include(g => g.Users)
|
||||
@ -70,7 +70,7 @@ namespace Demo.Data.Repository
|
||||
}
|
||||
|
||||
// Метод для обновления группы по ID
|
||||
public bool UpdateGroupByIdDao(int groupId, GroupDao updatedGroup)
|
||||
public bool UpdateGroupById(int groupId, GroupDao updatedGroup)
|
||||
{
|
||||
var groupDao = _remoteDatabaseContext.Groups
|
||||
.Include(g => g.Users)
|
||||
@ -91,7 +91,7 @@ namespace Demo.Data.Repository
|
||||
}
|
||||
|
||||
// Метод для удаления группы по ID
|
||||
public bool RemoveGroupByIdDao(int groupId)
|
||||
public bool RemoveGroupById(int groupId)
|
||||
{
|
||||
var groupDao = _remoteDatabaseContext.Groups.Find(groupId);
|
||||
if (groupDao == null) return false;
|
||||
@ -101,29 +101,22 @@ namespace Demo.Data.Repository
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<GroupLocalEntity> GetAllGroup()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool RemoveGroupById(int groupID)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public GroupLocalEntity GetGroupById(int groupID)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool AddGroup(GroupLocalEntity newGroup)
|
||||
public bool AddGroup(string Name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
var groupDao = new GroupDao
|
||||
{
|
||||
Name = Name
|
||||
};
|
||||
_remoteDatabaseContext.Groups.Add(groupDao);
|
||||
_remoteDatabaseContext.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace Demo.Data.Repository
|
||||
public List<PresenceDao> GetPresenceByDateAndGroupDao(DateTime date, int groupId)
|
||||
{
|
||||
return _remoteDatabaseContext.PresenceDaos.Where(p => p.Date == DateOnly.FromDateTime(date) &&
|
||||
LocalStaticData.users.Any(u => u.GroupID == groupId && u.ID == p.UserId)).ToList();
|
||||
_remoteDatabaseContext.Users.Any(u => u.GroupId == groupId && u.UserId == p.UserId)).ToList();
|
||||
}
|
||||
|
||||
public List<PresenceLocalEntity> GetPresenceByGroup(int groupId)
|
||||
|
@ -1,13 +1,15 @@
|
||||
using Demo.Data.LocalData;
|
||||
using Demo.Data.RemoteData.RemoteDataBase.DAO;
|
||||
using Demo.Data.Repository;
|
||||
using Demo.domain.Models;
|
||||
|
||||
namespace Demo.Domain.UseCase
|
||||
{
|
||||
public class GroupUseCase
|
||||
{
|
||||
private readonly GroupRepositoryImpl _repositoryGroupImpl;
|
||||
private readonly IGroupRepository _repositoryGroupImpl;
|
||||
|
||||
public GroupUseCase(GroupRepositoryImpl repositoryGroupImpl)
|
||||
public GroupUseCase(IGroupRepository repositoryGroupImpl)
|
||||
{
|
||||
_repositoryGroupImpl = repositoryGroupImpl;
|
||||
}
|
||||
@ -30,7 +32,7 @@ namespace Demo.Domain.UseCase
|
||||
}
|
||||
|
||||
// Приватный метод для валидации существования группы по ID
|
||||
private GroupLocalEntity ValidateGroupExistence(int groupId)
|
||||
private GroupDao ValidateGroupExistence(int groupId)
|
||||
{
|
||||
var existingGroup = _repositoryGroupImpl.GetAllGroups()
|
||||
.FirstOrDefault(g => g.Id == groupId);
|
||||
@ -79,17 +81,14 @@ namespace Demo.Domain.UseCase
|
||||
{
|
||||
ValidateGroupName(groupName);
|
||||
|
||||
var newId = _repositoryGroupImpl.GetAllGroups().Any()
|
||||
? _repositoryGroupImpl.GetAllGroups().Max(g => g.Id) + 1
|
||||
: 1;
|
||||
|
||||
|
||||
GroupLocalEntity newGroup = new GroupLocalEntity
|
||||
{
|
||||
Id = newId,
|
||||
Name = groupName
|
||||
};
|
||||
|
||||
_repositoryGroupImpl.AddGroup(newGroup);
|
||||
_repositoryGroupImpl.AddGroup(newGroup.Name);
|
||||
}
|
||||
|
||||
public void RemoveGroupById(int groupId)
|
||||
@ -103,7 +102,7 @@ namespace Demo.Domain.UseCase
|
||||
if (groupToRemove != null)
|
||||
{
|
||||
_groups.Remove(groupToRemove);
|
||||
_repositoryGroupImpl.RemoveGroupById(existingGroup);
|
||||
_repositoryGroupImpl.RemoveGroupById(existingGroup.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -120,7 +119,7 @@ namespace Demo.Domain.UseCase
|
||||
var existingGroup = ValidateGroupExistence(groupId);
|
||||
|
||||
existingGroup.Name = newGroupName;
|
||||
_repositoryGroupImpl.UpdateGroup(existingGroup);
|
||||
_repositoryGroupImpl.UpdateGroupById(groupId,existingGroup);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,10 +10,10 @@ namespace Demo.Domain.UseCase
|
||||
{
|
||||
public class UseCaseGeneratePresence
|
||||
{
|
||||
public readonly UserRepositoryImpl _userRepository;
|
||||
public readonly IUserRepository _userRepository;
|
||||
public readonly IPresenceRepository _presenceRepository;
|
||||
|
||||
public UseCaseGeneratePresence(UserRepositoryImpl userRepository, IPresenceRepository presenceRepository)
|
||||
public UseCaseGeneratePresence(IUserRepository userRepository, IPresenceRepository presenceRepository)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
_presenceRepository = presenceRepository;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Demo.Data.Exceptions;
|
||||
using Demo.Data.RemoteData.RemoteDataBase.DAO;
|
||||
using Demo.Data.Repository;
|
||||
using Demo.domain.Models;
|
||||
|
||||
@ -6,10 +7,10 @@ namespace Demo.Domain.UseCase
|
||||
{
|
||||
public class UserUseCase
|
||||
{
|
||||
private readonly UserRepositoryImpl _repositoryUserImpl;
|
||||
private readonly GroupRepositoryImpl _repositoryGroupImpl;
|
||||
private readonly IUserRepository _repositoryUserImpl;
|
||||
private readonly IGroupRepository _repositoryGroupImpl;
|
||||
|
||||
public UserUseCase(UserRepositoryImpl repositoryImpl, GroupRepositoryImpl repositoryGroupImpl)
|
||||
public UserUseCase(IUserRepository repositoryImpl, IGroupRepository repositoryGroupImpl)
|
||||
{
|
||||
_repositoryUserImpl = repositoryImpl;
|
||||
_repositoryGroupImpl = repositoryGroupImpl;
|
||||
@ -39,7 +40,7 @@ namespace Demo.Domain.UseCase
|
||||
}
|
||||
|
||||
// Приватный метод для валидации существования группы по ID
|
||||
private GroupLocalEntity ValidateGroupExistence(int groupId)
|
||||
private GroupDao ValidateGroupExistence(int groupId)
|
||||
{
|
||||
var group = _repositoryGroupImpl.GetAllGroups()
|
||||
.FirstOrDefault(g => g.Id == groupId);
|
||||
|
123
Demo/Migrations/20241025085326_InitialCreate.Designer.cs
generated
Normal file
123
Demo/Migrations/20241025085326_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,123 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Demo.Data.RemoteData.RemoteDataBase;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Demo.Migrations
|
||||
{
|
||||
[DbContext(typeof(RemoteDatabaseContext))]
|
||||
[Migration("20241025085326_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.PresenceDao", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<bool>("IsAttedance")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("LessonNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("UserDaoUserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("UserId", "Date", "IsAttedance", "LessonNumber");
|
||||
|
||||
b.HasIndex("UserDaoUserId");
|
||||
|
||||
b.ToTable("PresenceDaos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("UserId"));
|
||||
|
||||
b.Property<string>("FIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("UserId");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.PresenceDao", b =>
|
||||
{
|
||||
b.HasOne("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", "UserDao")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserDaoUserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("UserDao");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", b =>
|
||||
{
|
||||
b.HasOne("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", "Group")
|
||||
.WithMany("Users")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Group");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", b =>
|
||||
{
|
||||
b.Navigation("Users");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
94
Demo/Migrations/20241025085326_InitialCreate.cs
Normal file
94
Demo/Migrations/20241025085326_InitialCreate.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Demo.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Groups",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Groups", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
UserId = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
FIO = table.Column<string>(type: "text", nullable: false),
|
||||
GroupId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.UserId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Users_Groups_GroupId",
|
||||
column: x => x.GroupId,
|
||||
principalTable: "Groups",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PresenceDaos",
|
||||
columns: table => new
|
||||
{
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
IsAttedance = table.Column<bool>(type: "boolean", nullable: false),
|
||||
Date = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
LessonNumber = table.Column<int>(type: "integer", nullable: false),
|
||||
UserDaoUserId = table.Column<int>(type: "integer", nullable: false),
|
||||
GroupId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PresenceDaos", x => new { x.UserId, x.Date, x.IsAttedance, x.LessonNumber });
|
||||
table.ForeignKey(
|
||||
name: "FK_PresenceDaos_Users_UserDaoUserId",
|
||||
column: x => x.UserDaoUserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "UserId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PresenceDaos_UserDaoUserId",
|
||||
table: "PresenceDaos",
|
||||
column: "UserDaoUserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Users_GroupId",
|
||||
table: "Users",
|
||||
column: "GroupId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "PresenceDaos");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Groups");
|
||||
}
|
||||
}
|
||||
}
|
120
Demo/Migrations/RemoteDatabaseContextModelSnapshot.cs
Normal file
120
Demo/Migrations/RemoteDatabaseContextModelSnapshot.cs
Normal file
@ -0,0 +1,120 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Demo.Data.RemoteData.RemoteDataBase;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Demo.Migrations
|
||||
{
|
||||
[DbContext(typeof(RemoteDatabaseContext))]
|
||||
partial class RemoteDatabaseContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.PresenceDao", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<bool>("IsAttedance")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("LessonNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("UserDaoUserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("UserId", "Date", "IsAttedance", "LessonNumber");
|
||||
|
||||
b.HasIndex("UserDaoUserId");
|
||||
|
||||
b.ToTable("PresenceDaos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("UserId"));
|
||||
|
||||
b.Property<string>("FIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("UserId");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.PresenceDao", b =>
|
||||
{
|
||||
b.HasOne("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", "UserDao")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserDaoUserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("UserDao");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", b =>
|
||||
{
|
||||
b.HasOne("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", "Group")
|
||||
.WithMany("Users")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Group");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", b =>
|
||||
{
|
||||
b.Navigation("Users");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -5,26 +5,24 @@ using Demo.UI;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
// Создаем экземпляр репозиториев
|
||||
GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl();
|
||||
UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl();
|
||||
PresenceRepositoryImpl presenceRepositoryImpl = new PresenceRepositoryImpl();
|
||||
|
||||
IServiceCollection services = new ServiceCollection();
|
||||
|
||||
services.AddDbContext<RemoteDatabaseContext>().
|
||||
AddSingleton<IGroupRepository, SQLGroupRepositoryImpl>();
|
||||
services.AddDbContext<RemoteDatabaseContext>().
|
||||
AddSingleton<IUserRepository, SQLUserRepositoryImpl>();
|
||||
services.AddDbContext<RemoteDatabaseContext>().
|
||||
AddSingleton<IPresenceRepository, SQLPresenceRepositoryImpl>();
|
||||
services
|
||||
.AddDbContext<RemoteDatabaseContext>()
|
||||
.AddSingleton<IGroupRepository, SQLGroupRepositoryImpl>()
|
||||
.AddSingleton<IUserRepository, SQLUserRepositoryImpl>()
|
||||
.AddSingleton<IPresenceRepository, SQLPresenceRepositoryImpl>()
|
||||
.AddSingleton<UserUseCase>()
|
||||
.AddSingleton<GroupUseCase>()
|
||||
.AddSingleton<UseCaseGeneratePresence>()
|
||||
.AddSingleton<MainMenuUI>();
|
||||
|
||||
|
||||
// Создаем UseCase для пользователей и групп
|
||||
UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl);
|
||||
GroupUseCase groupUseCase = new GroupUseCase(groupRepositoryImpl);
|
||||
UseCaseGeneratePresence presenceUseCase = new UseCaseGeneratePresence(userRepositoryImpl, presenceRepositoryImpl);
|
||||
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
// Создаем пользовательский интерфейс
|
||||
MainMenuUI mainMenuUI = new MainMenuUI(userUseCase, groupUseCase, presenceUseCase);
|
||||
MainMenuUI mainMenuUI = serviceProvider.GetService<MainMenuUI>();
|
||||
|
||||
// Выводим главное меню
|
||||
mainMenuUI.DisplayMenu();
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Demo")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0e15fc7d62cdcd2ecc8853e551035e8a3737aee9")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f7d51508b530eabb76d3b4b1f318300167d3841e")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Demo")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Demo")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
4ece56c2162fd488c720e2f84da208a216fb7d2f8a4132ee7289842b3b121377
|
||||
493adb33b632bbecda0d79b7d44fbeac0c4f7b12d8b381a895bb0e6e1fed2bd3
|
||||
|
@ -8,6 +8,6 @@ build_property.PlatformNeutralAssembly =
|
||||
build_property.EnforceExtendedAnalyzerRules =
|
||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||
build_property.RootNamespace = Demo
|
||||
build_property.ProjectDir = C:\Users\adm\Source\Repos\presence1\Demo\
|
||||
build_property.ProjectDir = C:\Users\adm\source\repos\presence1\Demo\
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
d802b7b93a990c8713727f8364fc47b1846b2dbf47bb30c6359a4f9f360292fb
|
||||
30504035d845e5616feb21a777025026c55555e88052b83a111a265004d6549d
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
bfad4a74ba74f7b6af7182a47faf922142f10d24ecb4676d49fb56abebdc3e22
|
||||
d5eb5cfbfe9d110c04bac2d0bacec315a054499e2bed6b39e50a2c77268548e7
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
28
Demo/obj/Demo.csproj.EntityFrameworkCore.targets
Normal file
28
Demo/obj/Demo.csproj.EntityFrameworkCore.targets
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name="GetEFProjectMetadata">
|
||||
<MSBuild Condition=" '$(TargetFramework)' == '' "
|
||||
Projects="$(MSBuildProjectFile)"
|
||||
Targets="GetEFProjectMetadata"
|
||||
Properties="TargetFramework=$(TargetFrameworks.Split(';')[0]);EFProjectMetadataFile=$(EFProjectMetadataFile)" />
|
||||
<ItemGroup Condition=" '$(TargetFramework)' != '' ">
|
||||
<EFProjectMetadata Include="AssemblyName: $(AssemblyName)" />
|
||||
<EFProjectMetadata Include="Language: $(Language)" />
|
||||
<EFProjectMetadata Include="OutputPath: $(OutputPath)" />
|
||||
<EFProjectMetadata Include="Platform: $(Platform)" />
|
||||
<EFProjectMetadata Include="PlatformTarget: $(PlatformTarget)" />
|
||||
<EFProjectMetadata Include="ProjectAssetsFile: $(ProjectAssetsFile)" />
|
||||
<EFProjectMetadata Include="ProjectDir: $(ProjectDir)" />
|
||||
<EFProjectMetadata Include="RootNamespace: $(RootNamespace)" />
|
||||
<EFProjectMetadata Include="RuntimeFrameworkVersion: $(RuntimeFrameworkVersion)" />
|
||||
<EFProjectMetadata Include="TargetFileName: $(TargetFileName)" />
|
||||
<EFProjectMetadata Include="TargetFrameworkMoniker: $(TargetFrameworkMoniker)" />
|
||||
<EFProjectMetadata Include="Nullable: $(Nullable)" />
|
||||
<EFProjectMetadata Include="TargetFramework: $(TargetFramework)" />
|
||||
<EFProjectMetadata Include="TargetPlatformIdentifier: $(TargetPlatformIdentifier)" />
|
||||
</ItemGroup>
|
||||
<WriteLinesToFile Condition=" '$(TargetFramework)' != '' "
|
||||
File="$(EFProjectMetadataFile)"
|
||||
Lines="@(EFProjectMetadata)" />
|
||||
</Target>
|
||||
</Project>
|
@ -1,17 +1,17 @@
|
||||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\Demo.csproj": {}
|
||||
"C:\\Users\\adm\\source\\repos\\presence1\\Demo\\Demo.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\Demo.csproj": {
|
||||
"C:\\Users\\adm\\source\\repos\\presence1\\Demo\\Demo.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\Demo.csproj",
|
||||
"projectUniqueName": "C:\\Users\\adm\\source\\repos\\presence1\\Demo\\Demo.csproj",
|
||||
"projectName": "Demo",
|
||||
"projectPath": "C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\Demo.csproj",
|
||||
"projectPath": "C:\\Users\\adm\\source\\repos\\presence1\\Demo\\Demo.csproj",
|
||||
"packagesPath": "C:\\Users\\adm\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\obj\\",
|
||||
"outputPath": "C:\\Users\\adm\\source\\repos\\presence1\\Demo\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\adm\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "O3GkfNM2ZvQ=",
|
||||
"dgSpecHash": "u1UuBtFmr6Y=",
|
||||
"success": true,
|
||||
"projectFilePath": "C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\Demo.csproj",
|
||||
"projectFilePath": "C:\\Users\\adm\\source\\repos\\presence1\\Demo\\Demo.csproj",
|
||||
"expectedPackageFiles": [
|
||||
"C:\\Users\\adm\\.nuget\\packages\\humanizer.core\\2.14.1\\humanizer.core.2.14.1.nupkg.sha512",
|
||||
"C:\\Users\\adm\\.nuget\\packages\\microsoft.bcl.asyncinterfaces\\6.0.0\\microsoft.bcl.asyncinterfaces.6.0.0.nupkg.sha512",
|
||||
|
Loading…
Reference in New Issue
Block a user