Compare commits
3 Commits
4f7ef7ffb2
...
6cd68fd8f8
Author | SHA1 | Date | |
---|---|---|---|
|
6cd68fd8f8 | ||
|
cefc9b3a85 | ||
|
979f0a84e8 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.vs/slnx.sqlite
BIN
.vs/slnx.sqlite
Binary file not shown.
@ -1,4 +1,5 @@
|
||||
using Zurnal.RemaDateBase.DateDao;
|
||||
using Zurnal.domain.Models;
|
||||
using Zurnal.RemaDateBase.DateDao;
|
||||
|
||||
internal interface IGroupRepository
|
||||
{
|
||||
@ -8,7 +9,7 @@ internal interface IGroupRepository
|
||||
{
|
||||
return AllGroup.Select(g => new GroupDao { GroupName = g.GroupName, Id = g.Id });
|
||||
}
|
||||
|
||||
List<GroupLocalEntity> GetAllGroup();
|
||||
public bool RemoveGroupById(int groupId)
|
||||
{
|
||||
var group = AllGroup.FirstOrDefault(g => g.Id == groupId);
|
||||
|
52
Zurnal/Date/Repository/SQLNado.cs
Normal file
52
Zurnal/Date/Repository/SQLNado.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using Zurnal.Date.LocalDate;
|
||||
using Zurnal.domain.Models;
|
||||
using Zurnal.RemaDateBase.DateDao;
|
||||
|
||||
namespace Data.Repository
|
||||
{
|
||||
public class SQLGroupRepositoryImpl:IGroupRepository
|
||||
{
|
||||
private readonly RemoteDateBaseContext _remoteDataBaseContext;
|
||||
|
||||
public SQLGroupRepositoryImpl(RemoteDateBaseContext remoteDataBaseContext) {
|
||||
_remoteDataBaseContext = remoteDataBaseContext;
|
||||
}
|
||||
|
||||
public List<GroupDao> AllGroup => throw new NotImplementedException();
|
||||
|
||||
public bool AddGroup(GroupLocalEntity newGroup)
|
||||
{
|
||||
GroupDao groupDao = new GroupDao { GroupName = newGroup.Name };
|
||||
var result = _remoteDataBaseContext.Group.Add(groupDao);
|
||||
if (result != null) {
|
||||
_remoteDataBaseContext.SaveChanges();
|
||||
return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<GroupLocalEntity> GetAllGroup()
|
||||
{
|
||||
return _remoteDataBaseContext.Group.Select(group => new GroupLocalEntity{
|
||||
Id = group.Id,
|
||||
Name = group.GroupName}
|
||||
).ToList();
|
||||
}
|
||||
|
||||
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
|
||||
|
||||
public GroupLocalEntity GetGroupById(int groupID)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool RemoveGroupById(int groupID)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
7
Zurnal/Domain/Recvara/Recvarer.cs
Normal file
7
Zurnal/Domain/Recvara/Recvarer.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace domain.Models.RequestModels
|
||||
{
|
||||
public class GroupAddRequest
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
4
Zurnal/Domain/Respy/GroupRespy.cs
Normal file
4
Zurnal/Domain/Respy/GroupRespy.cs
Normal file
@ -0,0 +1,4 @@
|
||||
public class GroupResponse{
|
||||
public int Id {get; set;}
|
||||
public string Name {get; set;}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
using Zurnal.Data.Repository;
|
||||
using Zurnal.domain.Models;
|
||||
using Zurnal.RemaDateBase.DateDao;
|
||||
namespace Zurnal.Domain.UseCase
|
||||
{
|
||||
public class GroupUseCase : IGroupRepository
|
||||
{
|
||||
private readonly IGroupRepository _repository;
|
||||
private List<GroupDao> _groups = new List<GroupDao>();
|
||||
public List<GroupDao> AllGroup => _groups;
|
||||
private UserRepositoryImpl _repositoryUserImpl;
|
||||
@ -59,5 +61,19 @@ namespace Zurnal.Domain.UseCase
|
||||
{
|
||||
return _groups.FirstOrDefault(g => g.Id == id);
|
||||
}
|
||||
|
||||
public List<GroupResponse> getAllGroup(){
|
||||
return _repository.GetAllGroup().Select(group =>
|
||||
new GroupResponse {
|
||||
Id = group.Id,
|
||||
Name = group.Name
|
||||
}
|
||||
).ToList();
|
||||
}
|
||||
|
||||
public List<GroupLocalEntity> GetAllGroup()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,18 @@
|
||||
using Zurnal.UI;
|
||||
using Zurnal.Data.Repository;
|
||||
using Zurnal.Domain.UseCase;
|
||||
using Zurnal.Domain.UseCase;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using UI;
|
||||
using Data.Repository;
|
||||
|
||||
GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl();
|
||||
UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl();
|
||||
UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl);
|
||||
IServiceCollection services = new ServiceCollection();
|
||||
|
||||
MainMenuUI mainMenuUI = new MainMenuUI(userUseCase);
|
||||
services
|
||||
.AddDbContext<RemoteDateBaseContext>()
|
||||
.AddSingleton<IGroupRepository,SQLGroupRepositoryImpl>()
|
||||
.AddSingleton<GroupUseCase>()
|
||||
.AddSingleton<GroupConsol>();
|
||||
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
GroupConsol groupUI = serviceProvider.GetService<GroupConsol>();
|
||||
|
||||
groupUI.AddGroup();
|
@ -2,7 +2,8 @@
|
||||
{
|
||||
public class PresnceDao
|
||||
{
|
||||
public Guid UserGuid { get; set; }
|
||||
|
||||
public Guid UserGuid { get; set; }
|
||||
public bool IsAttendensy { get; set; } = true;
|
||||
public int LessonNumber { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
|
@ -1,17 +1,84 @@
|
||||
using Zurnal.domain.Models;
|
||||
using Zurnal.RemaDateBase.DateDao;
|
||||
using Group = System.Text.RegularExpressions.Group;
|
||||
|
||||
namespace Zurnal.RemaDateBase
|
||||
{
|
||||
public interface IGroupRepository
|
||||
{
|
||||
void AddGroup(Group group);
|
||||
Group GetGroupById(int id);
|
||||
IEnumerable<Group> GetAllGroups();
|
||||
void UpdateGroup(Group group);
|
||||
void DeleteGroup(int id);
|
||||
object GetAllGroup();
|
||||
bool RemoveGroupById(int groupID);
|
||||
bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup);
|
||||
List<GroupDao> AllGroup { get; }
|
||||
|
||||
public IEnumerable<GroupDao> AllGroups()
|
||||
{
|
||||
return AllGroup.Select(g => new GroupDao { GroupName = g.GroupName, Id = g.Id });
|
||||
}
|
||||
|
||||
public bool RemoveGroupById(int groupId)
|
||||
{
|
||||
var group = AllGroup.FirstOrDefault(g => g.Id == groupId);
|
||||
if (group != null)
|
||||
{
|
||||
AllGroup.Remove(group);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public GroupDao FindGroupById(int groupId)
|
||||
{
|
||||
return AllGroup.FirstOrDefault(g => g.Id == groupId);
|
||||
}
|
||||
|
||||
public bool UpdateGroupById(int groupId, GroupDao updatedGroup)
|
||||
{
|
||||
if (updatedGroup == null) throw new ArgumentNullException(nameof(updatedGroup));
|
||||
|
||||
var group = AllGroup.FirstOrDefault(g => g.Id == groupId);
|
||||
if (group != null)
|
||||
{
|
||||
group.GroupName = updatedGroup.GroupName;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void DeleteGroup(int id)
|
||||
{
|
||||
var group = AllGroup.FirstOrDefault(g => g.Id == id);
|
||||
if (group != null)
|
||||
{
|
||||
AllGroup.Remove(group);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<GroupDao> GetAllGroups()
|
||||
{
|
||||
return AllGroup;
|
||||
}
|
||||
|
||||
public void UpdateGroupName(int groupId, string name)
|
||||
{
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
|
||||
var group = AllGroup.FirstOrDefault(g => g.Id == groupId);
|
||||
if (group != null)
|
||||
{
|
||||
group.GroupName = name;
|
||||
}
|
||||
}
|
||||
public bool UpdateUser(Guid userGuid, UserDao updatedUser)
|
||||
{
|
||||
if (updatedUser == null) throw new ArgumentNullException(nameof(updatedUser));
|
||||
|
||||
var user = AllGroup.SelectMany(g => g.Users).FirstOrDefault(u => u.UserGuid == userGuid);
|
||||
if (user != null)
|
||||
{
|
||||
user.FIO = updatedUser.FIO;
|
||||
user.GroupID = updatedUser.GroupID;
|
||||
user.Group = updatedUser.Group;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
using Zurnal.domain.Models;
|
||||
using Zurnal.RemaDateBase.DateDao;
|
||||
|
||||
public interface IPresenceRepository
|
||||
{
|
||||
void AddPresence(Presence presence);
|
||||
Presence GetPresenceById(int id);
|
||||
IEnumerable<Presence> GetAllPresences();
|
||||
void UpdatePresence(Presence presence);
|
||||
void AddPresence(PresnceDao presence);
|
||||
PresnceDao GetPresenceById(int id);
|
||||
IEnumerable<PresnceDao> GetAllPresences();
|
||||
void UpdatePresence(PresnceDao presence);
|
||||
void DeletePresence(int id);
|
||||
}
|
80
Zurnal/RemaDateBase/PresenceRepository.cs
Normal file
80
Zurnal/RemaDateBase/PresenceRepository.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using Zurnal.RemaDateBase.DateDao;
|
||||
public class PresenceRepository : IPresenceRepository
|
||||
{
|
||||
private List<PresnceDao> presences = new List<PresnceDao>();
|
||||
|
||||
public void AddPresence(PresnceDao presence)
|
||||
{
|
||||
presences.Add(new PresnceDao
|
||||
{
|
||||
UserGuid = presence.UserGuid,
|
||||
IsAttendensy = presence.IsAttendensy,
|
||||
LessonNumber = presence.LessonNumber,
|
||||
Date = presence.Date,
|
||||
userDao = new UserDao
|
||||
{
|
||||
FIO = presence.userDao.FIO,
|
||||
UserGuid = presence.userDao.UserGuid,
|
||||
GroupID = presence.userDao.GroupID,
|
||||
Group = new GroupDao { Id = presence.userDao.Group.Id, GroupName = presence.userDao.Group.GroupName }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PresnceDao GetPresenceById(int id)
|
||||
{
|
||||
var presence = presences.FirstOrDefault(p => p.LessonNumber == id);
|
||||
return presence != null ? new PresnceDao
|
||||
{
|
||||
UserGuid = presence.UserGuid,
|
||||
IsAttendensy = presence.IsAttendensy,
|
||||
LessonNumber = presence.LessonNumber,
|
||||
Date = presence.Date,
|
||||
userDao = new UserDao
|
||||
{
|
||||
FIO = presence.userDao.FIO,
|
||||
GroupID = presence.userDao.GroupID,
|
||||
Group = presence.userDao.Group
|
||||
}
|
||||
} : null;
|
||||
}
|
||||
|
||||
public IEnumerable<PresnceDao> GetAllPresences()
|
||||
{
|
||||
return presences.Select(p => new PresnceDao
|
||||
{
|
||||
UserGuid = p.UserGuid,
|
||||
IsAttendensy = p.IsAttendensy,
|
||||
LessonNumber = p.LessonNumber,
|
||||
Date = p.Date,
|
||||
userDao = new UserDao
|
||||
{
|
||||
FIO = p.userDao.FIO,
|
||||
GroupID = p.userDao.GroupID,
|
||||
Group = p.userDao.Group
|
||||
}
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public void UpdatePresence(PresnceDao presence)
|
||||
{
|
||||
var existingPresence = presences.FirstOrDefault(p => p.LessonNumber == presence.LessonNumber);
|
||||
if (existingPresence != null)
|
||||
{
|
||||
existingPresence.IsAttendensy = presence.IsAttendensy;
|
||||
existingPresence.Date = presence.Date;
|
||||
existingPresence.userDao.FIO = presence.userDao.FIO;
|
||||
existingPresence.userDao.GroupID = presence.userDao.GroupID;
|
||||
existingPresence.userDao.Group.GroupName = presence.userDao.Group.GroupName;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeletePresence(int id)
|
||||
{
|
||||
var presence = presences.FirstOrDefault(p => p.LessonNumber == id);
|
||||
if (presence != null)
|
||||
{
|
||||
presences.Remove(presence);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,8 +3,6 @@ using Zurnal.RemaDateBase.DateDao;
|
||||
|
||||
public class RemoteDateBaseContext : DbContext
|
||||
{
|
||||
public RemoteDateBaseContext() { }
|
||||
|
||||
public DbSet<GroupDao> Group { get; set; }
|
||||
public DbSet<UserDao> User { get; set; }
|
||||
public DbSet<PresnceDao> Presence { get; set; }
|
||||
|
33
Zurnal/UI/GroupConsol.cs
Normal file
33
Zurnal/UI/GroupConsol.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using domain;
|
||||
using domain.Models.RequestModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Zurnal.Domain.UseCase;
|
||||
using Zurnal.RemaDateBase.DateDao;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class GroupConsol
|
||||
{
|
||||
private readonly GroupUseCase _groupUseCase;
|
||||
public GroupConsol(GroupUseCase groupUseCase) {
|
||||
_groupUseCase = groupUseCase;
|
||||
}
|
||||
|
||||
public void AddGroup() {
|
||||
Console.WriteLine("Введите название группы: ");
|
||||
string groupName = Console.ReadLine();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(groupName)) {
|
||||
Console.WriteLine("Название группы не может быть пустым. Пожалуйста, введите корректное название.");
|
||||
return;
|
||||
}
|
||||
GroupDao groupDao = new GroupDao { GroupName = groupName };
|
||||
_groupUseCase.AddGroup(groupDao);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Zurnal")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e86bec8a7f833b7d641968f35cc2ebce20da3dc8")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cefc9b3a85c12cb82d7e543ab8d2eb025849b9ec")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Zurnal")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Zurnal")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
91af4bd6b85cc028ddbbf62d14f2f440aae593b748896e98c6bba89005927b76
|
||||
e861d9be05b9445b3ebef44d26117a8c4b30fb141208d42302beba8abc1372c1
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
132477173c8f0b9bd98b70bc6d28240502a0a14c41a11367b550c5913679e10c
|
||||
e818c2582926724344d87f9300781db10e3c61b91dde2011ab5210bca4cb8741
|
||||
|
@ -13,8 +13,12 @@
|
||||
"packagesPath": "C:\\Users\\profi\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\Users\\profi\\source\\repos\\Zurnal\\Zurnal\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\profi\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
|
@ -5,12 +5,13 @@
|
||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\profi\.nuget\packages\</NuGetPackageFolders>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\profi\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.11.1</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="C:\Users\profi\.nuget\packages\" />
|
||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
||||
</ItemGroup>
|
||||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.entityframeworkcore\8.0.10\buildTransitive\net8.0\Microsoft.EntityFrameworkCore.props" Condition="Exists('$(NuGetPackageRoot)microsoft.entityframeworkcore\8.0.10\buildTransitive\net8.0\Microsoft.EntityFrameworkCore.props')" />
|
||||
|
@ -2112,7 +2112,8 @@
|
||||
]
|
||||
},
|
||||
"packageFolders": {
|
||||
"C:\\Users\\profi\\.nuget\\packages\\": {}
|
||||
"C:\\Users\\profi\\.nuget\\packages\\": {},
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
|
||||
},
|
||||
"project": {
|
||||
"version": "1.0.0",
|
||||
@ -2123,8 +2124,12 @@
|
||||
"packagesPath": "C:\\Users\\profi\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\Users\\profi\\source\\repos\\Zurnal\\Zurnal\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\profi\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "BG9wtY8hZA8=",
|
||||
"dgSpecHash": "/Ii72Vl1qzo=",
|
||||
"success": true,
|
||||
"projectFilePath": "C:\\Users\\profi\\source\\repos\\Zurnal\\Zurnal\\Zurnal.csproj",
|
||||
"expectedPackageFiles": [
|
||||
|
Loading…
Reference in New Issue
Block a user