bigDisplayForGroup

This commit is contained in:
Your Name 2024-10-28 13:39:15 +03:00
parent 86b4759087
commit de2cdcb08b
17 changed files with 139 additions and 5 deletions

View File

@ -9,5 +9,5 @@ namespace Demo.Domain.Models{
if (other == null) return false;
return this.Guid.Equals(other.Guid);
}
}
}
}

View File

@ -6,6 +6,7 @@ namespace Demo.Data.Repository
{
List<UserLocalEntity> GetAllUser();
UserLocalEntity? GetUserByGuid(Guid guid);
List<UserLocalEntity> GetUsersByGroupID(int groupID);
bool RemoveUserByGuid(Guid guid);
UserLocalEntity? UpdateUser(UserLocalEntity updatedUser);
}

View File

@ -25,6 +25,19 @@ namespace Demo.Data.Repository
return new UserLocalEntity{FIO = userDAO.FIO, GroupID = userDAO.GroupID, Guid = guid};
}
public List<UserLocalEntity> GetUsersByGroupID(int groupID)
{
return _remoteDatabaseContext.Users
.Where(x => x.GroupID == groupID) // Фильтруем пользователей по GroupID
.Select(x => new UserLocalEntity
{
FIO = x.FIO,
Guid = x.Guid,
GroupID = x.GroupID // Устанавливаем фактический GroupID
})
.ToList();
}
public bool RemoveUserByGuid(Guid guid){
var userDAO = _remoteDatabaseContext.Users.FirstOrDefault(x => x.Guid == guid);
_remoteDatabaseContext.Users.Remove(userDAO);

View File

@ -6,6 +6,9 @@ namespace Demo.Domain.UseCase
{
List<Presence> GetPresenceByGroup(int groupID);
List<Presence> GetPresenceByGroupByTime(int groupID, DateOnly date);
List<Presence> GetPresenceByUser(Guid userGuid);
List<Presence> GetFalsePresenceByUser(Guid userGuid);
List<Presence> GetFalsePresenceByGroup(int groupID);
bool IsAttedance(int firstLesson, int lastLesson, DateOnly date, Guid UserGuid);
bool GeneratePresence(int firstLesson, int lastLesson, int groupID, DateOnly date);
bool GeneratePresenceWeek(int firstLesson, int lastLesson, int groupID, DateOnly date);

View File

@ -8,5 +8,6 @@ namespace Demo.Domain.UseCase
bool RemoveUserByGuid(Guid userGuid);
User UpdateUser(User user);
User GetUserByGuid(Guid userGuid);
List<User> GetUsersByGroupID(int groupID);
}
}

View File

@ -40,6 +40,73 @@ namespace Demo.Domain.UseCase
return presenceByGroup;
}
public List<Presence> GetFalsePresenceByGroup(int groupID){
var usersByGroup = _repositoryUserImpl.GetAllUser()
.Where(user => user.GroupID == groupID).ToList();
var presenceByGroup = _repositoryPresenceImpl.GetAllPresences()
.Where(x => usersByGroup.Any(user => user.Guid == x.UserGuid) && x.IsAttedance == false)
.Select(presence => new Presence{
User = new User{
Guid = presence.UserGuid,
Group = new Group{
ID = groupID,
Name = _repositoryGroupImpl.GetAllGroup().First(group => group.ID == groupID).Name
},
FIO = usersByGroup.First(user => user.Guid == presence.UserGuid).FIO,
},
LessonNumber = presence.LessonNumber,
Date = presence.Date,
IsAttedance = presence.IsAttedance
}).ToList();
return presenceByGroup;
}
public List<Presence> GetPresenceByUser(Guid userGuid){
var user = _repositoryUserImpl.GetUserByGuid(userGuid);
var presenceByUser = _repositoryPresenceImpl.GetAllPresences()
.Where(user => userGuid == user.UserGuid)
.Select(presence => new Presence{
User = new User{
Guid = user.Guid,
Group = new Group{
ID = user.GroupID,
Name = _repositoryGroupImpl.GetAllGroup().First(group => group.ID == user.GroupID).Name
},
FIO = user.FIO
},
LessonNumber = presence.LessonNumber,
Date = presence.Date,
IsAttedance = presence.IsAttedance
}).ToList();
return presenceByUser;
}
public List<Presence> GetFalsePresenceByUser(Guid userGuid){
var user = _repositoryUserImpl.GetUserByGuid(userGuid);
var presenceByUser = _repositoryPresenceImpl.GetAllPresences()
.Where(user => userGuid == user.UserGuid && user.IsAttedance == false)
.Select(presence => new Presence{
User = new User{
Guid = user.Guid,
Group = new Group{
ID = user.GroupID,
Name = _repositoryGroupImpl.GetAllGroup().First(group => group.ID == user.GroupID).Name
},
FIO = user.FIO
},
LessonNumber = presence.LessonNumber,
Date = presence.Date,
IsAttedance = presence.IsAttedance
}).ToList();
return presenceByUser;
}
public List<Presence> GetPresenceByGroupByTime(int groupID, DateOnly date){
var usersByGroup = _repositoryUserImpl.GetAllUser()
.Where(user => user.GroupID == groupID).ToList();

View File

@ -44,6 +44,23 @@ namespace Demo.Domain.UseCase
};
}
public List<User> GetUsersByGroupID(int groupID){
List<UserLocalEntity> localUsers = _repositoryUserImpl.GetUsersByGroupID(groupID);
if (localUsers == null) throw new Exception("bello");
Group? group = GetAllGroups().FirstOrDefault(it => groupID == it.ID);
if (group == null) throw new Exception("bello");
List<User> users = localUsers.Select(userLocal => new User{
FIO = userLocal.FIO,
Guid = userLocal.Guid,
Group = new Group{
Name = group.Name,
ID = group.ID
}
}).ToList();
return users;
}
public bool RemoveUserByGuid(Guid userGuid) {
return _repositoryUserImpl.RemoveUserByGuid(userGuid);
}

View File

@ -12,7 +12,7 @@ namespace Demo.UI
public MainMenuUI(IUserUseCase userUseCase, IGroupUseCase groupUseCase, IPresenceUseCase presenceUseCase) {
_userConsoleUI = new UserConsoleUI(userUseCase);
_groupConsoleUI = new GroupConsoleUI(groupUseCase);
_groupConsoleUI = new GroupConsoleUI(groupUseCase, userUseCase, presenceUseCase);
_presenceConsoleUI = new PresenceConsoleUI(presenceUseCase);
DisplayMenu();
@ -23,6 +23,7 @@ namespace Demo.UI
{
switch (Console.ReadLine())
{
case "0": _groupConsoleUI.DisplayAllBoutGroup(Convert.ToInt32(Console.ReadLine())); break;
case "1": _groupConsoleUI.DisplayAllGroups(); break;
case "2": _groupConsoleUI.CreateNewGroup(Console.ReadLine()); break;
case "3": _groupConsoleUI.UpdateGroupName(Group.Parse(Console.ReadLine())); break;

View File

@ -1,3 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Text;
using Demo.Domain.Models;
using Demo.Domain.UseCase;
@ -53,8 +54,12 @@ namespace Demo.UI
public class GroupConsoleUI
{
IGroupUseCase _groupUseCase;
public GroupConsoleUI(IGroupUseCase groupUseCase){
IUserUseCase _userUseCase;
IPresenceUseCase _presenceUseCase;
public GroupConsoleUI(IGroupUseCase groupUseCase, IUserUseCase userUseCase, IPresenceUseCase presenceUseCase){
_groupUseCase = groupUseCase;
_userUseCase = userUseCase;
_presenceUseCase = presenceUseCase;
}
public void DisplayAllGroups(){
@ -99,6 +104,32 @@ namespace Demo.UI
string output = _groupUseCase.RemoveGroupByID(ID) ? "Группа удалена" : "Группа не удалена";
Console.WriteLine(output);
}
public void DisplayAllBoutGroup(int groupID){
var users = _userUseCase.GetUsersByGroupID(groupID);
Console.WriteLine($"Группа: {groupID}\tКоличество учеников: {users.Count}");
var presencesByGroup = _presenceUseCase.GetPresenceByGroup(groupID);
var presenceFalseByGroup = _presenceUseCase.GetFalsePresenceByGroup(groupID);
var precentePresenceGroup = 100 - Math.Round((double)presenceFalseByGroup.Count / presencesByGroup.Count * 100);
Console.WriteLine($"Количество занятий: {presencesByGroup.Count}\tОбщий процент посещаемости: {precentePresenceGroup}");
foreach(var user in _userUseCase.GetUsersByGroupID(groupID)){
var countPresences = _presenceUseCase.GetPresenceByUser(user.Guid);
var countFalsePresences = _presenceUseCase.GetFalsePresenceByUser(user.Guid);
var precentePresenceUser = 100 - Math.Round((double)countFalsePresences.Count / countPresences.Count * 100);
if (precentePresenceUser < 40)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"FIO: {user.FIO}\tКоличество посещённых занятий: {countPresences.Count - countFalsePresences.Count}\tКоличество пропущенных занятий: {countFalsePresences.Count}\tПроцент посещаемости: {precentePresenceUser}");
Console.ResetColor();
}
else
{
Console.WriteLine($"FIO: {user.FIO}\tКоличество посещённых занятий: {countPresences.Count - countFalsePresences.Count}\tКоличество пропущенных занятий: {countFalsePresences.Count}\tПроцент посещаемости: {precentePresenceUser}");
}
}
}
}
public class PresenceConsoleUI{

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,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+ea99225579b2fe5759998c1d40840070bd9463e0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+86b4759087deeb63dff8a43a0ff879e320f29457")]
[assembly: System.Reflection.AssemblyProductAttribute("Demo")]
[assembly: System.Reflection.AssemblyTitleAttribute("Demo")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
80d5c4821e3ff98a41b6c458f427344bd492e44a8a96d916098f8470ef998b85
06f206715bfe1384818fd42aad58f6d1ef0f893f41ccdcce066ace7c594fd406

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.