diff --git a/Data/Repository/IPresenceRepository.cs b/Data/Repository/IPresenceRepository.cs index ee2554d..05791d6 100644 --- a/Data/Repository/IPresenceRepository.cs +++ b/Data/Repository/IPresenceRepository.cs @@ -11,7 +11,7 @@ namespace Posechaemost.Data.Repository { List GetPresenceByGroup(int groupId); List GetPresenceByGroupAndDate(int groupId, DateOnly date); - bool UncheckAttendence(PresenceLocalEntity presence); + bool UncheckAttendence(int firstClass, int lastClass, DateOnly date, Guid userGuid); void AddPresence(PresenceLocalEntity presence); } diff --git a/Data/Repository/PresenceRepositoryImpl.cs b/Data/Repository/PresenceRepositoryImpl.cs index 20961e7..7707a6a 100644 --- a/Data/Repository/PresenceRepositoryImpl.cs +++ b/Data/Repository/PresenceRepositoryImpl.cs @@ -36,15 +36,14 @@ namespace Posechaemost.Data.Repository return GetAllPresences; } - public bool UncheckAttendence(PresenceLocalEntity presence) + public bool UncheckAttendence(int firstClass, int lastClass, DateOnly date, Guid userGuid) { var presToUpdate = GetAllPresences - .Where(x => x.IsAttendence == presence.IsAttendence - && x.UserGuid == presence.UserGuid && x.Date == presence.Date - && x.ClassNumber == presence.ClassNumber).ToList(); + .Where(x => x.UserGuid == userGuid && x.ClassNumber >= firstClass + && x.ClassNumber <= lastClass && x.Date == date).ToList(); foreach (var pres in presToUpdate) { - presence.IsAttendence = false; + pres.IsAttendence = false; } return true; } diff --git a/Domain/UseCase/PresenceUseCase.cs b/Domain/UseCase/PresenceUseCase.cs index adcc8b3..1c95261 100644 --- a/Domain/UseCase/PresenceUseCase.cs +++ b/Domain/UseCase/PresenceUseCase.cs @@ -64,8 +64,20 @@ namespace Posechaemost.Domain.UseCase return presenceByGroupAndDate; } - public bool UncheckAttendence(PresenceLocalEntity presence) { - return _repositoryPresenceImpl.UncheckAttendence(presence); + public bool UncheckAttendence(int firstClass, int lastClass, DateOnly date, Guid userGuid) { + return _repositoryPresenceImpl.UncheckAttendence(firstClass, lastClass, date, userGuid); + } + + public void AddPresence(int firstClass, int lastClass, int groupId,DateOnly date) + { + var users = _repositoryUserImpl.GetAllUser().Where(x => x.GroupID==groupId).ToList(); + List presenceList = new List(); + for (int i = firstClass; i < lastClass; i++) { + foreach (var user in users) { + PresenceLocalEntity pres = new PresenceLocalEntity {ClassNumber = i, Date = date, UserGuid = user.Guid}; + presenceList.Add(pres); + } + } } } } \ No newline at end of file diff --git a/UI/MainMenu.cs b/UI/MainMenu.cs index d5b0057..ba9a268 100644 --- a/UI/MainMenu.cs +++ b/UI/MainMenu.cs @@ -12,11 +12,14 @@ namespace Posechaemost.UI UserConsoleUI _userConsoleUI; GroupConsoleUI _groupConsoleUI; + PresenceConsoleUI _presenceConsoleUI; - public MainMenuUI(UserUseCase userUseCase, GroupUseCase groupUseCase) + public MainMenuUI(UserUseCase userUseCase, GroupUseCase groupUseCase, PresenceUseCase presenceUseCase) { _userConsoleUI = new UserConsoleUI(userUseCase); _groupConsoleUI = new GroupConsoleUI(groupUseCase); + _presenceConsoleUI = new PresenceConsoleUI(presenceUseCase); + DisplayMenu(); diff --git a/UI/PresenceConsole.cs b/UI/PresenceConsole.cs new file mode 100644 index 0000000..f9dec1a --- /dev/null +++ b/UI/PresenceConsole.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Posechaemost.Domain.UseCase; + +namespace Posechaemost.UI +{ + public class PresenceConsoleUI + { + PresenceUseCase _presenceUseCase; + public PresenceConsoleUI(PresenceUseCase presenceUseCase) { + _presenceUseCase = presenceUseCase; + } + + public void GetPresenceByGroup(int groupId) { + var presence = _presenceUseCase.GetPresenceByGroup(groupId); + } + + public void GetPresenceByGroupAndDate(int groupId, DateOnly date) { + var presence = _presenceUseCase.GetPresenceByGroupAndDate(groupId, date); + } + + public void UncheckAttendence(int firstClass, int lastClass, DateOnly date, Guid userGuid) { + var presence = _presenceUseCase.UncheckAttendence(firstClass, lastClass, date, userGuid); + } + + public void AddPresence(int firstClass, int lastClass, int groupId, DateOnly date) { + _presenceUseCase.AddPresence(firstClass, lastClass, groupId, date); + } + } +} \ No newline at end of file diff --git a/obj/Debug/net8.0/Posechaemost.AssemblyInfo.cs b/obj/Debug/net8.0/Posechaemost.AssemblyInfo.cs index 8b54eee..2f70f3c 100644 --- a/obj/Debug/net8.0/Posechaemost.AssemblyInfo.cs +++ b/obj/Debug/net8.0/Posechaemost.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Posechaemost")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6b32e405d76bb739524c318b227f1fa95db1cba6")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+dd18de386525d2859a6db90bb74a2bdc95bc47e3")] [assembly: System.Reflection.AssemblyProductAttribute("Posechaemost")] [assembly: System.Reflection.AssemblyTitleAttribute("Posechaemost")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/net8.0/Posechaemost.AssemblyInfoInputs.cache b/obj/Debug/net8.0/Posechaemost.AssemblyInfoInputs.cache index 4e37887..ee33663 100644 --- a/obj/Debug/net8.0/Posechaemost.AssemblyInfoInputs.cache +++ b/obj/Debug/net8.0/Posechaemost.AssemblyInfoInputs.cache @@ -1 +1 @@ -4adf1b2c58c78e6eafd52a8be1c408433fb9f4a3525dbf62f4e5019169eebcab +e484c6d2be3801b673b3b8bec4389b40f150f0a04dc9544c29a279722a7318c6