Compare commits

..

No commits in common. "6cd68fd8f848f82dab9dfb3c0fa57e7014aa5697" and "4f7ef7ffb28283c7077607579022f64cf7ddd780" have entirely different histories.

29 changed files with 31 additions and 310 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,4 @@
using Zurnal.domain.Models;
using Zurnal.RemaDateBase.DateDao;
using Zurnal.RemaDateBase.DateDao;
internal interface IGroupRepository
{
@ -9,7 +8,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);

View File

@ -1,52 +0,0 @@
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();
}
}
}

View File

@ -1,7 +0,0 @@
namespace domain.Models.RequestModels
{
public class GroupAddRequest
{
public string Name { get; set; }
}
}

View File

@ -1,4 +0,0 @@
public class GroupResponse{
public int Id {get; set;}
public string Name {get; set;}
}

View File

@ -1,11 +1,9 @@
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;
@ -61,19 +59,5 @@ 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();
}
}
}

View File

@ -1,18 +1,9 @@
using Zurnal.Domain.UseCase;
using Microsoft.Extensions.DependencyInjection;
using UI;
using Data.Repository;
using Zurnal.UI;
using Zurnal.Data.Repository;
using Zurnal.Domain.UseCase;
IServiceCollection services = new ServiceCollection();
GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl();
UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl();
UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl);
services
.AddDbContext<RemoteDateBaseContext>()
.AddSingleton<IGroupRepository,SQLGroupRepositoryImpl>()
.AddSingleton<GroupUseCase>()
.AddSingleton<GroupConsol>();
var serviceProvider = services.BuildServiceProvider();
GroupConsol groupUI = serviceProvider.GetService<GroupConsol>();
groupUI.AddGroup();
MainMenuUI mainMenuUI = new MainMenuUI(userUseCase);

View File

@ -2,7 +2,6 @@
{
public class PresnceDao
{
public Guid UserGuid { get; set; }
public bool IsAttendensy { get; set; } = true;
public int LessonNumber { get; set; }

View File

@ -1,84 +1,17 @@
using Zurnal.domain.Models;
using Zurnal.RemaDateBase.DateDao;
using Group = System.Text.RegularExpressions.Group;
namespace Zurnal.RemaDateBase
{
public interface IGroupRepository
{
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;
}
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);
}
}

View File

@ -1,10 +1,9 @@
using Zurnal.RemaDateBase.DateDao;
using Zurnal.domain.Models;
public interface IPresenceRepository
{
void AddPresence(PresnceDao presence);
PresnceDao GetPresenceById(int id);
IEnumerable<PresnceDao> GetAllPresences();
void UpdatePresence(PresnceDao presence);
void AddPresence(Presence presence);
Presence GetPresenceById(int id);
IEnumerable<Presence> GetAllPresences();
void UpdatePresence(Presence presence);
void DeletePresence(int id);
}

View File

@ -1,80 +0,0 @@
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);
}
}
}

View File

@ -3,6 +3,8 @@ 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; }

View File

@ -1,33 +0,0 @@
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);
}
}
}

View File

@ -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+cefc9b3a85c12cb82d7e543ab8d2eb025849b9ec")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e86bec8a7f833b7d641968f35cc2ebce20da3dc8")]
[assembly: System.Reflection.AssemblyProductAttribute("Zurnal")]
[assembly: System.Reflection.AssemblyTitleAttribute("Zurnal")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
e861d9be05b9445b3ebef44d26117a8c4b30fb141208d42302beba8abc1372c1
91af4bd6b85cc028ddbbf62d14f2f440aae593b748896e98c6bba89005927b76

View File

@ -1 +1 @@
e818c2582926724344d87f9300781db10e3c61b91dde2011ab5210bca4cb8741
132477173c8f0b9bd98b70bc6d28240502a0a14c41a11367b550c5913679e10c

View File

@ -13,12 +13,8 @@
"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": [

View File

@ -5,13 +5,12 @@
<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\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\profi\.nuget\packages\</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')" />

View File

@ -2112,8 +2112,7 @@
]
},
"packageFolders": {
"C:\\Users\\profi\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
"C:\\Users\\profi\\.nuget\\packages\\": {}
},
"project": {
"version": "1.0.0",
@ -2124,12 +2123,8 @@
"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": [

View File

@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "/Ii72Vl1qzo=",
"dgSpecHash": "BG9wtY8hZA8=",
"success": true,
"projectFilePath": "C:\\Users\\profi\\source\\repos\\Zurnal\\Zurnal\\Zurnal.csproj",
"expectedPackageFiles": [