This commit is contained in:
parent
fffc809c12
commit
d8c07ebb08
@ -1,17 +1,21 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using Zurnal.RemaDateBase.DateDao;
|
using Zurnal.RemaDateBase.DateDao;
|
||||||
|
|
||||||
public class GroupAttendanceService
|
public class GroupAttendanceService
|
||||||
{
|
{
|
||||||
private List<PresnceDao> attendances;
|
private List<PresnceDao> attendances;
|
||||||
|
|
||||||
public void DisplayGroupInfo()
|
public GroupAttendanceService(List<PresnceDao> records)
|
||||||
|
{
|
||||||
|
attendances = records;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisplayGroupInfo(Guid userGuid, object GroupName, IEnumerable<UserDao> users)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Группа: {GroupName}");
|
Console.WriteLine($"Группа: {GroupName}");
|
||||||
Console.WriteLine($"Количество студентов: {Count()}");
|
Console.WriteLine($"Количество студентов: {users.Count()}");
|
||||||
|
|
||||||
var totalClasses = new AttendanceCounter(attendances).CountAttendances(userGuid);
|
var totalClasses = new AttendanceCounter(attendances).CountAttendances(userGuid);
|
||||||
Console.WriteLine($"Количество проведенных занятий: {totalClasses}");
|
Console.WriteLine($"Количество проведенных занятий: {totalClasses}");
|
||||||
@ -20,7 +24,7 @@ public class GroupAttendanceService
|
|||||||
Console.WriteLine($"Общий процент посещаемости: {overallAttendancePercentage:F2}%");
|
Console.WriteLine($"Общий процент посещаемости: {overallAttendancePercentage:F2}%");
|
||||||
Console.WriteLine("Список студентов:");
|
Console.WriteLine("Список студентов:");
|
||||||
|
|
||||||
foreach (var user in Group.Users)
|
foreach (var user in users)
|
||||||
{
|
{
|
||||||
var attendanceInfo = GetAttendanceInfo(user);
|
var attendanceInfo = GetAttendanceInfo(user);
|
||||||
Console.WriteLine($"{user.FIO}: Посещенные занятия: {attendanceInfo.AttendedClasses}, Пропущенные занятия: {attendanceInfo.MissedClasses}, Процент посещаемости: {attendanceInfo.AttendancePercentage:F2}%");
|
Console.WriteLine($"{user.FIO}: Посещенные занятия: {attendanceInfo.AttendedClasses}, Пропущенные занятия: {attendanceInfo.MissedClasses}, Процент посещаемости: {attendanceInfo.AttendancePercentage:F2}%");
|
||||||
@ -40,11 +44,6 @@ public class GroupAttendanceService
|
|||||||
{
|
{
|
||||||
return _attendances.Count(a => a.UserGuid == userGuid && a.IsAttendensy);
|
return _attendances.Count(a => a.UserGuid == userGuid && a.IsAttendensy);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object CountAttendances(object userGuid)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double CalculateAttendancePercentage(List<PresnceDao> attendanceRecords, Guid userGuid)
|
public static double CalculateAttendancePercentage(List<PresnceDao> attendanceRecords, Guid userGuid)
|
||||||
@ -60,21 +59,22 @@ public class GroupAttendanceService
|
|||||||
|
|
||||||
private (int AttendedClasses, int MissedClasses, double AttendancePercentage) GetAttendanceInfo(UserDao user)
|
private (int AttendedClasses, int MissedClasses, double AttendancePercentage) GetAttendanceInfo(UserDao user)
|
||||||
{
|
{
|
||||||
private List<PresnceDao> attendanceRecords;
|
var attendanceRecords = this.attendances.Where(record => record.UserGuid == user.UserGuid).ToList();
|
||||||
|
int attendedClasses = attendanceRecords.Count(record => record.IsAttendensy);
|
||||||
|
int missedClasses = attendanceRecords.Count - attendedClasses;
|
||||||
|
double attendancePercentage = attendanceRecords.Count == 0 ? 0 : (double)attendedClasses / attendanceRecords.Count * 100;
|
||||||
|
|
||||||
public AttendanceService(List<PresnceDao> records)
|
return (attendedClasses, missedClasses, attendancePercentage);
|
||||||
{
|
|
||||||
attendanceRecords = records;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PresnceDao> GetAttendanceByUser(Guid userGuid)
|
public List<PresnceDao> GetAttendanceByUser(Guid userGuid)
|
||||||
{
|
{
|
||||||
return attendanceRecords.Where(record => record.UserGuid == userGuid).ToList();
|
return attendances.Where(record => record.UserGuid == userGuid).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<DateOnly, int> GetAttendanceSummary(Guid userGuid)
|
public Dictionary<DateOnly, int> GetAttendanceSummary(Guid userGuid)
|
||||||
{
|
{
|
||||||
var userAttendance = attendanceRecords.Where(record => record.UserGuid == userGuid);
|
var userAttendance = attendances.Where(record => record.UserGuid == userGuid);
|
||||||
var summary = new Dictionary<DateOnly, int>();
|
var summary = new Dictionary<DateOnly, int>();
|
||||||
|
|
||||||
foreach (var record in userAttendance)
|
foreach (var record in userAttendance)
|
||||||
@ -91,5 +91,4 @@ public class GroupAttendanceService
|
|||||||
|
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user