diff --git a/console_ui/obj/Debug/net8.0/console_ui.AssemblyInfo.cs b/console_ui/obj/Debug/net8.0/console_ui.AssemblyInfo.cs index 70eb0fe..acdc5db 100644 --- a/console_ui/obj/Debug/net8.0/console_ui.AssemblyInfo.cs +++ b/console_ui/obj/Debug/net8.0/console_ui.AssemblyInfo.cs @@ -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")] diff --git a/console_ui/obj/Debug/net8.0/console_ui.AssemblyInfoInputs.cache b/console_ui/obj/Debug/net8.0/console_ui.AssemblyInfoInputs.cache index 4d6a081..a2df53c 100644 --- a/console_ui/obj/Debug/net8.0/console_ui.AssemblyInfoInputs.cache +++ b/console_ui/obj/Debug/net8.0/console_ui.AssemblyInfoInputs.cache @@ -1 +1 @@ -9b1464a1a381c026e523ead07c5c0bd2c1fc254caae642a9c0dc293c388a5267 +fcb9cb787b816ab3834bc04682c26c8d4aa31776dacf72b5b63de8786566ad86 diff --git a/console_ui/obj/Debug/net8.0/console_ui.csproj.AssemblyReference.cache b/console_ui/obj/Debug/net8.0/console_ui.csproj.AssemblyReference.cache index aa6a31a..56b281e 100644 Binary files a/console_ui/obj/Debug/net8.0/console_ui.csproj.AssemblyReference.cache and b/console_ui/obj/Debug/net8.0/console_ui.csproj.AssemblyReference.cache differ diff --git a/data/Repository/UserRepositorylmpl.cs b/data/Repository/UserRepositorylmpl.cs index 1112390..584a251 100644 --- a/data/Repository/UserRepositorylmpl.cs +++ b/data/Repository/UserRepositorylmpl.cs @@ -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}; } diff --git a/data/bin/Debug/net8.0/data.dll b/data/bin/Debug/net8.0/data.dll index 6fefe90..37cf6ec 100644 Binary files a/data/bin/Debug/net8.0/data.dll and b/data/bin/Debug/net8.0/data.dll differ diff --git a/data/bin/Debug/net8.0/data.pdb b/data/bin/Debug/net8.0/data.pdb index c17373f..52a0355 100644 Binary files a/data/bin/Debug/net8.0/data.pdb and b/data/bin/Debug/net8.0/data.pdb differ diff --git a/data/obj/Debug/net8.0/data.AssemblyInfo.cs b/data/obj/Debug/net8.0/data.AssemblyInfo.cs index 5c05971..3c1de01 100644 --- a/data/obj/Debug/net8.0/data.AssemblyInfo.cs +++ b/data/obj/Debug/net8.0/data.AssemblyInfo.cs @@ -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")] diff --git a/data/obj/Debug/net8.0/data.AssemblyInfoInputs.cache b/data/obj/Debug/net8.0/data.AssemblyInfoInputs.cache index 277a37b..675e8ae 100644 --- a/data/obj/Debug/net8.0/data.AssemblyInfoInputs.cache +++ b/data/obj/Debug/net8.0/data.AssemblyInfoInputs.cache @@ -1 +1 @@ -1717865c1f3ea8eb394c6de25814487453eeb08c49cfa440b8caad21b340b555 +4bdad9cb9dbe9a4bbb133ff745306a1ea490f7961d9350beff628cc509c45b3d diff --git a/data/obj/Debug/net8.0/data.dll b/data/obj/Debug/net8.0/data.dll index 6fefe90..37cf6ec 100644 Binary files a/data/obj/Debug/net8.0/data.dll and b/data/obj/Debug/net8.0/data.dll differ diff --git a/data/obj/Debug/net8.0/data.pdb b/data/obj/Debug/net8.0/data.pdb index c17373f..52a0355 100644 Binary files a/data/obj/Debug/net8.0/data.pdb and b/data/obj/Debug/net8.0/data.pdb differ diff --git a/data/obj/Debug/net8.0/ref/data.dll b/data/obj/Debug/net8.0/ref/data.dll index a78e84e..17a147b 100644 Binary files a/data/obj/Debug/net8.0/ref/data.dll and b/data/obj/Debug/net8.0/ref/data.dll differ diff --git a/data/obj/Debug/net8.0/refint/data.dll b/data/obj/Debug/net8.0/refint/data.dll index a78e84e..17a147b 100644 Binary files a/data/obj/Debug/net8.0/refint/data.dll and b/data/obj/Debug/net8.0/refint/data.dll differ diff --git a/domain/UseCase/UserUseCase.cs b/domain/UseCase/UserUseCase.cs index 2b0579f..637a002 100644 --- a/domain/UseCase/UserUseCase.cs +++ b/domain/UseCase/UserUseCase.cs @@ -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, diff --git a/domain/bin/Debug/net8.0/data.dll b/domain/bin/Debug/net8.0/data.dll index 6fefe90..37cf6ec 100644 Binary files a/domain/bin/Debug/net8.0/data.dll and b/domain/bin/Debug/net8.0/data.dll differ diff --git a/domain/bin/Debug/net8.0/data.pdb b/domain/bin/Debug/net8.0/data.pdb index c17373f..52a0355 100644 Binary files a/domain/bin/Debug/net8.0/data.pdb and b/domain/bin/Debug/net8.0/data.pdb differ diff --git a/domain/bin/Debug/net8.0/domain.dll b/domain/bin/Debug/net8.0/domain.dll index 4f14dfb..47b6a40 100644 Binary files a/domain/bin/Debug/net8.0/domain.dll and b/domain/bin/Debug/net8.0/domain.dll differ diff --git a/domain/bin/Debug/net8.0/domain.pdb b/domain/bin/Debug/net8.0/domain.pdb index ed237c1..51db241 100644 Binary files a/domain/bin/Debug/net8.0/domain.pdb and b/domain/bin/Debug/net8.0/domain.pdb differ diff --git a/domain/obj/Debug/net8.0/domain.AssemblyInfo.cs b/domain/obj/Debug/net8.0/domain.AssemblyInfo.cs index e6334c3..3637ff0 100644 --- a/domain/obj/Debug/net8.0/domain.AssemblyInfo.cs +++ b/domain/obj/Debug/net8.0/domain.AssemblyInfo.cs @@ -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")] diff --git a/domain/obj/Debug/net8.0/domain.AssemblyInfoInputs.cache b/domain/obj/Debug/net8.0/domain.AssemblyInfoInputs.cache index 272eead..bd97862 100644 --- a/domain/obj/Debug/net8.0/domain.AssemblyInfoInputs.cache +++ b/domain/obj/Debug/net8.0/domain.AssemblyInfoInputs.cache @@ -1 +1 @@ -7cd83e005f219e7f461ddb8b33cfed5348a98ea55d97b78c917596cc14252493 +51f0b800e5221e0557228a48bda04ba517dabcc7d9458bdda1aa141fab7b4f18 diff --git a/domain/obj/Debug/net8.0/domain.csproj.AssemblyReference.cache b/domain/obj/Debug/net8.0/domain.csproj.AssemblyReference.cache index 33768f1..15875cd 100644 Binary files a/domain/obj/Debug/net8.0/domain.csproj.AssemblyReference.cache and b/domain/obj/Debug/net8.0/domain.csproj.AssemblyReference.cache differ diff --git a/domain/obj/Debug/net8.0/domain.dll b/domain/obj/Debug/net8.0/domain.dll index 4f14dfb..47b6a40 100644 Binary files a/domain/obj/Debug/net8.0/domain.dll and b/domain/obj/Debug/net8.0/domain.dll differ diff --git a/domain/obj/Debug/net8.0/domain.pdb b/domain/obj/Debug/net8.0/domain.pdb index ed237c1..51db241 100644 Binary files a/domain/obj/Debug/net8.0/domain.pdb and b/domain/obj/Debug/net8.0/domain.pdb differ diff --git a/domain/obj/Debug/net8.0/ref/domain.dll b/domain/obj/Debug/net8.0/ref/domain.dll index 0e97a10..825f8b1 100644 Binary files a/domain/obj/Debug/net8.0/ref/domain.dll and b/domain/obj/Debug/net8.0/ref/domain.dll differ diff --git a/domain/obj/Debug/net8.0/refint/domain.dll b/domain/obj/Debug/net8.0/refint/domain.dll index 0e97a10..825f8b1 100644 Binary files a/domain/obj/Debug/net8.0/refint/domain.dll and b/domain/obj/Debug/net8.0/refint/domain.dll differ diff --git a/presence_api/Controllers/AdminController.cs b/presence_api/Controllers/AdminController.cs index a7bcdd3..555bc58 100644 --- a/presence_api/Controllers/AdminController.cs +++ b/presence_api/Controllers/AdminController.cs @@ -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 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 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 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 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"); } } diff --git a/presence_api/Controllers/PresenceController.cs b/presence_api/Controllers/PresenceController.cs index 4dccaf8..4ce76aa 100644 --- a/presence_api/Controllers/PresenceController.cs +++ b/presence_api/Controllers/PresenceController.cs @@ -39,8 +39,8 @@ public class PresenceController: ControllerBase{ public ActionResult 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; } diff --git a/presence_api/Program.cs b/presence_api/Program.cs index 55caa02..a4419b8 100644 --- a/presence_api/Program.cs +++ b/presence_api/Program.cs @@ -7,7 +7,10 @@ builder.Services.AddDbContext(); 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(); diff --git a/presence_api/ServiceExtensions/ServiceExtensions.cs b/presence_api/ServiceExtensions/ServiceExtensions.cs index 4d5b6b1..d6beae3 100644 --- a/presence_api/ServiceExtensions/ServiceExtensions.cs +++ b/presence_api/ServiceExtensions/ServiceExtensions.cs @@ -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() + // .AddScoped() + // .AddScoped() + // .AddScoped() + // .AddScoped() + // .AddScoped(); + // } + + public static void AddGroupServices(this IServiceCollection services) { services.AddScoped() - .AddScoped() - .AddScoped() - .AddScoped() - .AddScoped() + .AddScoped(); + } + + public static void AddUserServices(this IServiceCollection services) + { + services.AddScoped() + .AddScoped(); + } + + public static void AddPresenceServices(this IServiceCollection services) + { + services.AddScoped() .AddScoped(); } } \ No newline at end of file diff --git a/presence_api/bin/Debug/net8.0/data.dll b/presence_api/bin/Debug/net8.0/data.dll index 6fefe90..37cf6ec 100644 Binary files a/presence_api/bin/Debug/net8.0/data.dll and b/presence_api/bin/Debug/net8.0/data.dll differ diff --git a/presence_api/bin/Debug/net8.0/data.pdb b/presence_api/bin/Debug/net8.0/data.pdb index c17373f..52a0355 100644 Binary files a/presence_api/bin/Debug/net8.0/data.pdb and b/presence_api/bin/Debug/net8.0/data.pdb differ diff --git a/presence_api/bin/Debug/net8.0/domain.dll b/presence_api/bin/Debug/net8.0/domain.dll index 4f14dfb..47b6a40 100644 Binary files a/presence_api/bin/Debug/net8.0/domain.dll and b/presence_api/bin/Debug/net8.0/domain.dll differ diff --git a/presence_api/bin/Debug/net8.0/domain.pdb b/presence_api/bin/Debug/net8.0/domain.pdb index ed237c1..51db241 100644 Binary files a/presence_api/bin/Debug/net8.0/domain.pdb and b/presence_api/bin/Debug/net8.0/domain.pdb differ diff --git a/presence_api/bin/Debug/net8.0/presence_api.dll b/presence_api/bin/Debug/net8.0/presence_api.dll index 214e604..cfa27bc 100644 Binary files a/presence_api/bin/Debug/net8.0/presence_api.dll and b/presence_api/bin/Debug/net8.0/presence_api.dll differ diff --git a/presence_api/bin/Debug/net8.0/presence_api.pdb b/presence_api/bin/Debug/net8.0/presence_api.pdb index 3d9f3c3..9bf1661 100644 Binary files a/presence_api/bin/Debug/net8.0/presence_api.pdb and b/presence_api/bin/Debug/net8.0/presence_api.pdb differ diff --git a/presence_api/obj/Debug/net8.0/presence_api.AssemblyInfo.cs b/presence_api/obj/Debug/net8.0/presence_api.AssemblyInfo.cs index 7bd39a4..1b27ed3 100644 --- a/presence_api/obj/Debug/net8.0/presence_api.AssemblyInfo.cs +++ b/presence_api/obj/Debug/net8.0/presence_api.AssemblyInfo.cs @@ -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")] diff --git a/presence_api/obj/Debug/net8.0/presence_api.AssemblyInfoInputs.cache b/presence_api/obj/Debug/net8.0/presence_api.AssemblyInfoInputs.cache index 524f89a..b0683f5 100644 --- a/presence_api/obj/Debug/net8.0/presence_api.AssemblyInfoInputs.cache +++ b/presence_api/obj/Debug/net8.0/presence_api.AssemblyInfoInputs.cache @@ -1 +1 @@ -ad0d9bd61813c0a35cbd8c85f8db96d734d0fcd658f5913b10790b5aa3eb50a5 +c3f230f6647ac6a2f215b94432a354594bcd758939c2e8860e567861fa31d7ba diff --git a/presence_api/obj/Debug/net8.0/presence_api.csproj.AssemblyReference.cache b/presence_api/obj/Debug/net8.0/presence_api.csproj.AssemblyReference.cache index c8bbee9..e027228 100644 Binary files a/presence_api/obj/Debug/net8.0/presence_api.csproj.AssemblyReference.cache and b/presence_api/obj/Debug/net8.0/presence_api.csproj.AssemblyReference.cache differ diff --git a/presence_api/obj/Debug/net8.0/presence_api.dll b/presence_api/obj/Debug/net8.0/presence_api.dll index 214e604..cfa27bc 100644 Binary files a/presence_api/obj/Debug/net8.0/presence_api.dll and b/presence_api/obj/Debug/net8.0/presence_api.dll differ diff --git a/presence_api/obj/Debug/net8.0/presence_api.pdb b/presence_api/obj/Debug/net8.0/presence_api.pdb index 3d9f3c3..9bf1661 100644 Binary files a/presence_api/obj/Debug/net8.0/presence_api.pdb and b/presence_api/obj/Debug/net8.0/presence_api.pdb differ diff --git a/presence_api/obj/Debug/net8.0/ref/presence_api.dll b/presence_api/obj/Debug/net8.0/ref/presence_api.dll index 49f36b2..ac6cb3a 100644 Binary files a/presence_api/obj/Debug/net8.0/ref/presence_api.dll and b/presence_api/obj/Debug/net8.0/ref/presence_api.dll differ diff --git a/presence_api/obj/Debug/net8.0/refint/presence_api.dll b/presence_api/obj/Debug/net8.0/refint/presence_api.dll index 49f36b2..ac6cb3a 100644 Binary files a/presence_api/obj/Debug/net8.0/refint/presence_api.dll and b/presence_api/obj/Debug/net8.0/refint/presence_api.dll differ diff --git a/ui/GroupConsole.cs b/ui/GroupConsole.cs new file mode 100644 index 0000000..8e7ca89 --- /dev/null +++ b/ui/GroupConsole.cs @@ -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}"); + } + } + } + } +} \ No newline at end of file diff --git a/ui/PresenceConsole.cs b/ui/PresenceConsole.cs new file mode 100644 index 0000000..66c524a --- /dev/null +++ b/ui/PresenceConsole.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/ui/UserConsole.cs b/ui/UserConsole.cs index 0fac04f..52dd1b8 100644 --- a/ui/UserConsole.cs +++ b/ui/UserConsole.cs @@ -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); + // } + // } } \ No newline at end of file diff --git a/ui/obj/Debug/net8.0/ui.AssemblyInfo.cs b/ui/obj/Debug/net8.0/ui.AssemblyInfo.cs index 408cb86..e52c314 100644 --- a/ui/obj/Debug/net8.0/ui.AssemblyInfo.cs +++ b/ui/obj/Debug/net8.0/ui.AssemblyInfo.cs @@ -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")] diff --git a/ui/obj/Debug/net8.0/ui.AssemblyInfoInputs.cache b/ui/obj/Debug/net8.0/ui.AssemblyInfoInputs.cache index eda6db5..9884175 100644 --- a/ui/obj/Debug/net8.0/ui.AssemblyInfoInputs.cache +++ b/ui/obj/Debug/net8.0/ui.AssemblyInfoInputs.cache @@ -1 +1 @@ -e3e671f79a52a9b1ef470e4e04498c35d6e044563001e3cff33e3856f43c8bd1 +fbd5ba1ec96a9775fca2586dd0993eddb5e59e7b10c3d7317479a62459ec788c diff --git a/ui/obj/Debug/net8.0/ui.csproj.AssemblyReference.cache b/ui/obj/Debug/net8.0/ui.csproj.AssemblyReference.cache index 6a62cca..61ee0a1 100644 Binary files a/ui/obj/Debug/net8.0/ui.csproj.AssemblyReference.cache and b/ui/obj/Debug/net8.0/ui.csproj.AssemblyReference.cache differ