From 09de4581a82446540871f424eec8ea52be7d2a94 Mon Sep 17 00:00:00 2001
From: ksenianeva <95441235+ksenianeva@users.noreply.github.com>
Date: Fri, 1 Dec 2023 01:01:22 +0400
Subject: [PATCH] Partially done
---
.../AccountBusinessLogic.csproj | 14 ++
.../BusinessLogic/AccountLogic.cs | 94 +++++++++++
.../BusinessLogic/RoleLogic.cs | 93 +++++++++++
.../AccountContracts/AccountContracts.csproj | 13 ++
.../BindingModels/AccountBindingModel.cs | 18 +++
.../BindingModels/RoleBindingModel.cs | 15 ++
.../BusinessLogicsContracts/IAccountLogic.cs | 20 +++
.../BusinessLogicsContracts/IRoleLogic.cs | 20 +++
.../SearchModels/AccountSearchModel.cs | 13 ++
.../SearchModels/RoleSearchModel.cs | 13 ++
.../StoragesContracts/IAccountStorage.cs | 20 +++
.../StoragesContracts/IRoleStorage.cs | 20 +++
.../ViewModels/AccountViewModel.cs | 24 +++
.../ViewModels/RoleViewModel.cs | 18 +++
.../AccountDatabase.cs | 19 +++
.../AccountDatabaseImplement.csproj | 22 +++
.../Implements/AccountStorage.cs | 73 +++++++++
.../Implements/RoleStorage.cs | 73 +++++++++
.../20231130200453_InitialCreate.Designer.cs | 86 ++++++++++
.../20231130200453_InitialCreate.cs | 65 ++++++++
.../AccountDatabaseModelSnapshot.cs | 83 ++++++++++
.../Models/Account.cs | 63 ++++++++
.../AccountDatabaseImplement/Models/Role.cs | 55 +++++++
.../AccountsDataModels.csproj | 9 ++
NevaevaLibrary/AccountsDataModels/IId.cs | 7 +
.../Models/IAccountModel.cs | 16 ++
.../AccountsDataModels/Models/IRoleModel.cs | 13 ++
.../AccountsView/AccountsView.csproj | 28 ++++
.../AccountsView/FormAccount.Designer.cs | 153 ++++++++++++++++++
NevaevaLibrary/AccountsView/FormAccount.cs | 103 ++++++++++++
NevaevaLibrary/AccountsView/FormAccount.resx | 60 +++++++
.../AccountsView/FormMain.Designer.cs | 138 ++++++++++++++++
NevaevaLibrary/AccountsView/FormMain.cs | 62 +++++++
NevaevaLibrary/AccountsView/FormMain.resx | 63 ++++++++
.../AccountsView/FormRoles.Designer.cs | 89 ++++++++++
NevaevaLibrary/AccountsView/FormRoles.cs | 105 ++++++++++++
NevaevaLibrary/AccountsView/FormRoles.resx | 66 ++++++++
NevaevaLibrary/AccountsView/Program.cs | 41 +++++
NevaevaLibrary/NevaevaLibrary.sln | 32 +++-
.../LogicalComponents/WordTableComponent.cs | 18 +--
.../NevaevaLibrary/NevaevaLibrary.csproj | 1 +
41 files changed, 1928 insertions(+), 10 deletions(-)
create mode 100644 NevaevaLibrary/AccountBusinessLogic/AccountBusinessLogic.csproj
create mode 100644 NevaevaLibrary/AccountBusinessLogic/BusinessLogic/AccountLogic.cs
create mode 100644 NevaevaLibrary/AccountBusinessLogic/BusinessLogic/RoleLogic.cs
create mode 100644 NevaevaLibrary/AccountContracts/AccountContracts.csproj
create mode 100644 NevaevaLibrary/AccountContracts/BindingModels/AccountBindingModel.cs
create mode 100644 NevaevaLibrary/AccountContracts/BindingModels/RoleBindingModel.cs
create mode 100644 NevaevaLibrary/AccountContracts/BusinessLogicsContracts/IAccountLogic.cs
create mode 100644 NevaevaLibrary/AccountContracts/BusinessLogicsContracts/IRoleLogic.cs
create mode 100644 NevaevaLibrary/AccountContracts/SearchModels/AccountSearchModel.cs
create mode 100644 NevaevaLibrary/AccountContracts/SearchModels/RoleSearchModel.cs
create mode 100644 NevaevaLibrary/AccountContracts/StoragesContracts/IAccountStorage.cs
create mode 100644 NevaevaLibrary/AccountContracts/StoragesContracts/IRoleStorage.cs
create mode 100644 NevaevaLibrary/AccountContracts/ViewModels/AccountViewModel.cs
create mode 100644 NevaevaLibrary/AccountContracts/ViewModels/RoleViewModel.cs
create mode 100644 NevaevaLibrary/AccountDatabaseImplement/AccountDatabase.cs
create mode 100644 NevaevaLibrary/AccountDatabaseImplement/AccountDatabaseImplement.csproj
create mode 100644 NevaevaLibrary/AccountDatabaseImplement/Implements/AccountStorage.cs
create mode 100644 NevaevaLibrary/AccountDatabaseImplement/Implements/RoleStorage.cs
create mode 100644 NevaevaLibrary/AccountDatabaseImplement/Migrations/20231130200453_InitialCreate.Designer.cs
create mode 100644 NevaevaLibrary/AccountDatabaseImplement/Migrations/20231130200453_InitialCreate.cs
create mode 100644 NevaevaLibrary/AccountDatabaseImplement/Migrations/AccountDatabaseModelSnapshot.cs
create mode 100644 NevaevaLibrary/AccountDatabaseImplement/Models/Account.cs
create mode 100644 NevaevaLibrary/AccountDatabaseImplement/Models/Role.cs
create mode 100644 NevaevaLibrary/AccountsDataModels/AccountsDataModels.csproj
create mode 100644 NevaevaLibrary/AccountsDataModels/IId.cs
create mode 100644 NevaevaLibrary/AccountsDataModels/Models/IAccountModel.cs
create mode 100644 NevaevaLibrary/AccountsDataModels/Models/IRoleModel.cs
create mode 100644 NevaevaLibrary/AccountsView/AccountsView.csproj
create mode 100644 NevaevaLibrary/AccountsView/FormAccount.Designer.cs
create mode 100644 NevaevaLibrary/AccountsView/FormAccount.cs
create mode 100644 NevaevaLibrary/AccountsView/FormAccount.resx
create mode 100644 NevaevaLibrary/AccountsView/FormMain.Designer.cs
create mode 100644 NevaevaLibrary/AccountsView/FormMain.cs
create mode 100644 NevaevaLibrary/AccountsView/FormMain.resx
create mode 100644 NevaevaLibrary/AccountsView/FormRoles.Designer.cs
create mode 100644 NevaevaLibrary/AccountsView/FormRoles.cs
create mode 100644 NevaevaLibrary/AccountsView/FormRoles.resx
create mode 100644 NevaevaLibrary/AccountsView/Program.cs
diff --git a/NevaevaLibrary/AccountBusinessLogic/AccountBusinessLogic.csproj b/NevaevaLibrary/AccountBusinessLogic/AccountBusinessLogic.csproj
new file mode 100644
index 0000000..26d04bd
--- /dev/null
+++ b/NevaevaLibrary/AccountBusinessLogic/AccountBusinessLogic.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/NevaevaLibrary/AccountBusinessLogic/BusinessLogic/AccountLogic.cs b/NevaevaLibrary/AccountBusinessLogic/BusinessLogic/AccountLogic.cs
new file mode 100644
index 0000000..a8651a3
--- /dev/null
+++ b/NevaevaLibrary/AccountBusinessLogic/BusinessLogic/AccountLogic.cs
@@ -0,0 +1,94 @@
+using AccountContracts.BindingModels;
+using AccountContracts.BusinessLogicsContracts;
+using AccountContracts.SearchModels;
+using AccountContracts.StoragesContracts;
+using AccountContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static AccountBusinessLogic.BusinessLogic.AccountLogic;
+
+namespace AccountBusinessLogic.BusinessLogic
+{
+ public class AccountLogic : IAccountLogic
+ {
+ private readonly IAccountStorage _accountStorage;
+
+ public AccountLogic(IAccountStorage accountStorage)
+ {
+ _accountStorage = accountStorage;
+ }
+
+ public bool Create(AccountBindingModel model)
+ {
+ CheckModel(model);
+ if (_accountStorage.Insert(model) == null)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public bool Delete(AccountBindingModel model)
+ {
+ CheckModel(model, false);
+ if (_accountStorage.Delete(model) == null)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public AccountViewModel? ReadElement(AccountSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ var element = _accountStorage.GetElement(model);
+ if (element == null)
+ {
+ return null;
+ }
+ return element;
+ }
+
+ public List? ReadList(AccountSearchModel? model)
+ {
+ var list = _accountStorage.GetFullList();
+ if (list == null)
+ {
+ return null;
+ }
+ return list;
+ }
+
+ public bool Update(AccountBindingModel model)
+ {
+ CheckModel(model);
+ if (_accountStorage.Update(model) == null)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ private void CheckModel(AccountBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.Login))
+ {
+ throw new ArgumentNullException("Account's login is missing!", nameof(model.Login));
+ }
+ }
+ }
+}
diff --git a/NevaevaLibrary/AccountBusinessLogic/BusinessLogic/RoleLogic.cs b/NevaevaLibrary/AccountBusinessLogic/BusinessLogic/RoleLogic.cs
new file mode 100644
index 0000000..fe78649
--- /dev/null
+++ b/NevaevaLibrary/AccountBusinessLogic/BusinessLogic/RoleLogic.cs
@@ -0,0 +1,93 @@
+using AccountContracts.BindingModels;
+using AccountContracts.BusinessLogicsContracts;
+using AccountContracts.SearchModels;
+using AccountContracts.StoragesContracts;
+using AccountContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountBusinessLogic.BusinessLogic
+{
+ public class RoleLogic : IRoleLogic
+ {
+ private readonly IRoleStorage _roleStorage;
+
+ public RoleLogic(IRoleStorage roleStorage)
+ {
+ _roleStorage = roleStorage;
+ }
+
+ public bool Create(RoleBindingModel model)
+ {
+ CheckModel(model);
+ if (_roleStorage.Insert(model) == null)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public bool Delete(RoleBindingModel model)
+ {
+ CheckModel(model, false);
+ if (_roleStorage.Delete(model) == null)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public RoleViewModel? ReadElement(RoleSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ var element = _roleStorage.GetElement(model);
+ if (element == null)
+ {
+ return null;
+ }
+ return element;
+ }
+
+ public List? ReadList()
+ {
+ var list = _roleStorage.GetFullList();
+ if (list == null)
+ {
+ return null;
+ }
+ return list;
+ }
+
+ public bool Update(RoleBindingModel model)
+ {
+ CheckModel(model);
+ if (_roleStorage.Update(model) == null)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ private void CheckModel(RoleBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.RoleName))
+ {
+ throw new ArgumentNullException("Role's name is missing!", nameof(model.RoleName));
+ }
+ }
+ }
+ }
diff --git a/NevaevaLibrary/AccountContracts/AccountContracts.csproj b/NevaevaLibrary/AccountContracts/AccountContracts.csproj
new file mode 100644
index 0000000..7168be6
--- /dev/null
+++ b/NevaevaLibrary/AccountContracts/AccountContracts.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/NevaevaLibrary/AccountContracts/BindingModels/AccountBindingModel.cs b/NevaevaLibrary/AccountContracts/BindingModels/AccountBindingModel.cs
new file mode 100644
index 0000000..f9f2b08
--- /dev/null
+++ b/NevaevaLibrary/AccountContracts/BindingModels/AccountBindingModel.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using AccountsDataModels.Models;
+
+namespace AccountContracts.BindingModels
+{
+ public class AccountBindingModel : IAccountModel
+ {
+ public int Id { get; set; }
+ public string Login { get; set; } = string.Empty;
+ public string? Warnings { get; set; } = string.Empty;
+ public float? Rating { get; set; }
+ public int RoleId { get; set; }
+ }
+}
diff --git a/NevaevaLibrary/AccountContracts/BindingModels/RoleBindingModel.cs b/NevaevaLibrary/AccountContracts/BindingModels/RoleBindingModel.cs
new file mode 100644
index 0000000..1a702d8
--- /dev/null
+++ b/NevaevaLibrary/AccountContracts/BindingModels/RoleBindingModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using AccountsDataModels.Models;
+
+namespace AccountContracts.BindingModels
+{
+ public class RoleBindingModel : IRoleModel
+ {
+ public int Id { get; set; }
+ public string RoleName { get; set; } = string.Empty;
+ }
+}
diff --git a/NevaevaLibrary/AccountContracts/BusinessLogicsContracts/IAccountLogic.cs b/NevaevaLibrary/AccountContracts/BusinessLogicsContracts/IAccountLogic.cs
new file mode 100644
index 0000000..a3d31b3
--- /dev/null
+++ b/NevaevaLibrary/AccountContracts/BusinessLogicsContracts/IAccountLogic.cs
@@ -0,0 +1,20 @@
+using AccountContracts.BindingModels;
+using AccountContracts.SearchModels;
+using AccountContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountContracts.BusinessLogicsContracts
+{
+ public interface IAccountLogic
+ {
+ List? ReadList(AccountSearchModel? model);
+ AccountViewModel? ReadElement(AccountSearchModel model);
+ bool Create(AccountBindingModel model);
+ bool Update(AccountBindingModel model);
+ bool Delete(AccountBindingModel model);
+ }
+}
diff --git a/NevaevaLibrary/AccountContracts/BusinessLogicsContracts/IRoleLogic.cs b/NevaevaLibrary/AccountContracts/BusinessLogicsContracts/IRoleLogic.cs
new file mode 100644
index 0000000..6e8b977
--- /dev/null
+++ b/NevaevaLibrary/AccountContracts/BusinessLogicsContracts/IRoleLogic.cs
@@ -0,0 +1,20 @@
+using AccountContracts.BindingModels;
+using AccountContracts.SearchModels;
+using AccountContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountContracts.BusinessLogicsContracts
+{
+ public interface IRoleLogic
+ {
+ List ReadList();
+ RoleViewModel? ReadElement(RoleSearchModel model);
+ bool Create(RoleBindingModel model);
+ bool Update(RoleBindingModel model);
+ bool Delete(RoleBindingModel model);
+ }
+}
diff --git a/NevaevaLibrary/AccountContracts/SearchModels/AccountSearchModel.cs b/NevaevaLibrary/AccountContracts/SearchModels/AccountSearchModel.cs
new file mode 100644
index 0000000..1612fb7
--- /dev/null
+++ b/NevaevaLibrary/AccountContracts/SearchModels/AccountSearchModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountContracts.SearchModels
+{
+ public class AccountSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/NevaevaLibrary/AccountContracts/SearchModels/RoleSearchModel.cs b/NevaevaLibrary/AccountContracts/SearchModels/RoleSearchModel.cs
new file mode 100644
index 0000000..7a6628a
--- /dev/null
+++ b/NevaevaLibrary/AccountContracts/SearchModels/RoleSearchModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountContracts.SearchModels
+{
+ public class RoleSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/NevaevaLibrary/AccountContracts/StoragesContracts/IAccountStorage.cs b/NevaevaLibrary/AccountContracts/StoragesContracts/IAccountStorage.cs
new file mode 100644
index 0000000..48679b4
--- /dev/null
+++ b/NevaevaLibrary/AccountContracts/StoragesContracts/IAccountStorage.cs
@@ -0,0 +1,20 @@
+using AccountContracts.BindingModels;
+using AccountContracts.SearchModels;
+using AccountContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountContracts.StoragesContracts
+{
+ public interface IAccountStorage
+ {
+ List GetFullList();
+ AccountViewModel? GetElement(AccountSearchModel model);
+ AccountViewModel? Insert(AccountBindingModel model);
+ AccountViewModel? Update(AccountBindingModel model);
+ AccountViewModel? Delete(AccountBindingModel model);
+ }
+}
diff --git a/NevaevaLibrary/AccountContracts/StoragesContracts/IRoleStorage.cs b/NevaevaLibrary/AccountContracts/StoragesContracts/IRoleStorage.cs
new file mode 100644
index 0000000..29f09f3
--- /dev/null
+++ b/NevaevaLibrary/AccountContracts/StoragesContracts/IRoleStorage.cs
@@ -0,0 +1,20 @@
+using AccountContracts.BindingModels;
+using AccountContracts.SearchModels;
+using AccountContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountContracts.StoragesContracts
+{
+ public interface IRoleStorage
+ {
+ List GetFullList();
+ RoleViewModel? GetElement(RoleSearchModel model);
+ RoleViewModel? Insert(RoleBindingModel model);
+ RoleViewModel? Update(RoleBindingModel model);
+ RoleViewModel? Delete(RoleBindingModel model);
+ }
+}
diff --git a/NevaevaLibrary/AccountContracts/ViewModels/AccountViewModel.cs b/NevaevaLibrary/AccountContracts/ViewModels/AccountViewModel.cs
new file mode 100644
index 0000000..34f4905
--- /dev/null
+++ b/NevaevaLibrary/AccountContracts/ViewModels/AccountViewModel.cs
@@ -0,0 +1,24 @@
+using AccountsDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountContracts.ViewModels
+{
+ public class AccountViewModel : IAccountModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Логин")]
+ public string Login { get; set; } = string.Empty;
+ [DisplayName("Рейтинг")]
+ public float? Rating { get; set; }
+ [DisplayName("Предупреждения")]
+ public string? Warnings { get; set; } = string.Empty;
+ public int RoleId { get; set; }
+ [DisplayName("Роль")]
+ public string RoleName { get; set; }
+ }
+}
diff --git a/NevaevaLibrary/AccountContracts/ViewModels/RoleViewModel.cs b/NevaevaLibrary/AccountContracts/ViewModels/RoleViewModel.cs
new file mode 100644
index 0000000..cd6371b
--- /dev/null
+++ b/NevaevaLibrary/AccountContracts/ViewModels/RoleViewModel.cs
@@ -0,0 +1,18 @@
+using AccountContracts.BusinessLogicsContracts;
+using AccountsDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountContracts.ViewModels
+{
+ public class RoleViewModel : IRoleModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название")]
+ public string RoleName { get; set; } = string.Empty;
+ }
+}
diff --git a/NevaevaLibrary/AccountDatabaseImplement/AccountDatabase.cs b/NevaevaLibrary/AccountDatabaseImplement/AccountDatabase.cs
new file mode 100644
index 0000000..78e471c
--- /dev/null
+++ b/NevaevaLibrary/AccountDatabaseImplement/AccountDatabase.cs
@@ -0,0 +1,19 @@
+using AccountDatabaseImplement.Models;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountDatabaseImplement
+{
+ public class AccountDatabase : DbContext
+ {
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ => optionsBuilder.UseNpgsql("Host=localhost;Database=AccountsDB;Username=postgres;Password=1234");
+ public virtual DbSet Roles { set; get; }
+ public virtual DbSet Accounts { set; get; }
+ }
+}
diff --git a/NevaevaLibrary/AccountDatabaseImplement/AccountDatabaseImplement.csproj b/NevaevaLibrary/AccountDatabaseImplement/AccountDatabaseImplement.csproj
new file mode 100644
index 0000000..5487f24
--- /dev/null
+++ b/NevaevaLibrary/AccountDatabaseImplement/AccountDatabaseImplement.csproj
@@ -0,0 +1,22 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
diff --git a/NevaevaLibrary/AccountDatabaseImplement/Implements/AccountStorage.cs b/NevaevaLibrary/AccountDatabaseImplement/Implements/AccountStorage.cs
new file mode 100644
index 0000000..fb53472
--- /dev/null
+++ b/NevaevaLibrary/AccountDatabaseImplement/Implements/AccountStorage.cs
@@ -0,0 +1,73 @@
+using AccountContracts.BindingModels;
+using AccountContracts.SearchModels;
+using AccountContracts.StoragesContracts;
+using AccountContracts.ViewModels;
+using AccountDatabaseImplement.Models;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountDatabaseImplement.Implements
+{
+ public class AccountStorage : IAccountStorage
+ {
+ public List GetFullList()
+ {
+ using var context = new AccountDatabase();
+ return context.Accounts.Include(x => x.Role)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ public AccountViewModel? GetElement(AccountSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return new();
+ }
+
+ using var context = new AccountDatabase();
+ return context.Accounts.Include(x => x.Role)
+ .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
+ ?.GetViewModel;
+ }
+ public AccountViewModel? Insert(AccountBindingModel model)
+ {
+ using var context = new AccountDatabase();
+ var newAccount = Account.Create(model, context);
+ if (newAccount == null)
+ {
+ return null;
+ }
+ context.Accounts.Add(newAccount);
+ context.SaveChanges();
+ return newAccount.GetViewModel;
+ }
+ public AccountViewModel? Update(AccountBindingModel model)
+ {
+ using var context = new AccountDatabase();
+ var account = context.Accounts.FirstOrDefault(x => x.Id == model.Id);
+ if (account == null)
+ {
+ return null;
+ }
+ account.Update(model);
+ context.SaveChanges();
+ return account.GetViewModel;
+ }
+ public AccountViewModel? Delete(AccountBindingModel model)
+ {
+ using var context = new AccountDatabase();
+ var element = context.Accounts.FirstOrDefault(rec => rec.Id == model.Id);
+ if (element != null)
+ {
+ context.Accounts.Remove(element);
+ context.SaveChanges();
+ return element.GetViewModel;
+ }
+ return null;
+ }
+ }
+}
diff --git a/NevaevaLibrary/AccountDatabaseImplement/Implements/RoleStorage.cs b/NevaevaLibrary/AccountDatabaseImplement/Implements/RoleStorage.cs
new file mode 100644
index 0000000..403ee9a
--- /dev/null
+++ b/NevaevaLibrary/AccountDatabaseImplement/Implements/RoleStorage.cs
@@ -0,0 +1,73 @@
+using AccountContracts.BindingModels;
+using AccountContracts.SearchModels;
+using AccountContracts.StoragesContracts;
+using AccountContracts.ViewModels;
+using AccountDatabaseImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountDatabaseImplement.Implements
+{
+ public class RoleStorage : IRoleStorage
+ {
+ public List GetFullList()
+ {
+ using var context = new AccountDatabase();
+ return context.Roles
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+
+ public RoleViewModel? GetElement(RoleSearchModel model)
+ {
+ using var context = new AccountDatabase();
+ return context.Roles
+ .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))
+ ?.GetViewModel;
+ }
+
+ public RoleViewModel? Insert(RoleBindingModel model)
+ {
+ var newRole = Role.Create(model);
+ if (newRole == null)
+ {
+ return null;
+ }
+ using var context = new AccountDatabase();
+ context.Roles.Add(newRole);
+ context.SaveChanges();
+ return newRole.GetViewModel;
+ }
+
+ public RoleViewModel? Update(RoleBindingModel model)
+ {
+ using var context = new AccountDatabase();
+ var role = context.Roles.FirstOrDefault(x => x.Id == model.Id);
+ if (role == null)
+ {
+ return null;
+ }
+ role.Update(model);
+ context.SaveChanges();
+ return role.GetViewModel;
+ }
+
+ public RoleViewModel? Delete(RoleBindingModel model)
+ {
+ using var context = new AccountDatabase();
+ var element = context.Roles.FirstOrDefault(rec => rec.Id == model.Id);
+ if (element != null)
+ {
+ context.Roles.Remove(element);
+ context.SaveChanges();
+ return element.GetViewModel;
+ }
+ return null;
+ }
+
+ }
+}
diff --git a/NevaevaLibrary/AccountDatabaseImplement/Migrations/20231130200453_InitialCreate.Designer.cs b/NevaevaLibrary/AccountDatabaseImplement/Migrations/20231130200453_InitialCreate.Designer.cs
new file mode 100644
index 0000000..84bf7aa
--- /dev/null
+++ b/NevaevaLibrary/AccountDatabaseImplement/Migrations/20231130200453_InitialCreate.Designer.cs
@@ -0,0 +1,86 @@
+//
+using System;
+using AccountDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace AccountDatabaseImplement.Migrations
+{
+ [DbContext(typeof(AccountDatabase))]
+ [Migration("20231130200453_InitialCreate")]
+ partial class InitialCreate
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("AccountDatabaseImplement.Models.Account", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Login")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Rating")
+ .HasColumnType("real");
+
+ b.Property("RoleId")
+ .HasColumnType("integer");
+
+ b.Property("Warnings")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("Accounts");
+ });
+
+ modelBuilder.Entity("AccountDatabaseImplement.Models.Role", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("RoleName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Roles");
+ });
+
+ modelBuilder.Entity("AccountDatabaseImplement.Models.Account", b =>
+ {
+ b.HasOne("AccountDatabaseImplement.Models.Role", "Role")
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/NevaevaLibrary/AccountDatabaseImplement/Migrations/20231130200453_InitialCreate.cs b/NevaevaLibrary/AccountDatabaseImplement/Migrations/20231130200453_InitialCreate.cs
new file mode 100644
index 0000000..e4d8ea0
--- /dev/null
+++ b/NevaevaLibrary/AccountDatabaseImplement/Migrations/20231130200453_InitialCreate.cs
@@ -0,0 +1,65 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace AccountDatabaseImplement.Migrations
+{
+ ///
+ public partial class InitialCreate : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Roles",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ RoleName = table.Column(type: "text", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Roles", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Accounts",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Login = table.Column(type: "text", nullable: false),
+ Warnings = table.Column(type: "text", nullable: true),
+ Rating = table.Column(type: "real", nullable: true),
+ RoleId = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Accounts", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Accounts_Roles_RoleId",
+ column: x => x.RoleId,
+ principalTable: "Roles",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Accounts_RoleId",
+ table: "Accounts",
+ column: "RoleId");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Accounts");
+
+ migrationBuilder.DropTable(
+ name: "Roles");
+ }
+ }
+}
diff --git a/NevaevaLibrary/AccountDatabaseImplement/Migrations/AccountDatabaseModelSnapshot.cs b/NevaevaLibrary/AccountDatabaseImplement/Migrations/AccountDatabaseModelSnapshot.cs
new file mode 100644
index 0000000..4510e54
--- /dev/null
+++ b/NevaevaLibrary/AccountDatabaseImplement/Migrations/AccountDatabaseModelSnapshot.cs
@@ -0,0 +1,83 @@
+//
+using System;
+using AccountDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace AccountDatabaseImplement.Migrations
+{
+ [DbContext(typeof(AccountDatabase))]
+ partial class AccountDatabaseModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("AccountDatabaseImplement.Models.Account", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Login")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Rating")
+ .HasColumnType("real");
+
+ b.Property("RoleId")
+ .HasColumnType("integer");
+
+ b.Property("Warnings")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("Accounts");
+ });
+
+ modelBuilder.Entity("AccountDatabaseImplement.Models.Role", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("RoleName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Roles");
+ });
+
+ modelBuilder.Entity("AccountDatabaseImplement.Models.Account", b =>
+ {
+ b.HasOne("AccountDatabaseImplement.Models.Role", "Role")
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/NevaevaLibrary/AccountDatabaseImplement/Models/Account.cs b/NevaevaLibrary/AccountDatabaseImplement/Models/Account.cs
new file mode 100644
index 0000000..bc65bfe
--- /dev/null
+++ b/NevaevaLibrary/AccountDatabaseImplement/Models/Account.cs
@@ -0,0 +1,63 @@
+using AccountContracts.BindingModels;
+using AccountContracts.ViewModels;
+using AccountsDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountDatabaseImplement.Models
+{
+ public class Account : IAccountModel
+ {
+ public int Id { get; private set; }
+ [Required]
+ public string Login { get; set; }
+ public string? Warnings { get; set; }
+ public float? Rating { get; set; }
+ [Required]
+ public int RoleId { get; set; }
+ public virtual Role Role { get; set; } = new();
+
+
+ public static Account? Create(AccountBindingModel? model, AccountDatabase context)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Account()
+ {
+ Id = model.Id,
+ Login = model.Login,
+ Warnings = model.Warnings,
+ Rating = model.Rating,
+ RoleId = model.RoleId,
+ Role = context.Roles.First(x => x.Id == model.RoleId),
+ };
+ }
+ public void Update(AccountBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Login = model.Login;
+ Warnings = model.Warnings;
+ Rating = model.Rating;
+ }
+ public AccountViewModel GetViewModel => new()
+ {
+ Id = Id,
+ Login = Login,
+ Warnings = Warnings,
+ Rating = Rating,
+ RoleId = RoleId,
+ RoleName = Role.RoleName,
+ };
+
+ }
+}
diff --git a/NevaevaLibrary/AccountDatabaseImplement/Models/Role.cs b/NevaevaLibrary/AccountDatabaseImplement/Models/Role.cs
new file mode 100644
index 0000000..a6622de
--- /dev/null
+++ b/NevaevaLibrary/AccountDatabaseImplement/Models/Role.cs
@@ -0,0 +1,55 @@
+using AccountContracts.BindingModels;
+using AccountContracts.ViewModels;
+using AccountsDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountDatabaseImplement.Models
+{
+ public class Role : IRoleModel
+ {
+ public int Id { get; private set; }
+ [Required]
+ public string RoleName { get; private set; } = string.Empty;
+
+ public static Role? Create(RoleBindingModel model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Role()
+ {
+ Id = model.Id,
+ RoleName = model.RoleName,
+ };
+ }
+ public static Role Create(RoleViewModel model)
+ {
+ return new Role
+ {
+ Id = model.Id,
+ RoleName = model.RoleName,
+ };
+ }
+ public void Update(RoleBindingModel model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ RoleName = model.RoleName;
+ }
+ public RoleViewModel GetViewModel => new()
+ {
+ Id = Id,
+ RoleName = RoleName,
+ };
+
+ }
+}
+
diff --git a/NevaevaLibrary/AccountsDataModels/AccountsDataModels.csproj b/NevaevaLibrary/AccountsDataModels/AccountsDataModels.csproj
new file mode 100644
index 0000000..132c02c
--- /dev/null
+++ b/NevaevaLibrary/AccountsDataModels/AccountsDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/NevaevaLibrary/AccountsDataModels/IId.cs b/NevaevaLibrary/AccountsDataModels/IId.cs
new file mode 100644
index 0000000..d6c9c7c
--- /dev/null
+++ b/NevaevaLibrary/AccountsDataModels/IId.cs
@@ -0,0 +1,7 @@
+namespace AccountsDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
\ No newline at end of file
diff --git a/NevaevaLibrary/AccountsDataModels/Models/IAccountModel.cs b/NevaevaLibrary/AccountsDataModels/Models/IAccountModel.cs
new file mode 100644
index 0000000..daa383c
--- /dev/null
+++ b/NevaevaLibrary/AccountsDataModels/Models/IAccountModel.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountsDataModels.Models
+{
+ public interface IAccountModel : IId
+ {
+ string Login { get; }
+ float? Rating { get; }
+ string? Warnings { get; }
+ int RoleId { get; }
+ }
+}
diff --git a/NevaevaLibrary/AccountsDataModels/Models/IRoleModel.cs b/NevaevaLibrary/AccountsDataModels/Models/IRoleModel.cs
new file mode 100644
index 0000000..64c808e
--- /dev/null
+++ b/NevaevaLibrary/AccountsDataModels/Models/IRoleModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountsDataModels.Models
+{
+ public interface IRoleModel : IId
+ {
+ string RoleName { get;}
+ }
+}
diff --git a/NevaevaLibrary/AccountsView/AccountsView.csproj b/NevaevaLibrary/AccountsView/AccountsView.csproj
new file mode 100644
index 0000000..994ec10
--- /dev/null
+++ b/NevaevaLibrary/AccountsView/AccountsView.csproj
@@ -0,0 +1,28 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/NevaevaLibrary/AccountsView/FormAccount.Designer.cs b/NevaevaLibrary/AccountsView/FormAccount.Designer.cs
new file mode 100644
index 0000000..7370577
--- /dev/null
+++ b/NevaevaLibrary/AccountsView/FormAccount.Designer.cs
@@ -0,0 +1,153 @@
+namespace AccountsView
+{
+ partial class FormAccount
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.controlInputRating = new ControlsLibraryNet60.Input.ControlInputNullableDouble();
+ this.comboBoxControlRole = new NevaevaLibrary.ComboBoxControl();
+ this.textBoxLogin = new System.Windows.Forms.TextBox();
+ this.textBoxWarnings = new System.Windows.Forms.TextBox();
+ this.labelLogin = new System.Windows.Forms.Label();
+ this.labelWarnings = new System.Windows.Forms.Label();
+ this.labelRating = new System.Windows.Forms.Label();
+ this.labelAccount = new System.Windows.Forms.Label();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // controlInputRating
+ //
+ this.controlInputRating.Location = new System.Drawing.Point(14, 219);
+ this.controlInputRating.Margin = new System.Windows.Forms.Padding(5, 8, 5, 8);
+ this.controlInputRating.Name = "controlInputRating";
+ this.controlInputRating.Size = new System.Drawing.Size(331, 36);
+ this.controlInputRating.TabIndex = 0;
+ this.controlInputRating.Value = null;
+ //
+ // comboBoxControlRole
+ //
+ this.comboBoxControlRole.Location = new System.Drawing.Point(22, 34);
+ this.comboBoxControlRole.Name = "comboBoxControlRole";
+ this.comboBoxControlRole.SelectedValue = "";
+ this.comboBoxControlRole.Size = new System.Drawing.Size(333, 44);
+ this.comboBoxControlRole.TabIndex = 1;
+ //
+ // textBoxLogin
+ //
+ this.textBoxLogin.Location = new System.Drawing.Point(22, 93);
+ this.textBoxLogin.Name = "textBoxLogin";
+ this.textBoxLogin.Size = new System.Drawing.Size(323, 27);
+ this.textBoxLogin.TabIndex = 2;
+ //
+ // textBoxWarnings
+ //
+ this.textBoxWarnings.Location = new System.Drawing.Point(22, 151);
+ this.textBoxWarnings.Name = "textBoxWarnings";
+ this.textBoxWarnings.Size = new System.Drawing.Size(323, 27);
+ this.textBoxWarnings.TabIndex = 3;
+ //
+ // labelLogin
+ //
+ this.labelLogin.AutoSize = true;
+ this.labelLogin.Location = new System.Drawing.Point(22, 70);
+ this.labelLogin.Name = "labelLogin";
+ this.labelLogin.Size = new System.Drawing.Size(52, 20);
+ this.labelLogin.TabIndex = 4;
+ this.labelLogin.Text = "Логин";
+ //
+ // labelWarnings
+ //
+ this.labelWarnings.AutoSize = true;
+ this.labelWarnings.Location = new System.Drawing.Point(22, 128);
+ this.labelWarnings.Name = "labelWarnings";
+ this.labelWarnings.Size = new System.Drawing.Size(131, 20);
+ this.labelWarnings.TabIndex = 5;
+ this.labelWarnings.Text = "Предупреждения";
+ //
+ // labelRating
+ //
+ this.labelRating.AutoSize = true;
+ this.labelRating.Location = new System.Drawing.Point(26, 191);
+ this.labelRating.Name = "labelRating";
+ this.labelRating.Size = new System.Drawing.Size(64, 20);
+ this.labelRating.TabIndex = 6;
+ this.labelRating.Text = "Рейтинг";
+ //
+ // labelAccount
+ //
+ this.labelAccount.AutoSize = true;
+ this.labelAccount.Location = new System.Drawing.Point(25, 8);
+ this.labelAccount.Name = "labelAccount";
+ this.labelAccount.Size = new System.Drawing.Size(63, 20);
+ this.labelAccount.TabIndex = 7;
+ this.labelAccount.Text = "Аккаунт";
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(36, 262);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(94, 29);
+ this.buttonAdd.TabIndex = 8;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // FormAccount
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(404, 307);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.labelAccount);
+ this.Controls.Add(this.labelRating);
+ this.Controls.Add(this.labelWarnings);
+ this.Controls.Add(this.labelLogin);
+ this.Controls.Add(this.textBoxWarnings);
+ this.Controls.Add(this.textBoxLogin);
+ this.Controls.Add(this.comboBoxControlRole);
+ this.Controls.Add(this.controlInputRating);
+ this.Name = "FormAccount";
+ this.Text = "FormAccount";
+ this.Load += new System.EventHandler(this.FormAccount_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private ControlsLibraryNet60.Input.ControlInputNullableDouble controlInputRating;
+ private NevaevaLibrary.ComboBoxControl comboBoxControlRole;
+ private TextBox textBoxLogin;
+ private TextBox textBoxWarnings;
+ private Label labelLogin;
+ private Label labelWarnings;
+ private Label labelRating;
+ private Label labelAccount;
+ private Button buttonAdd;
+ }
+}
\ No newline at end of file
diff --git a/NevaevaLibrary/AccountsView/FormAccount.cs b/NevaevaLibrary/AccountsView/FormAccount.cs
new file mode 100644
index 0000000..15139c1
--- /dev/null
+++ b/NevaevaLibrary/AccountsView/FormAccount.cs
@@ -0,0 +1,103 @@
+using AbazovViewComponents.Components;
+using AccountContracts.BindingModels;
+using AccountContracts.BusinessLogicsContracts;
+using AccountContracts.SearchModels;
+using AccountContracts.ViewModels;
+using NevaevaLibrary;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace AccountsView
+{
+ public partial class FormAccount : Form
+ {
+ private int? _id;
+ private readonly IAccountLogic _logic;
+ private readonly IRoleLogic _roleLogic;
+ private List _roles;
+ public int Id { set { _id = value; } }
+
+ public FormAccount(IAccountLogic logic, IRoleLogic roleLogic)
+ {
+ InitializeComponent();
+ _logic = logic;
+ _roleLogic = roleLogic;
+ _roles = new List();
+ }
+
+ private void FormAccount_Load(object sender, EventArgs e)
+ {
+ _roles = _roleLogic.ReadList();
+ comboBoxControlRole.addItems(_roles.Select(x => x.RoleName).ToList());
+ if (_id.HasValue)
+ {
+ try
+ {
+ var view = _logic.ReadElement(new AccountSearchModel { Id = _id.Value });
+ if (view != null)
+ {
+ textBoxLogin.Text = view.Login;
+ textBoxWarnings.Text = view.Warnings;
+ controlInputRating.Value = view.Rating;
+
+ comboBoxControlRole.SelectedValue = view.RoleName;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxLogin.Text))
+ {
+ MessageBox.Show("Заполните логин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (string.IsNullOrEmpty(comboBoxControlRole.SelectedValue))
+ {
+ MessageBox.Show("Выберете роль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ try
+ {
+ var model = new AccountBindingModel
+ {
+ Id = _id ?? 0,
+ Login = textBoxLogin.Text,
+ Warnings = textBoxWarnings.Text,
+ Rating = (float)controlInputRating.Value,
+ RoleId = _roles.First(x => x.RoleName == comboBoxControlRole.SelectedValue).Id,
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+}
diff --git a/NevaevaLibrary/AccountsView/FormAccount.resx b/NevaevaLibrary/AccountsView/FormAccount.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/NevaevaLibrary/AccountsView/FormAccount.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/NevaevaLibrary/AccountsView/FormMain.Designer.cs b/NevaevaLibrary/AccountsView/FormMain.Designer.cs
new file mode 100644
index 0000000..1a7c97a
--- /dev/null
+++ b/NevaevaLibrary/AccountsView/FormMain.Designer.cs
@@ -0,0 +1,138 @@
+namespace AccountsView
+{
+ partial class FormMain
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.menuStrip1 = new System.Windows.Forms.MenuStrip();
+ this.аккаунтыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.создатьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.редактироватьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.удалитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.отчётыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ролиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.abazovTreeView = new AbazovViewComponents.Components.AbazovTreeView();
+ this.menuStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // menuStrip1
+ //
+ this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
+ this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.аккаунтыToolStripMenuItem,
+ this.отчётыToolStripMenuItem,
+ this.ролиToolStripMenuItem});
+ this.menuStrip1.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip1.Name = "menuStrip1";
+ this.menuStrip1.Size = new System.Drawing.Size(800, 28);
+ this.menuStrip1.TabIndex = 0;
+ this.menuStrip1.Text = "menuStrip1";
+ //
+ // аккаунтыToolStripMenuItem
+ //
+ this.аккаунтыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.создатьToolStripMenuItem,
+ this.редактироватьToolStripMenuItem,
+ this.удалитьToolStripMenuItem});
+ this.аккаунтыToolStripMenuItem.Name = "аккаунтыToolStripMenuItem";
+ this.аккаунтыToolStripMenuItem.Size = new System.Drawing.Size(88, 24);
+ this.аккаунтыToolStripMenuItem.Text = "Аккаунты";
+ //
+ // создатьToolStripMenuItem
+ //
+ this.создатьToolStripMenuItem.Name = "создатьToolStripMenuItem";
+ this.создатьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
+ this.создатьToolStripMenuItem.Size = new System.Drawing.Size(246, 26);
+ this.создатьToolStripMenuItem.Text = "Создать";
+ this.создатьToolStripMenuItem.Click += new System.EventHandler(this.создатьToolStripMenuItem_Click);
+ //
+ // редактироватьToolStripMenuItem
+ //
+ this.редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
+ this.редактироватьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
+ this.редактироватьToolStripMenuItem.Size = new System.Drawing.Size(246, 26);
+ this.редактироватьToolStripMenuItem.Text = "Редактировать";
+ //
+ // удалитьToolStripMenuItem
+ //
+ this.удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
+ this.удалитьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
+ this.удалитьToolStripMenuItem.Size = new System.Drawing.Size(246, 26);
+ this.удалитьToolStripMenuItem.Text = "Удалить";
+ //
+ // отчётыToolStripMenuItem
+ //
+ this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
+ this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
+ this.отчётыToolStripMenuItem.Text = "Отчёты";
+ //
+ // ролиToolStripMenuItem
+ //
+ this.ролиToolStripMenuItem.Name = "ролиToolStripMenuItem";
+ this.ролиToolStripMenuItem.Size = new System.Drawing.Size(57, 24);
+ this.ролиToolStripMenuItem.Text = "Роли";
+ this.ролиToolStripMenuItem.Click += new System.EventHandler(this.ролиToolStripMenuItem_Click);
+ //
+ // abazovTreeView
+ //
+ this.abazovTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.abazovTreeView.Location = new System.Drawing.Point(0, 28);
+ this.abazovTreeView.Name = "abazovTreeView";
+ this.abazovTreeView.SelectedNodeIndex = -1;
+ this.abazovTreeView.Size = new System.Drawing.Size(800, 422);
+ this.abazovTreeView.TabIndex = 1;
+ //
+ // FormMain
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.abazovTreeView);
+ this.Controls.Add(this.menuStrip1);
+ this.MainMenuStrip = this.menuStrip1;
+ this.Name = "FormMain";
+ this.Text = "Аккаунты";
+ this.Load += new System.EventHandler(this.FormMain_Load);
+ this.menuStrip1.ResumeLayout(false);
+ this.menuStrip1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem аккаунтыToolStripMenuItem;
+ private ToolStripMenuItem отчётыToolStripMenuItem;
+ private ToolStripMenuItem ролиToolStripMenuItem;
+ private AbazovViewComponents.Components.AbazovTreeView abazovTreeView;
+ private ToolStripMenuItem создатьToolStripMenuItem;
+ private ToolStripMenuItem редактироватьToolStripMenuItem;
+ private ToolStripMenuItem удалитьToolStripMenuItem;
+ }
+}
\ No newline at end of file
diff --git a/NevaevaLibrary/AccountsView/FormMain.cs b/NevaevaLibrary/AccountsView/FormMain.cs
new file mode 100644
index 0000000..dcf76eb
--- /dev/null
+++ b/NevaevaLibrary/AccountsView/FormMain.cs
@@ -0,0 +1,62 @@
+using AccountContracts.BusinessLogicsContracts;
+using ControlsLibraryNet60.Core;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace AccountsView
+{
+ public partial class FormMain : Form
+ {
+ private IAccountLogic _logic;
+
+ public FormMain(IAccountLogic logic)
+ {
+ InitializeComponent();
+ _logic = logic;
+ abazovTreeView.setHierarchy(new List<(string, bool)> { ("RoleName", false), ("Rating", true), ("Id", true), ("Login", true) });
+ }
+
+ private void ролиToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormRoles));
+ if (service is FormRoles form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ abazovTreeView.clear();
+ var accounts = _logic.ReadList(null);
+ if (accounts != null)
+ {
+ abazovTreeView.addItems(accounts);
+ }
+ }
+
+ private void создатьToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormAccount));
+ if (service is FormAccount form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+}
diff --git a/NevaevaLibrary/AccountsView/FormMain.resx b/NevaevaLibrary/AccountsView/FormMain.resx
new file mode 100644
index 0000000..938108a
--- /dev/null
+++ b/NevaevaLibrary/AccountsView/FormMain.resx
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/NevaevaLibrary/AccountsView/FormRoles.Designer.cs b/NevaevaLibrary/AccountsView/FormRoles.Designer.cs
new file mode 100644
index 0000000..d112838
--- /dev/null
+++ b/NevaevaLibrary/AccountsView/FormRoles.Designer.cs
@@ -0,0 +1,89 @@
+namespace AccountsView
+{
+ partial class FormRoles
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.NameCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.NameCol,
+ this.Id});
+ this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGridView.Location = new System.Drawing.Point(0, 0);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(800, 450);
+ this.dataGridView.TabIndex = 0;
+ this.dataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellValueChanged);
+ this.dataGridView.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.dataGridView_UserDeletingRow);
+ this.dataGridView.KeyUp += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyUp);
+ //
+ // NameCol
+ //
+ this.NameCol.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.NameCol.HeaderText = "Название";
+ this.NameCol.MinimumWidth = 6;
+ this.NameCol.Name = "NameCol";
+ //
+ // Id
+ //
+ this.Id.HeaderText = "Id";
+ this.Id.MinimumWidth = 6;
+ this.Id.Name = "Id";
+ this.Id.Visible = false;
+ this.Id.Width = 125;
+ //
+ // FormRoles
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormRoles";
+ this.Text = "FormRoles";
+ this.Load += new System.EventHandler(this.FormRoles_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn NameCol;
+ private DataGridViewTextBoxColumn Id;
+ }
+}
\ No newline at end of file
diff --git a/NevaevaLibrary/AccountsView/FormRoles.cs b/NevaevaLibrary/AccountsView/FormRoles.cs
new file mode 100644
index 0000000..7b71f4c
--- /dev/null
+++ b/NevaevaLibrary/AccountsView/FormRoles.cs
@@ -0,0 +1,105 @@
+using AccountContracts.BindingModels;
+using AccountContracts.BusinessLogicsContracts;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace AccountsView
+{
+ public partial class FormRoles : Form
+ {
+
+ private readonly IRoleLogic _logic;
+ private bool loading = false;
+
+ public FormRoles(IRoleLogic logic)
+ {
+ InitializeComponent();
+ _logic = logic;
+ }
+
+ private void FormRoles_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ loading = true;
+ try
+ {
+ var list = _logic.ReadList();
+ if (list != null)
+ {
+ foreach (var role in list)
+ {
+ int rowIndex = dataGridView.Rows.Add();
+ dataGridView.Rows[rowIndex].Cells[0].Value = role.RoleName;
+ dataGridView.Rows[rowIndex].Cells[1].Value = role.Id;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ finally
+ {
+ loading = false;
+ }
+ }
+
+ private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
+ {
+ if (loading || e.RowIndex < 0 || e.ColumnIndex != 0) return;
+ if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null && !string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString()))
+ {
+ var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
+ if (name is null) return;
+ _logic.Update(new RoleBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), RoleName = name.ToString() });
+ }
+ else
+ {
+ var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
+ if (name is null) return;
+ _logic.Create(new RoleBindingModel { Id = 0, RoleName = name.ToString() });
+ int newRoleId = _logic.ReadList().ToList().Last().Id;
+ dataGridView.Rows[e.RowIndex].Cells[1].Value = newRoleId;
+ }
+ }
+
+ private void dataGridView_KeyUp(object sender, KeyEventArgs e)
+ {
+ switch (e.KeyCode)
+ {
+ case Keys.Insert:
+ dataGridView.Rows.Add();
+ break;
+ }
+ }
+
+ private void deleteRows(DataGridViewSelectedRowCollection rows)
+ {
+ for (int i = 0; i < rows.Count; i++)
+ {
+ DataGridViewRow row = rows[i];
+ if (!_logic.Delete(new RoleBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) })) continue;
+ dataGridView.Rows.Remove(row);
+ }
+ }
+
+ private void dataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
+ {
+ e.Cancel = true;
+ if (dataGridView.SelectedRows == null) return;
+ if (MessageBox.Show("Удалить записи?", "Подтвердите действие", MessageBoxButtons.YesNo) == DialogResult.No) return;
+ deleteRows(dataGridView.SelectedRows);
+ }
+ }
+}
diff --git a/NevaevaLibrary/AccountsView/FormRoles.resx b/NevaevaLibrary/AccountsView/FormRoles.resx
new file mode 100644
index 0000000..c68f54e
--- /dev/null
+++ b/NevaevaLibrary/AccountsView/FormRoles.resx
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ True
+
+
+ True
+
+
\ No newline at end of file
diff --git a/NevaevaLibrary/AccountsView/Program.cs b/NevaevaLibrary/AccountsView/Program.cs
new file mode 100644
index 0000000..7a58b17
--- /dev/null
+++ b/NevaevaLibrary/AccountsView/Program.cs
@@ -0,0 +1,41 @@
+using AccountBusinessLogic.BusinessLogic;
+using AccountContracts.BusinessLogicsContracts;
+using AccountContracts.StoragesContracts;
+using AccountDatabaseImplement.Implements;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace AccountsView
+{
+ internal static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+ [STAThread]
+
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ ApplicationConfiguration.Initialize();
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+ Application.Run(_serviceProvider.GetRequiredService());
+ }
+
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/NevaevaLibrary/NevaevaLibrary.sln b/NevaevaLibrary/NevaevaLibrary.sln
index f2c2405..23f8c45 100644
--- a/NevaevaLibrary/NevaevaLibrary.sln
+++ b/NevaevaLibrary/NevaevaLibrary.sln
@@ -5,7 +5,17 @@ VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NevaevaLibrary", "NevaevaLibrary\NevaevaLibrary.csproj", "{E7CA58DB-9F0F-4380-96F7-EAFDA623CE84}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp", "TestApp\TestApp.csproj", "{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountsView", "AccountsView\AccountsView.csproj", "{B7A72992-283B-4364-864E-337DDD9B0E83}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountsDataModels", "AccountsDataModels\AccountsDataModels.csproj", "{EDF1F276-5D94-41A9-B002-20C9A27BD1BA}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountContracts", "AccountContracts\AccountContracts.csproj", "{0ADBF5BC-502F-43D2-B343-3F11D0AC4069}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountBusinessLogic", "AccountBusinessLogic\AccountBusinessLogic.csproj", "{4EB11E48-32B2-4300-A134-BEC339991D95}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountDatabaseImplement", "AccountDatabaseImplement\AccountDatabaseImplement.csproj", "{E25D2269-2C4C-4176-B5E0-9D44B084306D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,6 +31,26 @@ Global
{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38BE5966-BF1C-4D26-AC7A-74EDDD25A6B3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B7A72992-283B-4364-864E-337DDD9B0E83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B7A72992-283B-4364-864E-337DDD9B0E83}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B7A72992-283B-4364-864E-337DDD9B0E83}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B7A72992-283B-4364-864E-337DDD9B0E83}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EDF1F276-5D94-41A9-B002-20C9A27BD1BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EDF1F276-5D94-41A9-B002-20C9A27BD1BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EDF1F276-5D94-41A9-B002-20C9A27BD1BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EDF1F276-5D94-41A9-B002-20C9A27BD1BA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0ADBF5BC-502F-43D2-B343-3F11D0AC4069}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0ADBF5BC-502F-43D2-B343-3F11D0AC4069}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0ADBF5BC-502F-43D2-B343-3F11D0AC4069}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0ADBF5BC-502F-43D2-B343-3F11D0AC4069}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4EB11E48-32B2-4300-A134-BEC339991D95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4EB11E48-32B2-4300-A134-BEC339991D95}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4EB11E48-32B2-4300-A134-BEC339991D95}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4EB11E48-32B2-4300-A134-BEC339991D95}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E25D2269-2C4C-4176-B5E0-9D44B084306D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E25D2269-2C4C-4176-B5E0-9D44B084306D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E25D2269-2C4C-4176-B5E0-9D44B084306D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E25D2269-2C4C-4176-B5E0-9D44B084306D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordTableComponent.cs b/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordTableComponent.cs
index f377942..a464c5d 100644
--- a/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordTableComponent.cs
+++ b/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordTableComponent.cs
@@ -82,7 +82,7 @@ namespace NevaevaLibrary.LogicalComponents
int rangeIndex = 0;
//number of cell
int headerIndex = 0;
- List cellFields = new List();
+ List cellProperties = new List();
var type = typeof(T);
for (int i = 0; i < widths.Count; i++)
{
@@ -101,15 +101,15 @@ namespace NevaevaLibrary.LogicalComponents
{
//work with cell
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
- var field = type.GetField(headers[headerIndex].Item1);
- if (field == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
+ var property = type.GetProperty(headers[headerIndex].Item1);
+ if (property == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
//format header
var cell = table.Cell(2, i + 1);
cell.Range.Text = headers[headerIndex].Item2;
cell.Width = widths[i];
cell.Range.Font.Size = 11;
- cellFields.Add(field);
+ cellProperties.Add(property);
headerIndex++;
}
i--;
@@ -119,8 +119,8 @@ namespace NevaevaLibrary.LogicalComponents
{
//work with cell
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
- var field = type.GetField(headers[headerIndex].Item1);
- if (field == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
+ var property = type.GetProperty(headers[headerIndex].Item1);
+ if (property == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
//format header
var cell = table.Cell(1, i + 1);
@@ -129,7 +129,7 @@ namespace NevaevaLibrary.LogicalComponents
cell.Width = widths[i];
cell.Range.Font.Size = 11;
- cellFields.Add(field);
+ cellProperties.Add(property);
headerIndex++;
}
}
@@ -145,10 +145,10 @@ namespace NevaevaLibrary.LogicalComponents
foreach (T item in items)
{
int columnNum = 1;
- foreach (var cellField in cellFields)
+ foreach (var cellProperty in cellProperties)
{
var cell = table.Cell(rowNum, columnNum);
- cell.Range.Text = cellField.GetValue(item)?.ToString();
+ cell.Range.Text = cellProperty.GetValue(item)?.ToString();
cell.Width = widths[columnNum - 1];
cell.Range.Bold = 0;
cell.Range.Font.Size = 11;
diff --git a/NevaevaLibrary/NevaevaLibrary/NevaevaLibrary.csproj b/NevaevaLibrary/NevaevaLibrary/NevaevaLibrary.csproj
index a414bcc..c83d7ec 100644
--- a/NevaevaLibrary/NevaevaLibrary/NevaevaLibrary.csproj
+++ b/NevaevaLibrary/NevaevaLibrary/NevaevaLibrary.csproj
@@ -6,6 +6,7 @@
true
enable
True
+ $(VersionPrefix)