This commit is contained in:
Userok 2024-10-18 09:49:19 +03:00
parent 74ec2fdea7
commit 0a0aaa36af
20 changed files with 106 additions and 70 deletions

View File

@ -8,6 +8,6 @@
"\\Demo\\Domain\\UseCase",
"\\Demo\\UI"
],
"SelectedNode": "\\Demo\\Data\\Repository\\GroupRepositoryImpl.cs",
"SelectedNode": "\\Demo\\Domain\\UseCase\\UserUseCase.cs",
"PreviewInSolutionExplorer": false
}

Binary file not shown.

View File

@ -2,6 +2,10 @@
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\profi\\source\\repos\\presence\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\UserUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:Demo\\Domain\\UseCase\\UserUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\profi\\source\\repos\\presence\\Demo\\Data\\Repository\\GroupRepositoryImpl.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:Demo\\Data\\Repository\\GroupRepositoryImpl.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
@ -10,10 +14,6 @@
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\GroupUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:Demo\\Domain\\UseCase\\GroupUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\UserUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:Demo\\Domain\\UseCase\\UserUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\profi\\source\\repos\\presence\\Demo\\UI\\UserConsole.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:Demo\\UI\\UserConsole.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
@ -26,11 +26,11 @@
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"SelectedChildIndex": 2,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"DocumentIndex": 1,
"Title": "GroupRepositoryImpl.cs",
"DocumentMoniker": "C:\\Users\\profi\\source\\repos\\presence\\Demo\\Data\\Repository\\GroupRepositoryImpl.cs",
"RelativeDocumentMoniker": "Demo\\Data\\Repository\\GroupRepositoryImpl.cs",
@ -43,7 +43,7 @@
},
{
"$type": "Document",
"DocumentIndex": 1,
"DocumentIndex": 2,
"Title": "GroupUseCase.cs",
"DocumentMoniker": "C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\GroupUseCase.cs",
"RelativeDocumentMoniker": "Demo\\Domain\\UseCase\\GroupUseCase.cs",
@ -51,18 +51,17 @@
"RelativeToolTip": "Demo\\Domain\\UseCase\\GroupUseCase.cs",
"ViewState": "AgIAAAMAAAAAAAAAAAAAABoAAAAxAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-10-16T09:23:36.604Z",
"EditorCaption": ""
"WhenOpened": "2024-10-16T09:23:36.604Z"
},
{
"$type": "Document",
"DocumentIndex": 2,
"DocumentIndex": 0,
"Title": "UserUseCase.cs",
"DocumentMoniker": "C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\UserUseCase.cs",
"RelativeDocumentMoniker": "Demo\\Domain\\UseCase\\UserUseCase.cs",
"ToolTip": "C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\UserUseCase.cs",
"RelativeToolTip": "Demo\\Domain\\UseCase\\UserUseCase.cs",
"ViewState": "AgIAABIAAAAAAAAAAAAwwCIAAAAvAAAAAAAAAA==",
"ToolTip": "C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\UserUseCase.cs*",
"RelativeToolTip": "Demo\\Domain\\UseCase\\UserUseCase.cs*",
"ViewState": "AgIAAAAAAAAAAAAAAAAAACIAAAAvAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-10-16T09:39:07.152Z",
"EditorCaption": ""
@ -77,8 +76,7 @@
"RelativeToolTip": "Demo\\UI\\UserConsole.cs",
"ViewState": "AgIAAB4AAAAAAAAAAAAAADYAAAA5AAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-10-16T07:06:47.821Z",
"EditorCaption": ""
"WhenOpened": "2024-10-16T07:06:47.821Z"
}
]
}

View File

@ -2,6 +2,10 @@
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\profi\\source\\repos\\presence\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\UserUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:Demo\\Domain\\UseCase\\UserUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\profi\\source\\repos\\presence\\Demo\\Data\\Repository\\GroupRepositoryImpl.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:Demo\\Data\\Repository\\GroupRepositoryImpl.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
@ -10,10 +14,6 @@
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\GroupUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:Demo\\Domain\\UseCase\\GroupUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\UserUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:Demo\\Domain\\UseCase\\UserUseCase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\profi\\source\\repos\\presence\\Demo\\UI\\UserConsole.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:Demo\\UI\\UserConsole.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
@ -26,11 +26,11 @@
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"SelectedChildIndex": 2,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"DocumentIndex": 1,
"Title": "GroupRepositoryImpl.cs",
"DocumentMoniker": "C:\\Users\\profi\\source\\repos\\presence\\Demo\\Data\\Repository\\GroupRepositoryImpl.cs",
"RelativeDocumentMoniker": "Demo\\Data\\Repository\\GroupRepositoryImpl.cs",
@ -38,12 +38,11 @@
"RelativeToolTip": "Demo\\Data\\Repository\\GroupRepositoryImpl.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-10-17T11:23:48.997Z",
"EditorCaption": ""
"WhenOpened": "2024-10-17T11:23:48.997Z"
},
{
"$type": "Document",
"DocumentIndex": 1,
"DocumentIndex": 2,
"Title": "GroupUseCase.cs",
"DocumentMoniker": "C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\GroupUseCase.cs",
"RelativeDocumentMoniker": "Demo\\Domain\\UseCase\\GroupUseCase.cs",
@ -51,18 +50,17 @@
"RelativeToolTip": "Demo\\Domain\\UseCase\\GroupUseCase.cs",
"ViewState": "AgIAAAMAAAAAAAAAAAAAABoAAAAxAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-10-16T09:23:36.604Z",
"EditorCaption": ""
"WhenOpened": "2024-10-16T09:23:36.604Z"
},
{
"$type": "Document",
"DocumentIndex": 2,
"DocumentIndex": 0,
"Title": "UserUseCase.cs",
"DocumentMoniker": "C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\UserUseCase.cs",
"RelativeDocumentMoniker": "Demo\\Domain\\UseCase\\UserUseCase.cs",
"ToolTip": "C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\UserUseCase.cs",
"RelativeToolTip": "Demo\\Domain\\UseCase\\UserUseCase.cs",
"ViewState": "AgIAABIAAAAAAAAAAAAwwCIAAAAvAAAAAAAAAA==",
"ToolTip": "C:\\Users\\profi\\source\\repos\\presence\\Demo\\Domain\\UseCase\\UserUseCase.cs*",
"RelativeToolTip": "Demo\\Domain\\UseCase\\UserUseCase.cs*",
"ViewState": "AgIAABUAAAAAAAAAAAAAADIAAAANAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-10-16T09:39:07.152Z",
"EditorCaption": ""
@ -77,8 +75,7 @@
"RelativeToolTip": "Demo\\UI\\UserConsole.cs",
"ViewState": "AgIAAB4AAAAAAAAAAAAAADYAAAA5AAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-10-16T07:06:47.821Z",
"EditorCaption": ""
"WhenOpened": "2024-10-16T07:06:47.821Z"
}
]
}

Binary file not shown.

View File

@ -2,27 +2,44 @@
using Demo.domain.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Demo.Data.Repository
{
[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
public class GroupRepositoryImpl
{
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
}
public void AddGroup(GroupLocalEntity newGroup)
{
LocalStaticData.groups.Add(newGroup);
}
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
public void UpdateGroupName(int GroupId, string NewName)
{
var group = LocalStaticData.groups.FirstOrDefault(g => g.Id == GroupId);
if (group != null)
public void AddGroup(GroupLocalEntity newGroup)
{
group.Name = newName;
LocalStaticData.groups.Add(newGroup);
}
public void UpdateGroupName(int groupId, string newName)
{
var group = LocalStaticData.groups.FirstOrDefault(g => g.Id == groupId);
if (group != null)
{
group.Name = newName;
}
}
public GroupLocalEntity GetGroupById(int groupId)
{
return LocalStaticData.groups.FirstOrDefault(g => g.Id == groupId);
}
private static string GetDebuggerDisplay()
{
return $"GroupRepository with {LocalStaticData.groups.Count} groups";
}
internal void AddGroup(Group group)
{
throw new NotImplementedException();
}
}
}

View File

@ -11,9 +11,9 @@ namespace Demo.Data.Repository
public class UserRepositoryImpl
{
public UserRepositoryImpl() {
GetAllUsers = LocalStaticData.users;
}
public List<UserLocalEnity> GetAllUsers
{ get; set; }
@ -41,7 +41,6 @@ namespace Demo.Data.Repository
userLocal.FIO = userUpdateLocalEnity.FIO;
userLocal.GroupID = userUpdateLocalEnity.GroupID;
return userLocal;
}
}
}

25
Demo/Demo.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo", "Demo.csproj", "{B6BB8660-275A-42CF-978F-8D410FE7FEA5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B6BB8660-275A-42CF-978F-8D410FE7FEA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6BB8660-275A-42CF-978F-8D410FE7FEA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6BB8660-275A-42CF-978F-8D410FE7FEA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6BB8660-275A-42CF-978F-8D410FE7FEA5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4BCD1A90-B0DC-4013-B7B9-C109F9A925B4}
EndGlobalSection
EndGlobal

View File

@ -10,5 +10,11 @@ namespace Demo.domain.Models
{
public required int Id { get; set; }
public required string Name { get; set; }
public static implicit operator Group(GroupLocalEntity v)
{
throw new NotImplementedException();
}
}
}

View File

@ -24,18 +24,13 @@ namespace Demo.Domain.UseCase
public void AddGroup(Group group)
{
_repositoryGroupImpl.AddGroup(group);
_repositoryGroupImpl.AddGroup(group: group);
}
public void UpdateGroupName(int groupId, string newName)
{
var group = _repositoryGroupImpl.GetGroupById(groupId);
if (group != null)
{
group.Name = newName;
_repositoryGroupImpl.UpdateGroup(group);
}
}
{
_repositoryGroupImpl.UpdateGroupName(groupId, newName);
}
}
}

View File

@ -35,12 +35,13 @@ namespace Demo.Domain.UseCase
return _repositoryUserImpl.RemoveUserByGuid(userGuid);
}
public User UpdateUser(User user) {
UserLocalEnity userLocalEnity = new UserLocalEnity { FIO = user.FIO, GroupID = user.Group.Id, Guid = user.Guid };
UserLocalEnity? result = _repositoryUserImpl.UpdateUser(userLocalEnity);
UserLocalEnity userLocalEnity = new UserLocalEnity { FIO = user.FIO, GroupID = user.Group.Id, Guid = user.Guid };
UserLocalEnity? result = _repositoryUserImpl.UpdateUser(userLocalEnity);
if (result == null) throw new Exception("");
Group? group = GetAllGroups().FirstOrDefault(it => it.Id == result!.GroupID);
if (group == null) throw new Exception("");
return new User { FIO = user.FIO, Guid = user.Guid, Group = group};
if (group == null) throw new Exception("Группа не найдена");
return new User { FIO = user.FIO, Guid = user.Guid, Group = group };
}
public User FindUserByGuid(Guid userGuid)
{
@ -50,5 +51,4 @@ namespace Demo.Domain.UseCase
return new User { FIO = user.FIO, Guid = user.Guid, Group = group };
}
}
}
}
}

View File

@ -1,10 +1,9 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
// This code was generated by a tool.
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
@ -14,10 +13,10 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Demo")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+74ec2fdea7a678f89a686dd1c62c7529dfe83231")]
[assembly: System.Reflection.AssemblyProductAttribute("Demo")]
[assembly: System.Reflection.AssemblyTitleAttribute("Demo")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Создано классом WriteCodeFragment MSBuild.
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -1 +1 @@
eb16b2b154799358c5c37f7f25193ef306ab5592617791ff431f7a24a66875c2
99617ed546c21c3c878e2446fcd661ed283e5ecc68438b468fcd6c1917a360ae