This commit is contained in:
parent
cefc9b3a85
commit
6cd68fd8f8
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
|
internal interface IGroupRepository
|
||||||
{
|
{
|
||||||
@ -8,7 +9,7 @@ internal interface IGroupRepository
|
|||||||
{
|
{
|
||||||
return AllGroup.Select(g => new GroupDao { GroupName = g.GroupName, Id = g.Id });
|
return AllGroup.Select(g => new GroupDao { GroupName = g.GroupName, Id = g.Id });
|
||||||
}
|
}
|
||||||
|
List<GroupLocalEntity> GetAllGroup();
|
||||||
public bool RemoveGroupById(int groupId)
|
public bool RemoveGroupById(int groupId)
|
||||||
{
|
{
|
||||||
var group = AllGroup.FirstOrDefault(g => g.Id == 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.Data.Repository;
|
||||||
|
using Zurnal.domain.Models;
|
||||||
using Zurnal.RemaDateBase.DateDao;
|
using Zurnal.RemaDateBase.DateDao;
|
||||||
namespace Zurnal.Domain.UseCase
|
namespace Zurnal.Domain.UseCase
|
||||||
{
|
{
|
||||||
public class GroupUseCase : IGroupRepository
|
public class GroupUseCase : IGroupRepository
|
||||||
{
|
{
|
||||||
|
private readonly IGroupRepository _repository;
|
||||||
private List<GroupDao> _groups = new List<GroupDao>();
|
private List<GroupDao> _groups = new List<GroupDao>();
|
||||||
public List<GroupDao> AllGroup => _groups;
|
public List<GroupDao> AllGroup => _groups;
|
||||||
private UserRepositoryImpl _repositoryUserImpl;
|
private UserRepositoryImpl _repositoryUserImpl;
|
||||||
@ -59,5 +61,19 @@ namespace Zurnal.Domain.UseCase
|
|||||||
{
|
{
|
||||||
return _groups.FirstOrDefault(g => g.Id == id);
|
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.Domain.UseCase;
|
||||||
using Zurnal.Data.Repository;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Zurnal.Domain.UseCase;
|
using UI;
|
||||||
|
using Data.Repository;
|
||||||
|
|
||||||
GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl();
|
IServiceCollection services = new ServiceCollection();
|
||||||
UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl();
|
|
||||||
UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl);
|
|
||||||
|
|
||||||
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();
|
@ -3,8 +3,6 @@ using Zurnal.RemaDateBase.DateDao;
|
|||||||
|
|
||||||
public class RemoteDateBaseContext : DbContext
|
public class RemoteDateBaseContext : DbContext
|
||||||
{
|
{
|
||||||
public RemoteDateBaseContext() { }
|
|
||||||
|
|
||||||
public DbSet<GroupDao> Group { get; set; }
|
public DbSet<GroupDao> Group { get; set; }
|
||||||
public DbSet<UserDao> User { get; set; }
|
public DbSet<UserDao> User { get; set; }
|
||||||
public DbSet<PresnceDao> Presence { 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.AssemblyCompanyAttribute("Zurnal")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+979f0a84e8934a72efb3311a281d819c04f351b5")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cefc9b3a85c12cb82d7e543ab8d2eb025849b9ec")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("Zurnal")]
|
[assembly: System.Reflection.AssemblyProductAttribute("Zurnal")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Zurnal")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Zurnal")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
81b7b72033be0fe61e2a2ba2abf77030b6175ed4211ce31436b98277e897b53f
|
e861d9be05b9445b3ebef44d26117a8c4b30fb141208d42302beba8abc1372c1
|
||||||
|
Loading…
Reference in New Issue
Block a user