Total dead
This commit is contained in:
parent
f931b8c14e
commit
ffc2c88104
@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopContracts",
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElectronicsShopBusinessLogic", "ElectronicsShopBusinessLogic\ElectronicsShopBusinessLogic.csproj", "{0CCDB712-EE03-4050-AC4B-4315FF14ABD2}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElectronicsShopBusinessLogic", "ElectronicsShopBusinessLogic\ElectronicsShopBusinessLogic.csproj", "{0CCDB712-EE03-4050-AC4B-4315FF14ABD2}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElectronicsShopDataBaseImplement", "ElectronicsShopDataBaseImplement\ElectronicsShopDataBaseImplement.csproj", "{03442D38-4C09-49D1-85F3-F8F563072F9B}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -27,6 +29,10 @@ Global
|
|||||||
{0CCDB712-EE03-4050-AC4B-4315FF14ABD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0CCDB712-EE03-4050-AC4B-4315FF14ABD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{0CCDB712-EE03-4050-AC4B-4315FF14ABD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0CCDB712-EE03-4050-AC4B-4315FF14ABD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{0CCDB712-EE03-4050-AC4B-4315FF14ABD2}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0CCDB712-EE03-4050-AC4B-4315FF14ABD2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{03442D38-4C09-49D1-85F3-F8F563072F9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{03442D38-4C09-49D1-85F3-F8F563072F9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{03442D38-4C09-49D1-85F3-F8F563072F9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{03442D38-4C09-49D1-85F3-F8F563072F9B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ElectronicsShopBusinessLogic.BusinessLogic
|
namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||||
{
|
{
|
||||||
public class ClientLogic : IClientLogic
|
public class ClientLogic : IUserLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
//private readonly IClientStorage _storage;
|
//private readonly IClientStorage _storage;
|
||||||
@ -24,7 +24,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
//storage = _storage;
|
//storage = _storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Add(ClientBindingModel model)
|
public bool Add(UserBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
// todo логика добавления в _clientStorage:_clientStorage.Insert(model) == null
|
// todo логика добавления в _clientStorage:_clientStorage.Insert(model) == null
|
||||||
@ -35,7 +35,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(ClientBindingModel model)
|
public bool Update(UserBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
// todo логика добавления в _clientStorage:_clientStorage.Update(model) == null
|
// todo логика добавления в _clientStorage:_clientStorage.Update(model) == null
|
||||||
@ -47,7 +47,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete(ClientBindingModel model)
|
public bool Delete(UserBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation($"Delete.ID:{model.UserID}");
|
_logger.LogInformation($"Delete.ID:{model.UserID}");
|
||||||
@ -60,7 +60,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? ReadElemet(ClientSearchModel? model)
|
public UserViewModel? ReadElemet(UserSearchModel? model)
|
||||||
{
|
{
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
@ -77,7 +77,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
public List<UserViewModel>? ReadList(UserSearchModel? model)
|
||||||
{
|
{
|
||||||
|
|
||||||
_logger.LogInformation($"ReadList: ClientID:{model?.UserID}");
|
_logger.LogInformation($"ReadList: ClientID:{model?.UserID}");
|
||||||
@ -93,7 +93,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckModel(ClientBindingModel model, bool withParams = true) {
|
private void CheckModel(UserBindingModel model, bool withParams = true) {
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
using ElectronicsShopDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ElectronicsShopContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class ShopAssistentBindingModel : IShopAssistentModel
|
|
||||||
{
|
|
||||||
//ID пользователя
|
|
||||||
public int UserID { get; set; }
|
|
||||||
//ID роли (сотрудник)
|
|
||||||
public int RoleID { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public string FirstName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string LastName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Login { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Email { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Password { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string PhoneNumber { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,5 @@
|
|||||||
using ElectronicsShopDataModels.Models;
|
using ElectronicsShopDataModels;
|
||||||
|
using ElectronicsShopDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -7,10 +8,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ElectronicsShopContracts.BindingModels
|
namespace ElectronicsShopContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class ClientBindingModel : IClientModel
|
public class UserBindingModel : IUserModel
|
||||||
{
|
{
|
||||||
//ID пользователя
|
//ID пользователя
|
||||||
public int UserID { get; set; }
|
public int ID { get; set; }
|
||||||
//ID роли (клиент)
|
//ID роли (клиент)
|
||||||
public int RoleID { get; set; }
|
public int RoleID { get; set; }
|
||||||
|
|
@ -9,13 +9,13 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ElectronicsShopContracts.BusinessLogicContracts
|
namespace ElectronicsShopContracts.BusinessLogicContracts
|
||||||
{
|
{
|
||||||
public interface IClientLogic
|
public interface IUserLogic
|
||||||
{
|
{
|
||||||
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
List<UserViewModel>? ReadList(UserSearchModel? model);
|
||||||
ClientViewModel? ReadElemet(ClientSearchModel? model);
|
UserViewModel? ReadElemet(UserSearchModel? model);
|
||||||
|
|
||||||
bool Add(ClientBindingModel model);
|
bool Add(UserBindingModel model);
|
||||||
bool Update(ClientBindingModel model);
|
bool Update(UserBindingModel model);
|
||||||
bool Delete(ClientBindingModel model);
|
bool Delete(UserBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,21 +0,0 @@
|
|||||||
using ElectronicsShopContracts.BindingModels;
|
|
||||||
using ElectronicsShopContracts.SearchModels;
|
|
||||||
using ElectronicsShopContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ElectronicsShopContracts.BusinessLogicContracts
|
|
||||||
{
|
|
||||||
public interface ShopAssistentLogic
|
|
||||||
{
|
|
||||||
List<ShopAssistentViewModel>? ReadList(ShopAssistentSearchModel? model);
|
|
||||||
ShopAssistentViewModel? ReadElement(ShopAssistentSearchModel? model);
|
|
||||||
|
|
||||||
bool Add(ShopAssistentBindingModel model);
|
|
||||||
bool Update(ShopAssistentBindingModel model);
|
|
||||||
bool Delete(ShopAssistentBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ElectronicsShopContracts.SearchModels
|
|
||||||
{
|
|
||||||
public class ShopAssistentSearchModel
|
|
||||||
{
|
|
||||||
public int? UserID { get; set; }
|
|
||||||
public string? Login { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,9 +6,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ElectronicsShopContracts.SearchModels
|
namespace ElectronicsShopContracts.SearchModels
|
||||||
{
|
{
|
||||||
public class ClientSearchModel
|
public class UserSearchModel
|
||||||
{
|
{
|
||||||
public int? UserID { get; set; }
|
public int? ID { get; set; }
|
||||||
public string? Login { get; set; }
|
public string? Login { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,10 +12,10 @@ namespace ElectronicsShopContracts.StorageContracts
|
|||||||
public interface ICategoryProductStorage
|
public interface ICategoryProductStorage
|
||||||
{
|
{
|
||||||
List<CategoryProductViewModel> GetFullList();
|
List<CategoryProductViewModel> GetFullList();
|
||||||
List<CategoryProductViewModel> GetFilteredList(ClientSearchModel model);
|
List<CategoryProductViewModel> GetFilteredList(CategoryProductSearchModel model);
|
||||||
CategoryProductViewModel? GetElement(ClientSearchModel model);
|
CategoryProductViewModel? GetElement(CategoryProductSearchModel model);
|
||||||
CategoryProductViewModel? Insert(ClientBindingModel model);
|
CategoryProductViewModel? Insert(CategoryProductBindingModel model);
|
||||||
CategoryProductViewModel? Update(ClientBindingModel model);
|
CategoryProductViewModel? Update(CategoryProductBindingModel model);
|
||||||
CategoryProductViewModel? Delete(ClientBindingModel model);
|
CategoryProductViewModel? Delete(CategoryProductBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
using ElectronicsShopContracts.BindingModels;
|
|
||||||
using ElectronicsShopContracts.SearchModels;
|
|
||||||
using ElectronicsShopContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ElectronicsShopContracts.StorageContracts
|
|
||||||
{
|
|
||||||
public interface IClientStorage
|
|
||||||
{
|
|
||||||
List<ClientViewModel> GetFullList();
|
|
||||||
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
|
||||||
ClientViewModel? GetElement(ClientSearchModel model);
|
|
||||||
ClientViewModel? Insert(ClientBindingModel model);
|
|
||||||
ClientViewModel? Update(ClientBindingModel model);
|
|
||||||
ClientViewModel? Delete(ClientBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,10 +12,10 @@ namespace ElectronicsShopContracts.StorageContracts
|
|||||||
public interface IOrderStorage
|
public interface IOrderStorage
|
||||||
{
|
{
|
||||||
List<OrderViewModel> GetFullList();
|
List<OrderViewModel> GetFullList();
|
||||||
List<OrderViewModel> GetFilteredList(ClientSearchModel model);
|
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||||
OrderViewModel? GetElement(ClientSearchModel model);
|
OrderViewModel? GetElement(OrderSearchModel model);
|
||||||
OrderViewModel? Insert(ClientBindingModel model);
|
OrderViewModel? Insert(OrderBindingModel model);
|
||||||
OrderViewModel? Update(ClientBindingModel model);
|
OrderViewModel? Update(OrderBindingModel model);
|
||||||
OrderViewModel? Delete(ClientBindingModel model);
|
OrderViewModel? Delete(OrderBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,10 @@ namespace ElectronicsShopContracts.StorageContracts
|
|||||||
public interface IProductStorage
|
public interface IProductStorage
|
||||||
{
|
{
|
||||||
List<ProductViewModel> GetFullList();
|
List<ProductViewModel> GetFullList();
|
||||||
List<ProductViewModel> GetFilteredList(ClientSearchModel model);
|
List<ProductViewModel> GetFilteredList(OrderSearchModel model);
|
||||||
ProductViewModel? GetElement(ClientSearchModel model);
|
ProductViewModel? GetElement(OrderSearchModel model);
|
||||||
ProductViewModel? Insert(ClientBindingModel model);
|
ProductViewModel? Insert(OrderBindingModel model);
|
||||||
ProductViewModel? Update(ClientBindingModel model);
|
ProductViewModel? Update(OrderBindingModel model);
|
||||||
ProductViewModel? Delete(ClientBindingModel model);
|
ProductViewModel? Delete(OrderBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,10 @@ namespace ElectronicsShopContracts.StorageContracts
|
|||||||
public interface IRoleStorage
|
public interface IRoleStorage
|
||||||
{
|
{
|
||||||
List<RoleViewModel> GetFullList();
|
List<RoleViewModel> GetFullList();
|
||||||
List<RoleViewModel> GetFilteredList(ClientSearchModel model);
|
List<RoleViewModel> GetFilteredList(RoleSearchModel model);
|
||||||
RoleViewModel? GetElement(ClientSearchModel model);
|
RoleViewModel? GetElement(RoleSearchModel model);
|
||||||
RoleViewModel? Insert(ClientBindingModel model);
|
RoleViewModel? Insert(RoleBindingModel model);
|
||||||
RoleViewModel? Update(ClientBindingModel model);
|
RoleViewModel? Update(RoleBindingModel model);
|
||||||
RoleViewModel? Delete(ClientBindingModel model);
|
RoleViewModel? Delete(RoleBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
using ElectronicsShopContracts.BindingModels;
|
|
||||||
using ElectronicsShopContracts.SearchModels;
|
|
||||||
using ElectronicsShopContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ElectronicsShopContracts.StorageContracts
|
|
||||||
{
|
|
||||||
public interface IShopAssistentStorage
|
|
||||||
{
|
|
||||||
List<ShopAssistentViewModel> GetFullList();
|
|
||||||
List<ShopAssistentViewModel> GetFilteredList(ClientSearchModel model);
|
|
||||||
ShopAssistentViewModel? GetElement(ClientSearchModel model);
|
|
||||||
ShopAssistentViewModel? Insert(ClientBindingModel model);
|
|
||||||
ShopAssistentViewModel? Update(ClientBindingModel model);
|
|
||||||
ShopAssistentViewModel? Delete(ClientBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,21 @@
|
|||||||
|
using ElectronicsShopContracts.BindingModels;
|
||||||
|
using ElectronicsShopContracts.SearchModels;
|
||||||
|
using ElectronicsShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ElectronicsShopContracts.StorageContracts
|
||||||
|
{
|
||||||
|
public interface IUserStorage
|
||||||
|
{
|
||||||
|
List<UserViewModel> GetFullList();
|
||||||
|
List<UserViewModel> GetFilteredList(UserSearchModel model);
|
||||||
|
UserViewModel? GetElement(UserSearchModel model);
|
||||||
|
UserViewModel? Insert(UserBindingModel model);
|
||||||
|
UserViewModel? Update(UserBindingModel model);
|
||||||
|
UserViewModel? Delete(UserBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +0,0 @@
|
|||||||
using ElectronicsShopDataModels.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ElectronicsShopContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class ShopAssistentViewModel : IShopAssistentModel
|
|
||||||
{
|
|
||||||
//ID пользователя
|
|
||||||
public int UserID { get; set; }
|
|
||||||
//ID роли (сотрудник)
|
|
||||||
public int RoleID { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
[DisplayName("Имя")]
|
|
||||||
public string FirstName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DisplayName("Фамилия")]
|
|
||||||
public string LastName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DisplayName("Логин")]
|
|
||||||
public string Login { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DisplayName("Почта")]
|
|
||||||
public string Email { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DisplayName("Пароль")]
|
|
||||||
public string Password { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[DisplayName("Номер телефона")]
|
|
||||||
public string PhoneNumber { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,5 @@
|
|||||||
using ElectronicsShopDataModels.Models;
|
using ElectronicsShopDataModels;
|
||||||
|
using ElectronicsShopDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -8,15 +9,14 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ElectronicsShopContracts.ViewModels
|
namespace ElectronicsShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ClientViewModel : IClientModel
|
public class UserViewModel : IUserModel
|
||||||
{
|
{
|
||||||
|
|
||||||
//ID пользователя
|
//ID пользователя
|
||||||
public int UserID { get; set; }
|
public int ID { get; set; }
|
||||||
//ID роли (клиент)
|
//ID роли (клиент)
|
||||||
public int RoleID { get; set; }
|
public int RoleID { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[DisplayName("Имя")]
|
[DisplayName("Имя")]
|
||||||
public string FirstName { get; set; } = string.Empty;
|
public string FirstName { get; set; } = string.Empty;
|
||||||
|
|
27
ElectronicsShop/ElectronicsShopDataBaseImplement/DataBase.cs
Normal file
27
ElectronicsShop/ElectronicsShopDataBaseImplement/DataBase.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ElectronicsShopDataBaseImplement
|
||||||
|
{
|
||||||
|
public class DataBase
|
||||||
|
{
|
||||||
|
public class Database : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder
|
||||||
|
optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlServer(@"Data Source=.\SQLEXPRESS;Initial Catalog=ZooDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
public virtual DbSet<CategoryProduct> CategoryProducts { set; get; }
|
||||||
|
public virtual DbSet<User> Users { set; get; }
|
||||||
|
public virtual DbSet<Route> Routes { set; get; }
|
||||||
|
public virtual DbSet<RoutePreserve> RoutePreserves { set; get; }
|
||||||
|
public virtual DbSet<Preserve> Preserves { set; get; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ElectronicsShopContracts\ElectronicsShopContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,63 @@
|
|||||||
|
using ElectronicsShopContracts.BindingModels;
|
||||||
|
using ElectronicsShopContracts.SearchModels;
|
||||||
|
using ElectronicsShopContracts.StorageContracts;
|
||||||
|
using ElectronicsShopContracts.ViewModels;
|
||||||
|
using ElectronicsShopDataBaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using static ElectronicsShopDataBaseImplement.DataBase;
|
||||||
|
|
||||||
|
namespace ElectronicsShopDataBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class CategoryProductStorage : ICategoryProductStorage
|
||||||
|
{
|
||||||
|
List<CategoryProductViewModel> ICategoryProductStorage.GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
return context.CategoryProducts.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
List<CategoryProductViewModel> ICategoryProductStorage.GetFilteredList(CategoryProductSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.CategoryProducts.Where(x => x.CategoryProducts.Contains(model.Name)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
CategoryProductViewModel? ICategoryProductStorage.GetElement(CategoryProductSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Name) && !model.ID.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.CategoryProducts.FirstOrDefault(x =>
|
||||||
|
(!string.IsNullOrEmpty(model.Name) && x.Name == model.Name && (model.ID.HasValue && x.Id == model.ID)) ) ?.GetViewModel;
|
||||||
|
}
|
||||||
|
CategoryProductViewModel? ICategoryProductStorage.Insert(CategoryProductBindingModel model)
|
||||||
|
{
|
||||||
|
var newComponent = CategoryProduct.Create(model);
|
||||||
|
if (newComponent == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
context.CategoryProducts.Add(newComponent);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newComponent.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
CategoryProductViewModel? ICategoryProductStorage.Update(CategoryProductBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
CategoryProductViewModel? ICategoryProductStorage.Delete(CategoryProductBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
using ElectronicsShopContracts.BindingModels;
|
||||||
|
using ElectronicsShopContracts.ViewModels;
|
||||||
|
using ElectronicsShopDataModels;
|
||||||
|
using ElectronicsShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ElectronicsShopDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class CategoryProduct : ICategoryProductModel
|
||||||
|
{
|
||||||
|
public int ID { get; private set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; }=string.Empty;
|
||||||
|
|
||||||
|
public static CategoryProduct? Create(CategoryProductBindingModel model)
|
||||||
|
{
|
||||||
|
if(model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new CategoryProduct()
|
||||||
|
{
|
||||||
|
ID = model.ID,
|
||||||
|
Name = model.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static CategoryProduct Create(CategoryProductViewModel model)
|
||||||
|
{
|
||||||
|
return new CategoryProduct
|
||||||
|
{
|
||||||
|
ID = model.ID,
|
||||||
|
Name = model.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(CategoryProductBindingModel model)
|
||||||
|
{
|
||||||
|
if(model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
model.ID = ID;
|
||||||
|
model.Name = Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CategoryProduct GetViewModel => new()
|
||||||
|
{
|
||||||
|
ID = ID,
|
||||||
|
Name = Name
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -6,14 +6,17 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ElectronicsShopDataModels
|
namespace ElectronicsShopDataModels
|
||||||
{
|
{
|
||||||
public interface IUser
|
public interface IUserModel : IID
|
||||||
{
|
{
|
||||||
|
//ID role
|
||||||
|
int RoleID { get; }
|
||||||
|
|
||||||
|
|
||||||
string FirstName { get; }
|
string FirstName { get; }
|
||||||
string LastName { get; }
|
string LastName { get; }
|
||||||
string Login { get; }
|
|
||||||
string Email { get; }
|
|
||||||
string Password { get; }
|
string Password { get; }
|
||||||
string PhoneNumber { get; }
|
string PhoneNumber { get; }
|
||||||
int RoleID { get; }
|
string Login { get; }
|
||||||
|
string Email { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ElectronicsShopDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IClientModel : IUser
|
|
||||||
{
|
|
||||||
int UserID { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ElectronicsShopDataModels.Models
|
|
||||||
{
|
|
||||||
public interface IShopAssistentModel : IUser
|
|
||||||
{
|
|
||||||
int UserID { get; }
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user