hello
This commit is contained in:
parent
7b40532afd
commit
5d31067f6b
@ -8,7 +8,7 @@ namespace _123.Data.LocalData.Entity
|
||||
{
|
||||
public class PresenceLocalEntity
|
||||
{
|
||||
public required Guid UserGuid { get; set; }
|
||||
public required Guid UserGuid { get; set; }
|
||||
public bool IsAttedance { get; set; } = true;
|
||||
public required DateOnly Date { get; set; }
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using _123.Data.LocalData.Entity;
|
||||
using _123.Data.RemoteData.RemoteDatabase.DAO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
15
123/Data/RemoteData/RemoteDatabase/DAO/Group.cs
Normal file
15
123/Data/RemoteData/RemoteDatabase/DAO/Group.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _123.Data.RemoteData.RemoteDatabase.DAO
|
||||
{
|
||||
public class GroupDao
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public IEnumerable<UserDao> Users { get; set; }
|
||||
}
|
||||
}
|
18
123/Data/RemoteData/RemoteDatabase/DAO/Presence.cs
Normal file
18
123/Data/RemoteData/RemoteDatabase/DAO/Presence.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _123.Data.RemoteData.RemoteDatabase.DAO
|
||||
{
|
||||
public class PresenceDao
|
||||
{
|
||||
public required Guid UserGuid { get; set; }
|
||||
public bool IsAttedance { get; set; } = true;
|
||||
public required DateOnly Date { get; set; }
|
||||
|
||||
public required int LessonNumber { get; set; }
|
||||
public UserDao UserDao { get; set; }
|
||||
}
|
||||
}
|
18
123/Data/RemoteData/RemoteDatabase/DAO/User.cs
Normal file
18
123/Data/RemoteData/RemoteDatabase/DAO/User.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _123.Data.RemoteData.RemoteDatabase.DAO
|
||||
{
|
||||
public class UserDao
|
||||
{
|
||||
public required string UserFIO { get; set; }
|
||||
public Guid UserGuid { get; set; }
|
||||
|
||||
public required int GroupID { get; set; }
|
||||
|
||||
public GroupDao Group { get; set; }
|
||||
}
|
||||
}
|
36
123/Data/RemoteData/RemoteDatabase/RemoteDatabaseContext.cs
Normal file
36
123/Data/RemoteData/RemoteDatabase/RemoteDatabaseContext.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using _123.Data.RemoteData.RemoteDatabase.DAO;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _123.Data.RemoteData.RemoteDatabase
|
||||
{
|
||||
internal class RemoteDatabaseContext: DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseNpgsql();
|
||||
}
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<GroupDao>().HasKey(group => group.ID);
|
||||
modelBuilder.Entity<GroupDao>().Property(group => group.ID).ValueGeneratedOnAdd();
|
||||
modelBuilder.Entity<UserDao>().HasKey(user => user.UserGuid);
|
||||
modelBuilder.Entity<UserDao>().Property(user => user.UserGuid).ValueGeneratedOnAdd();
|
||||
modelBuilder.Entity<PresenceDao>().HasKey(presence => new
|
||||
{
|
||||
presence.UserGuid,
|
||||
presence.Date,
|
||||
presence.IsAttedance,
|
||||
presence.LessonNumber
|
||||
});
|
||||
}
|
||||
public DbSet<GroupDao> Groups { get; set; }
|
||||
public DbSet<UserDao> Users { get; set; }
|
||||
public DbSet<PresenceDao> PresencesDaos { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
using _123.Data.LocalData.Entity;
|
||||
using _123.Data.LocalData;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _123.Data.ReportsHistory
|
||||
{
|
||||
|
||||
public class GroupRepositoryImpl
|
||||
{
|
||||
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
|
||||
|
||||
public GroupLocalEntity? UpdateGroup(String name)
|
||||
{
|
||||
GroupLocalEntity? groupLocal = GetAllGroups()
|
||||
.Where(x => x.Name == name).FirstOrDefault();
|
||||
if (groupLocal == null) return null;
|
||||
groupLocal.Name = name;
|
||||
return groupLocal;
|
||||
}
|
||||
//public GroupLocalEntity AddGroup(String name, String id)
|
||||
//{
|
||||
// List<GroupLocalEntity> groups => new List<GroupLocalEntity>
|
||||
//}
|
||||
}
|
||||
}
|
55
123/Data/Repository/GroupRepositoty.cs
Normal file
55
123/Data/Repository/GroupRepositoty.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using _123.Data.LocalData.Entity;
|
||||
using _123.Data.LocalData;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _123.Data.RemoteData.RemoteDatabase.DAO;
|
||||
|
||||
namespace _123.Data.Repository
|
||||
{
|
||||
|
||||
public class GroupRepositoryImpl: IGroupRepository
|
||||
{
|
||||
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
|
||||
public bool AddGroup(String name,String Id)
|
||||
{
|
||||
GroupLocalEntity? groupLocal = GetAllGroups().FirstOrDefault();
|
||||
groupLocal.Name = name;
|
||||
groupLocal.ID = int.Parse(Id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<GroupLocalEntity> GetAllGroup()
|
||||
{
|
||||
return GetAllGroup();
|
||||
}
|
||||
|
||||
public GroupLocalEntity GetGroupById(int groupID)
|
||||
{
|
||||
GroupLocalEntity? groupLocal = GetAllGroups()
|
||||
.Where(x => x.ID == groupID).FirstOrDefault();
|
||||
if (groupLocal == null) return null;
|
||||
return groupLocal;
|
||||
}
|
||||
|
||||
public bool RemoveGroupById(int groupID)
|
||||
{
|
||||
GroupLocalEntity? userLocal = GetAllGroups()
|
||||
.Where(x => x.ID == groupID).FirstOrDefault();
|
||||
if (userLocal == null) return false;
|
||||
return GetAllGroups().Remove(userLocal);
|
||||
}
|
||||
|
||||
public bool UpdateGroupById(int groupID, String name)
|
||||
{
|
||||
GroupLocalEntity? groupLocal = GetAllGroups()
|
||||
.Where(x => x.ID == groupID).FirstOrDefault();
|
||||
if (groupLocal == null) return false;
|
||||
groupLocal.Name = name;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
123/Data/Repository/IGroupRepository.cs
Normal file
19
123/Data/Repository/IGroupRepository.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using _123.Data.LocalData.Entity;
|
||||
using _123.Data.RemoteData.RemoteDatabase.DAO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _123.Data.Repository
|
||||
{
|
||||
internal interface IGroupRepository
|
||||
{
|
||||
List<GroupLocalEntity> GetAllGroup();
|
||||
bool RemoveGroupById(int groupID);
|
||||
bool UpdateGroupById(int groupID, String name);
|
||||
GroupLocalEntity GetGroupById(int groupID);
|
||||
bool AddGroup(String name, String id);
|
||||
}
|
||||
}
|
19
123/Data/Repository/IPresenceRepository.cs
Normal file
19
123/Data/Repository/IPresenceRepository.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using _123.Data.LocalData.Entity;
|
||||
using _123.Domain.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _123.Data.Repository
|
||||
{
|
||||
interface IPresenceRepository
|
||||
{
|
||||
List<PresenceLocalEntity> GetPresenceByGroup(int groupId);
|
||||
List<PresenceLocalEntity> GetPresenceByGroupAndDate(int groupId, DateOnly date);
|
||||
void UnCheckAttendence (PresenceLocalEntity presence);
|
||||
void AddPresence (PresenceLocalEntity presence);
|
||||
|
||||
}
|
||||
}
|
20
123/Data/Repository/IUserRepository.cs
Normal file
20
123/Data/Repository/IUserRepository.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using _123.Data.LocalData.Entity;
|
||||
using _123.Data.RemoteData.RemoteDatabase.DAO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _123.Data.Repository
|
||||
{
|
||||
internal interface IUserRepository
|
||||
{
|
||||
public List<UserLocalEntity> GetAllUsers();
|
||||
bool RemoveUserByGuid(Guid userGuid);
|
||||
UserLocalEntity FindUserByGuid(Guid userGuid);
|
||||
UserLocalEntity? GetUserByGuid(Guid userGuid);
|
||||
UserLocalEntity? UpdateUser(UserLocalEntity userUpdateLocalEnity);
|
||||
UserLocalEntity? UpdateUserByGuid(Guid userGuid);
|
||||
}
|
||||
}
|
49
123/Data/Repository/PresenceRepository.cs
Normal file
49
123/Data/Repository/PresenceRepository.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using _123.Data.LocalData;
|
||||
using _123.Data.LocalData.Entity;
|
||||
using _123.Domain.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace _123.Data.Repository
|
||||
{
|
||||
public class PresenceRepositoryImpl : IPresenceRepository
|
||||
|
||||
{
|
||||
public PresenceRepositoryImpl()
|
||||
{
|
||||
GetAllPresences = LocalStaticData.presences;
|
||||
}
|
||||
public List<PresenceLocalEntity> GetAllPresences
|
||||
{ get; set; }
|
||||
|
||||
public void AddPresence(PresenceLocalEntity presence)
|
||||
{
|
||||
PresenceLocalEntity? presenceLocal = GetAllPresences.FirstOrDefault();
|
||||
presenceLocal.UserGuid = presence.UserGuid;
|
||||
presenceLocal.Date = presence.Date;
|
||||
presenceLocal.IsAttedance = presence.IsAttedance;
|
||||
presenceLocal.LessonNumber = presence.LessonNumber;
|
||||
|
||||
}
|
||||
|
||||
public List<PresenceLocalEntity> GetPresenceByGroup(int groupId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<PresenceLocalEntity> GetPresenceByGroupAndDate(int groupId, DateOnly date)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UnCheckAttendence(Presence presence)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
using _123.Data.LocalData;
|
||||
using _123.Data.LocalData.Entity;
|
||||
using _123.Data.RemoteData.RemoteDatabase.DAO;
|
||||
using _123.Data.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -9,7 +11,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace _123.Data.ReportsHistory
|
||||
{
|
||||
public class UserRepositoryImpl
|
||||
public class UserRepositoryImpl: IUserRepository
|
||||
{
|
||||
public UserRepositoryImpl()
|
||||
{
|
||||
@ -64,5 +66,9 @@ namespace _123.Data.ReportsHistory
|
||||
|
||||
}
|
||||
|
||||
List<UserLocalEntity> IUserRepository.GetAllUsers()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Data\RemoteData\" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkcore" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkcore.Design" Version="8.0.10">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _123.Domain.Models;
|
||||
using _123.Data.LocalData.Entity;
|
||||
using _123.Data.Repository;
|
||||
|
||||
namespace _123.Domain.UseCase
|
||||
{
|
||||
@ -19,13 +20,13 @@ namespace _123.Domain.UseCase
|
||||
public List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroups()
|
||||
.Select(it => new Group { ID = it.ID, Name = it.Name }).ToList();
|
||||
|
||||
public Group UpdateGroupName(String name, String name1)
|
||||
public bool UpdateGroupName(String id, String name1)
|
||||
{
|
||||
GroupLocalEntity? result = _repositoryGroupImpl.UpdateGroup(name);
|
||||
if (result == null) throw new Exception("");
|
||||
Group? group = GetAllGroups().FirstOrDefault(it => it.Name == result!.Name);
|
||||
if (group == null) throw new Exception("");
|
||||
return new Group { ID = group.ID, Name = name1 };
|
||||
return _repositoryGroupImpl.UpdateGroupById(int.Parse(id), name1);
|
||||
}
|
||||
public bool AddGroup(String name, string id)
|
||||
{
|
||||
return _repositoryGroupImpl.AddGroup(name, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
12
123/Domain/UseCase/PresenceUseCase.cs
Normal file
12
123/Domain/UseCase/PresenceUseCase.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _123.Domain.UseCase
|
||||
{
|
||||
class PresenceUseCase
|
||||
{
|
||||
}
|
||||
}
|
13
123/Domain/UseCase/UseCaseGeneratePresence.cs
Normal file
13
123/Domain/UseCase/UseCaseGeneratePresence.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _123.Domain.UseCase
|
||||
{
|
||||
internal class UseCaseGeneratePresence
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
using _123.Data.LocalData.Entity;
|
||||
using _123.Data.RemoteData.RemoteDatabase.DAO;
|
||||
using _123.Data.ReportsHistory;
|
||||
using _123.Data.Repository;
|
||||
using _123.Domain.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -11,8 +13,10 @@ namespace _123.Domain.UseCase
|
||||
{
|
||||
public class UserUseCase
|
||||
{
|
||||
private UserRepositoryImpl _repositoryUserImpl;
|
||||
private GroupRepositoryImpl _repositoryGroupImpl;
|
||||
//private readonly UserRepositoryImpl _repositoryUserImpl;
|
||||
//private readonly GroupRepositoryImpl _repositoryGroupImpl;
|
||||
private readonly UserRepositoryImpl _repositoryUserImpl;
|
||||
private readonly IGroupRepository _repositoryGroupImpl;
|
||||
|
||||
public UserUseCase(UserRepositoryImpl repositoryImpl, GroupRepositoryImpl repositoryGroupImpl)
|
||||
{
|
||||
@ -20,10 +24,10 @@ namespace _123.Domain.UseCase
|
||||
_repositoryGroupImpl = repositoryGroupImpl;
|
||||
}
|
||||
|
||||
public List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroups()
|
||||
public List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroup()
|
||||
.Select(it => new Group { ID = it.ID, Name = it.Name }).ToList();
|
||||
public List<User> GetAllUsers() => _repositoryUserImpl.GetAllUsers
|
||||
.Join(_repositoryGroupImpl.GetAllGroups(),
|
||||
private List<User> GetAllUsers() => _repositoryUserImpl.GetAllUsers
|
||||
.Join(_repositoryGroupImpl.GetAllGroup(),
|
||||
user => user.GroupID,
|
||||
group => group.ID,
|
||||
(user, group) =>
|
||||
|
@ -1,6 +1,15 @@
|
||||
using _123.Data.ReportsHistory;
|
||||
using _123.Data.Repository;
|
||||
using _123.Domain.UseCase;
|
||||
using _123.UI;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
IServiceCollection services = new ServiceCollection();
|
||||
services
|
||||
.AddSingleton<IGroupRepository, GroupRepositoryImpl>()
|
||||
.AddSingleton<UserUseCase>();
|
||||
var serviceProvider = services.BuildServiceProvider ();
|
||||
|
||||
GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl();
|
||||
UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl();
|
||||
|
@ -33,5 +33,15 @@ namespace _123.UI
|
||||
}
|
||||
Console.WriteLine(groupOutput);
|
||||
}
|
||||
public void AddGroup (String name, String id)
|
||||
{
|
||||
StringBuilder groupOutput = new StringBuilder();
|
||||
var group = _groupUseCase.AddGroup(name,id);
|
||||
{
|
||||
groupOutput.AppendLine($"{group.Name}\t{group.ID}");
|
||||
}
|
||||
Console.WriteLine(groupOutput);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -34,7 +34,8 @@ namespace _123.UI
|
||||
case "3": _groupConsoleUI.DisplayAllGroups(); break;
|
||||
case "4": _userConsoleUI.FindUserByGuid(Guid.Parse(Console.ReadLine()));break;
|
||||
case "5": _userConsoleUI.UpdateUserByGuid(Guid.Parse(Console.ReadLine()),Console.ReadLine(), Console.ReadLine()); break;
|
||||
case "6": _groupConsoleUI.UpdateGroupName(Console.ReadLine(),Console.ReadLine()); break;
|
||||
case "6": _groupConsoleUI.UpdateGroupName(Console.ReadLine(),Console.ReadLine()); break;
|
||||
case "7": _groupConsoleUI.AddGroup(Console.ReadLine(), Console.ReadLine());break;
|
||||
default:
|
||||
DisplayMenu();
|
||||
break;
|
||||
|
12
123/UI/PresenceConsole.cs
Normal file
12
123/UI/PresenceConsole.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _123.UI
|
||||
{
|
||||
internal class PresenceConsole
|
||||
{
|
||||
}
|
||||
}
|
BIN
Загрузки - Ярлык.lnk
Normal file
BIN
Загрузки - Ярлык.lnk
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user