Logs;Extensions

This commit is contained in:
Your Name 2024-11-21 15:27:51 +03:00
parent 1be6e426f7
commit 9b3cfbc400
47 changed files with 297 additions and 141 deletions

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("console_ui")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6c6c0936f5e12ba65625b810a3751f41f19d78bc")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8d435f71b5721c711cb9dad7ab5782dcef034f90")]
[assembly: System.Reflection.AssemblyProductAttribute("console_ui")]
[assembly: System.Reflection.AssemblyTitleAttribute("console_ui")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
9b1464a1a381c026e523ead07c5c0bd2c1fc254caae642a9c0dc293c388a5267
fcb9cb787b816ab3834bc04682c26c8d4aa31776dacf72b5b63de8786566ad86

View File

@ -23,6 +23,7 @@ namespace Demo.Data.Repository
public UserLocalEntity? GetUserByGuid(Guid guid){
var userDAO = _remoteDatabaseContext.Users.FirstOrDefault(x => x.Guid == guid);
if (userDAO == null) return null;
return new UserLocalEntity{FIO = userDAO.FIO, GroupID = userDAO.GroupID, Guid = guid};
}

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("data")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6c6c0936f5e12ba65625b810a3751f41f19d78bc")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8d435f71b5721c711cb9dad7ab5782dcef034f90")]
[assembly: System.Reflection.AssemblyProductAttribute("data")]
[assembly: System.Reflection.AssemblyTitleAttribute("data")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
1717865c1f3ea8eb394c6de25814487453eeb08c49cfa440b8caad21b340b555
4bdad9cb9dbe9a4bbb133ff745306a1ea490f7961d9350beff628cc509c45b3d

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -32,9 +32,9 @@ namespace Demo.Domain.UseCase
public User GetUserByGuid(Guid userGuid){
UserLocalEntity? userLocalEntity = _repositoryUserImpl.GetUserByGuid(userGuid);
if (userLocalEntity == null) throw new Exception("bello");
if (userLocalEntity == null) return null;
Group? group = GetAllGroups().FirstOrDefault(it => userLocalEntity.GroupID == it.ID);
if (group == null) throw new Exception("bello");
if (group == null) return null;
return new User{
FIO = userLocalEntity.FIO,
Guid = userLocalEntity.Guid,

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("domain")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6c6c0936f5e12ba65625b810a3751f41f19d78bc")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8d435f71b5721c711cb9dad7ab5782dcef034f90")]
[assembly: System.Reflection.AssemblyProductAttribute("domain")]
[assembly: System.Reflection.AssemblyTitleAttribute("domain")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
7cd83e005f219e7f461ddb8b33cfed5348a98ea55d97b78c917596cc14252493
51f0b800e5221e0557228a48bda04ba517dabcc7d9458bdda1aa141fab7b4f18

Binary file not shown.

Binary file not shown.

View File

@ -25,7 +25,7 @@ public class AdminController: ControllerBase{
{
if (request == null || string.IsNullOrEmpty(request.GroupName))
{
_logger.LogWarning("NotFound");
_logger.LogWarning("CreateGroup: Invalid request");
return BadRequest("Invalid request");
}
@ -43,12 +43,12 @@ public class AdminController: ControllerBase{
[HttpDelete("user")]
public ActionResult<bool> DeleteUser(Guid userGuid){
if (userGuid == Guid.Empty){
_logger.LogWarning("Invalid request");
_logger.LogWarning("DeleteUser: Invalid Guid or empty");
return BadRequest("Invalid request");
}
bool isDeleted = _userUseCase.RemoveUserByGuid(userGuid);
if (isDeleted == false){
_logger.LogWarning("NotFound");
_logger.LogWarning("DeleteUser: User with Guid '{UserGuid}' not found", userGuid);
return NotFound("User not found");
}
return Ok(true);
@ -57,14 +57,14 @@ public class AdminController: ControllerBase{
[HttpDelete("users")]
public ActionResult<bool> DeleteUsers([FromBody] DeleteUsersRequest request){
if (request == null){
_logger.LogWarning("Invalid request");
_logger.LogWarning("DeleteUsers: Invalid request");
return BadRequest("Invalid request");
}
foreach (Guid userGuid in request.UsersGuid)
{
bool isDeleted = _userUseCase.RemoveUserByGuid(userGuid);
if (isDeleted == false){
_logger.LogWarning("NotFound");
_logger.LogWarning("DeleteUsers: User with Guid '{UserGuid}' not found", userGuid);
return NotFound("User not found");
}
}
@ -75,7 +75,7 @@ public class AdminController: ControllerBase{
public ActionResult<bool> DeleteGroup(int GroupID){
bool isDeleted = _groupUseCase.RemoveGroupByID(GroupID);
if (isDeleted == false){
_logger.LogWarning("NotFound");
_logger.LogWarning("DeleteGroup: Group with GroupID '{GroupID}' not found", GroupID);
return NotFound("Group not found");
}
return Ok(true);
@ -84,14 +84,14 @@ public class AdminController: ControllerBase{
[HttpDelete("groups")]
public ActionResult<bool> DeleteGroups([FromBody] DeleteGroupsRequest request){
if (request == null){
_logger.LogWarning("Invalid request");
_logger.LogWarning("DeleteGroups: Invalid request");
return BadRequest("Invalid request");
}
foreach (int GroupID in request.GroupIDs)
{
bool isDeleted = _groupUseCase.RemoveGroupByID(GroupID);
if (isDeleted == false){
_logger.LogWarning("NotFound");
_logger.LogWarning("DeleteGroup: Group with GroupID '{GroupID}' not found", GroupID);
return NotFound("Group not found");
}
}
@ -115,9 +115,10 @@ public class AdminController: ControllerBase{
{
var user = _userUseCase.GetUserByGuid(userGuid);
if (user != null){
_logger.LogWarning("found");
return Ok(user);
} else{
_logger.LogWarning("NotFound");
_logger.LogWarning("GetUserByGuid: User with Guid '{UserGuid}' not found", userGuid);
return NotFound("User not found");
}
}

View File

@ -39,8 +39,8 @@ public class PresenceController: ControllerBase{
public ActionResult<bool> GeneratePresence([FromBody] PresencePost request)
{
if (request == null){
_logger.LogWarning("NotFound");
return BadRequest("buba");
_logger.LogWarning("GeneratePresence: Invalid request");
return BadRequest("Invalid request");
}
DateOnly.TryParse(request.date, out DateOnly date);
@ -56,8 +56,8 @@ public class PresenceController: ControllerBase{
var isDeleted = _presenceUseCase.DeletePresenceByGroup(groupID);
if (isDeleted == false)
{
_logger.LogWarning("NotFound");
return NotFound("buba");
_logger.LogWarning("DeletePresenceByGroup: Presence with groupID '{groupID}' not found", groupID);
return NotFound("Presence not found");
}
return isDeleted;
}
@ -68,8 +68,8 @@ public class PresenceController: ControllerBase{
var isDeleted = _presenceUseCase.DeletePresenceByUser(userGuid);
if (isDeleted == false)
{
_logger.LogWarning("NotFound");
return NotFound("buba");
_logger.LogWarning("DeletePresenceByUser: Presence with userGuid '{userGuid}' not found", userGuid);
return NotFound("Presence not found");
}
return isDeleted;
}
@ -82,8 +82,8 @@ public class PresenceController: ControllerBase{
var isDeleted = _presenceUseCase.DeletePresenceByRange(start, end);
if (isDeleted == false)
{
_logger.LogWarning("NotFound");
return NotFound("buba");
_logger.LogWarning("DeletePresenceByRange: Presence with range '{start}' - '{end}' not found", start, end);
return NotFound("Presence not found");
}
return isDeleted;
}
@ -97,8 +97,8 @@ public class PresenceController: ControllerBase{
var isUpdated = _presenceUseCase.IsAttedance(request.firstLesson, request.lastLesson, date, request.UserGuid);
if (isUpdated == false)
{
_logger.LogWarning("NotFound");
return NotFound("buba");
_logger.LogWarning("UpdatePresence: Presence with data from request not found");
return NotFound("Presence not found");
}
return isUpdated;
}

View File

@ -7,7 +7,10 @@ builder.Services.AddDbContext<RemoteDatabaseContext>();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.ConfigurateGroup();
// builder.Services.ConfigurateGroup();
builder.Services.AddGroupServices();
builder.Services.AddUserServices();
builder.Services.AddPresenceServices();
var app = builder.Build();

View File

@ -3,13 +3,31 @@ using Demo.Domain.UseCase;
public static class ServiceExtencions
{
public static void ConfigurateGroup(this IServiceCollection services)
// public static void ConfigurateGroup(this IServiceCollection services)
// {
// services.AddScoped<IGroupRepository, SQLGroupRepositoryImpl>()
// .AddScoped<IUserRepository, SQLUserRepositoryImpl>()
// .AddScoped<IPresenceRepository, SQLPresenceRepositoryImpl>()
// .AddScoped<GroupUseCase>()
// .AddScoped<UserUseCase>()
// .AddScoped<PresenceUseCase>();
// }
public static void AddGroupServices(this IServiceCollection services)
{
services.AddScoped<IGroupRepository, SQLGroupRepositoryImpl>()
.AddScoped<IUserRepository, SQLUserRepositoryImpl>()
.AddScoped<IPresenceRepository, SQLPresenceRepositoryImpl>()
.AddScoped<GroupUseCase>()
.AddScoped<UserUseCase>()
.AddScoped<GroupUseCase>();
}
public static void AddUserServices(this IServiceCollection services)
{
services.AddScoped<IUserRepository, SQLUserRepositoryImpl>()
.AddScoped<UserUseCase>();
}
public static void AddPresenceServices(this IServiceCollection services)
{
services.AddScoped<IPresenceRepository, SQLPresenceRepositoryImpl>()
.AddScoped<PresenceUseCase>();
}
}

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("presence_api")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6c6c0936f5e12ba65625b810a3751f41f19d78bc")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8d435f71b5721c711cb9dad7ab5782dcef034f90")]
[assembly: System.Reflection.AssemblyProductAttribute("presence_api")]
[assembly: System.Reflection.AssemblyTitleAttribute("presence_api")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
ad0d9bd61813c0a35cbd8c85f8db96d734d0fcd658f5913b10790b5aa3eb50a5
c3f230f6647ac6a2f215b94432a354594bcd758939c2e8860e567861fa31d7ba

88
ui/GroupConsole.cs Normal file
View File

@ -0,0 +1,88 @@
using System.ComponentModel.DataAnnotations;
using System.Text;
using Demo.Domain.Models;
using Demo.Domain.UseCase;
namespace Demo.UI
{
public class GroupConsoleUI
{
IGroupUseCase _groupUseCase;
IUserUseCase _userUseCase;
IPresenceUseCase _presenceUseCase;
public GroupConsoleUI(IGroupUseCase groupUseCase, IUserUseCase userUseCase, IPresenceUseCase presenceUseCase){
_groupUseCase = groupUseCase;
_userUseCase = userUseCase;
_presenceUseCase = presenceUseCase;
}
public void DisplayAllGroups(){
StringBuilder userOutput = new StringBuilder();
foreach (var group in _groupUseCase.GetAllGroups())
{
userOutput.AppendLine($"{group.ID}\t{group.Name}");
}
Console.WriteLine(userOutput);
}
public void DisplayGroupByID(int ID){
StringBuilder userOutput = new StringBuilder();
var group = _groupUseCase.GetGroupById(ID);
{
userOutput.AppendLine($"{group.ID}\t{group.Name}");
}
Console.WriteLine(userOutput);
}
public void CreateNewGroup(string Name){
string output = _groupUseCase.CreateGroup(Name) ? "Группа создана" : "Группа не создана";
Console.WriteLine(output);
}
public void UpdateGroupName(Group group)
{
try
{
Group output = _groupUseCase.UpdateGroup(group);
StringBuilder groupOutput = new StringBuilder();
groupOutput.AppendLine($"Обновленная группа: {output.ID}\t{output.Name}");
Console.WriteLine(groupOutput);
}
catch (Exception ex)
{
Console.WriteLine($"Ошибка при обновлении группы: {ex.Message}");
}
}
public void RemoveGroupByID(int ID){
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}");
}
}
}
}
}

45
ui/PresenceConsole.cs Normal file
View File

@ -0,0 +1,45 @@
using System.ComponentModel.DataAnnotations;
using System.Text;
using Demo.Domain.Models;
using Demo.Domain.UseCase;
namespace Demo.UI
{
public class PresenceConsoleUI{
IPresenceUseCase _presenceUseCase;
public PresenceConsoleUI (IPresenceUseCase presenceUseCase){
_presenceUseCase = presenceUseCase;
}
public void DisplayPresenceByGroup(int groupID){
StringBuilder stringBuilder = new StringBuilder();
foreach(Presence presence in _presenceUseCase.GetPresenceByGroup(groupID)){
stringBuilder.AppendLine($"{presence.User.FIO}, {presence.User.Group.Name}, {presence.IsAttedance}, {presence.Date}, {presence.LessonNumber}");
}
Console.WriteLine(stringBuilder);
}
public void DisplayPresenceByGroupByTime(int groupID, DateOnly date){
StringBuilder stringBuilder = new StringBuilder();
foreach(Presence presence in _presenceUseCase.GetPresenceByGroupByTime(groupID, date)){
stringBuilder.AppendLine($"{presence.User.FIO}, {presence.User.Group.Name}, {presence.IsAttedance}, {presence.Date}, {presence.LessonNumber}");
}
Console.WriteLine(stringBuilder);
}
public void GeneratePresence(int firstLesson, int lastLesson, int groupID, DateOnly date){
string output = _presenceUseCase.GeneratePresence(firstLesson, lastLesson, groupID, date) ? "Сгенерированно" : "Не сгенерированно";
Console.WriteLine(output);
}
public void GeneratePresenceWeek(int firstLesson, int lastLesson, int groupID, DateOnly date){
string output = _presenceUseCase.GeneratePresenceWeek(firstLesson, lastLesson, groupID, date) ? "Сгенерированно" : "Не сгенерированно";
Console.WriteLine(output);
}
public void IsAttedance(int firstLesson, int lastLesson, DateOnly date, Guid UserGuid){
string output = _presenceUseCase.IsAttedance(firstLesson, lastLesson, date, UserGuid) ? "Обновлено" : "Не обновлено";
Console.WriteLine(output);
}
}
}

View File

@ -51,122 +51,122 @@ namespace Demo.UI
}
}
public class GroupConsoleUI
{
IGroupUseCase _groupUseCase;
IUserUseCase _userUseCase;
IPresenceUseCase _presenceUseCase;
public GroupConsoleUI(IGroupUseCase groupUseCase, IUserUseCase userUseCase, IPresenceUseCase presenceUseCase){
_groupUseCase = groupUseCase;
_userUseCase = userUseCase;
_presenceUseCase = presenceUseCase;
}
// public class GroupConsoleUI
// {
// IGroupUseCase _groupUseCase;
// IUserUseCase _userUseCase;
// IPresenceUseCase _presenceUseCase;
// public GroupConsoleUI(IGroupUseCase groupUseCase, IUserUseCase userUseCase, IPresenceUseCase presenceUseCase){
// _groupUseCase = groupUseCase;
// _userUseCase = userUseCase;
// _presenceUseCase = presenceUseCase;
// }
public void DisplayAllGroups(){
StringBuilder userOutput = new StringBuilder();
foreach (var group in _groupUseCase.GetAllGroups())
{
userOutput.AppendLine($"{group.ID}\t{group.Name}");
}
Console.WriteLine(userOutput);
}
// public void DisplayAllGroups(){
// StringBuilder userOutput = new StringBuilder();
// foreach (var group in _groupUseCase.GetAllGroups())
// {
// userOutput.AppendLine($"{group.ID}\t{group.Name}");
// }
// Console.WriteLine(userOutput);
// }
public void DisplayGroupByID(int ID){
StringBuilder userOutput = new StringBuilder();
var group = _groupUseCase.GetGroupById(ID);
{
userOutput.AppendLine($"{group.ID}\t{group.Name}");
}
Console.WriteLine(userOutput);
}
// public void DisplayGroupByID(int ID){
// StringBuilder userOutput = new StringBuilder();
// var group = _groupUseCase.GetGroupById(ID);
// {
// userOutput.AppendLine($"{group.ID}\t{group.Name}");
// }
// Console.WriteLine(userOutput);
// }
public void CreateNewGroup(string Name){
string output = _groupUseCase.CreateGroup(Name) ? "Группа создана" : "Группа не создана";
Console.WriteLine(output);
}
// public void CreateNewGroup(string Name){
// string output = _groupUseCase.CreateGroup(Name) ? "Группа создана" : "Группа не создана";
// Console.WriteLine(output);
// }
public void UpdateGroupName(Group group)
{
try
{
Group output = _groupUseCase.UpdateGroup(group);
StringBuilder groupOutput = new StringBuilder();
groupOutput.AppendLine($"Обновленная группа: {output.ID}\t{output.Name}");
Console.WriteLine(groupOutput);
}
catch (Exception ex)
{
Console.WriteLine($"Ошибка при обновлении группы: {ex.Message}");
}
}
// public void UpdateGroupName(Group group)
// {
// try
// {
// Group output = _groupUseCase.UpdateGroup(group);
// StringBuilder groupOutput = new StringBuilder();
// groupOutput.AppendLine($"Обновленная группа: {output.ID}\t{output.Name}");
// Console.WriteLine(groupOutput);
// }
// catch (Exception ex)
// {
// Console.WriteLine($"Ошибка при обновлении группы: {ex.Message}");
// }
// }
public void RemoveGroupByID(int ID){
string output = _groupUseCase.RemoveGroupByID(ID) ? "Группа удалена" : "Группа не удалена";
Console.WriteLine(output);
}
// public void RemoveGroupByID(int ID){
// string output = _groupUseCase.RemoveGroupByID(ID) ? "Группа удалена" : "Группа не удалена";
// Console.WriteLine(output);
// }
public void DisplayAllBoutGroup(int groupID){
var users = _userUseCase.GetUsersByGroupID(groupID);
Console.WriteLine($"Группа: {groupID}\tКоличество учеников: {users.Count}");
// 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}");
// 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}");
}
}
}
}
// 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{
IPresenceUseCase _presenceUseCase;
public PresenceConsoleUI (IPresenceUseCase presenceUseCase){
_presenceUseCase = presenceUseCase;
}
// public class PresenceConsoleUI{
// IPresenceUseCase _presenceUseCase;
// public PresenceConsoleUI (IPresenceUseCase presenceUseCase){
// _presenceUseCase = presenceUseCase;
// }
public void DisplayPresenceByGroup(int groupID){
StringBuilder stringBuilder = new StringBuilder();
foreach(Presence presence in _presenceUseCase.GetPresenceByGroup(groupID)){
stringBuilder.AppendLine($"{presence.User.FIO}, {presence.User.Group.Name}, {presence.IsAttedance}, {presence.Date}, {presence.LessonNumber}");
}
Console.WriteLine(stringBuilder);
}
// public void DisplayPresenceByGroup(int groupID){
// StringBuilder stringBuilder = new StringBuilder();
// foreach(Presence presence in _presenceUseCase.GetPresenceByGroup(groupID)){
// stringBuilder.AppendLine($"{presence.User.FIO}, {presence.User.Group.Name}, {presence.IsAttedance}, {presence.Date}, {presence.LessonNumber}");
// }
// Console.WriteLine(stringBuilder);
// }
public void DisplayPresenceByGroupByTime(int groupID, DateOnly date){
StringBuilder stringBuilder = new StringBuilder();
foreach(Presence presence in _presenceUseCase.GetPresenceByGroupByTime(groupID, date)){
stringBuilder.AppendLine($"{presence.User.FIO}, {presence.User.Group.Name}, {presence.IsAttedance}, {presence.Date}, {presence.LessonNumber}");
}
Console.WriteLine(stringBuilder);
}
// public void DisplayPresenceByGroupByTime(int groupID, DateOnly date){
// StringBuilder stringBuilder = new StringBuilder();
// foreach(Presence presence in _presenceUseCase.GetPresenceByGroupByTime(groupID, date)){
// stringBuilder.AppendLine($"{presence.User.FIO}, {presence.User.Group.Name}, {presence.IsAttedance}, {presence.Date}, {presence.LessonNumber}");
// }
// Console.WriteLine(stringBuilder);
// }
public void GeneratePresence(int firstLesson, int lastLesson, int groupID, DateOnly date){
string output = _presenceUseCase.GeneratePresence(firstLesson, lastLesson, groupID, date) ? "Сгенерированно" : "Не сгенерированно";
Console.WriteLine(output);
}
// public void GeneratePresence(int firstLesson, int lastLesson, int groupID, DateOnly date){
// string output = _presenceUseCase.GeneratePresence(firstLesson, lastLesson, groupID, date) ? "Сгенерированно" : "Не сгенерированно";
// Console.WriteLine(output);
// }
public void GeneratePresenceWeek(int firstLesson, int lastLesson, int groupID, DateOnly date){
string output = _presenceUseCase.GeneratePresenceWeek(firstLesson, lastLesson, groupID, date) ? "Сгенерированно" : "Не сгенерированно";
Console.WriteLine(output);
}
// public void GeneratePresenceWeek(int firstLesson, int lastLesson, int groupID, DateOnly date){
// string output = _presenceUseCase.GeneratePresenceWeek(firstLesson, lastLesson, groupID, date) ? "Сгенерированно" : "Не сгенерированно";
// Console.WriteLine(output);
// }
public void IsAttedance(int firstLesson, int lastLesson, DateOnly date, Guid UserGuid){
string output = _presenceUseCase.IsAttedance(firstLesson, lastLesson, date, UserGuid) ? "Обновлено" : "Не обновлено";
Console.WriteLine(output);
}
}
// public void IsAttedance(int firstLesson, int lastLesson, DateOnly date, Guid UserGuid){
// string output = _presenceUseCase.IsAttedance(firstLesson, lastLesson, date, UserGuid) ? "Обновлено" : "Не обновлено";
// Console.WriteLine(output);
// }
// }
}

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("ui")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6c6c0936f5e12ba65625b810a3751f41f19d78bc")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8d435f71b5721c711cb9dad7ab5782dcef034f90")]
[assembly: System.Reflection.AssemblyProductAttribute("ui")]
[assembly: System.Reflection.AssemblyTitleAttribute("ui")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
e3e671f79a52a9b1ef470e4e04498c35d6e044563001e3cff33e3856f43c8bd1
fbd5ba1ec96a9775fca2586dd0993eddb5e59e7b10c3d7317479a62459ec788c