Compare commits

...

30 Commits

Author SHA1 Message Date
Илья Федотов
b9aa29ae27 mini fix 2024-04-29 23:23:26 +04:00
Илья Федотов
f9c768037d is done 2024-04-29 23:20:48 +04:00
Илья Федотов
8551235414 Базовые настройки 2024-04-29 22:10:50 +04:00
Илья Федотов
4eedfb402a Контроллеры 2024-04-29 21:57:01 +04:00
13f9cd4920 RestApi Create 2024-04-29 21:38:18 +04:00
Илья Федотов
ccb78dd53d Merge branch 'ReportLogic' of https://git.is.ulstu.ru/Ilfedotov.01/CourseWorkElectronicsShop into ReportLogic 2024-04-29 19:35:41 +04:00
Илья Федотов
0975a9b4d6 Report logis запрос нв получение данных из бд 2024-04-29 19:35:19 +04:00
4a958769f0 Mb not done 2024-04-29 19:34:14 +04:00
Илья Федотов
d07ef5499f Report logis запрос нв получение данных из бд 2024-04-29 19:33:15 +04:00
Илья Федотов
d934652b6c data base fix 2024-04-29 18:34:49 +04:00
Илья Федотов
11ea6cc0c0 Merge branch 'DataBaseImplement_02' of https://git.is.ulstu.ru/Ilfedotov.01/CourseWorkElectronicsShop into DataBaseImplement_02 2024-04-29 18:01:28 +04:00
858d42295b Trabls 2024-04-29 18:00:54 +04:00
99b0e691c4 Last fix ProductList 2024-04-29 18:00:54 +04:00
a8beee0d2c Trabls 2024-04-29 17:59:45 +04:00
45205630a5 Last fix ProductList 2024-04-29 01:55:20 +04:00
Илья Федотов
134f7d6cef Business logic 0.2 2024-04-29 01:28:41 +04:00
Илья Федотов
02d78da38f fixed 0.5 2024-04-29 00:44:49 +04:00
Илья Федотов
15f995b6ce fixed 0.4 категории воскресли! 2024-04-28 23:53:21 +04:00
Илья Федотов
f899455329 fixed 0.3 :/ 2024-04-28 23:36:49 +04:00
Илья Федотов
3cba2df163 fixed 0.2 :c 2024-04-28 23:33:49 +04:00
Илья Федотов
64532a3804 fixed :) 2024-04-28 23:24:54 +04:00
Илья Федотов
8770645a82 Total dead 2024-04-28 23:09:52 +04:00
ffc2c88104 Total dead 2024-04-28 23:08:09 +04:00
Илья Федотов
f931b8c14e Merge branch 'BusinessLogic' of https://git.is.ulstu.ru/Ilfedotov.01/CourseWorkElectronicsShop into BusinessLogic 2024-04-28 21:25:57 +04:00
Илья Федотов
47d59c7bfb Business logic добавить хранилище, убрать затычки! 0.1 2024-04-28 21:23:43 +04:00
Илья Федотов
4b0183ae91 Business logic добавить хранилище, убрать затычки! 0.1 2024-04-28 21:20:10 +04:00
6a7395b3b5 Storage add 2024-04-28 20:59:10 +04:00
Илья Федотов
9c049cd819 Contracts исправил модели! 0.2 2024-04-28 20:14:44 +04:00
Илья Федотов
2587d43871 Contracts 0.1 2024-04-27 13:01:57 +04:00
Илья Федотов
3b361e18fc Data models 0.1 2024-04-27 12:58:16 +04:00
147 changed files with 77301 additions and 0 deletions

View File

@ -3,7 +3,49 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopDataModels", "ElectronicsShopDataModels\ElectronicsShopDataModels.csproj", "{380E3833-D9AE-46C7-8881-9B15B8559411}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopContracts", "ElectronicsShopContracts\ElectronicsShopContracts.csproj", "{69411E41-F304-4D1B-8F15-48DD08585C7A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopBusinessLogic", "ElectronicsShopBusinessLogic\ElectronicsShopBusinessLogic.csproj", "{0CCDB712-EE03-4050-AC4B-4315FF14ABD2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopDataBaseImplement", "ElectronicsShopDataBaseImplement\ElectronicsShopDataBaseImplement.csproj", "{03442D38-4C09-49D1-85F3-F8F563072F9B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopRestAPI", "ElectronicsShopResrAPI\ElectronicsShopRestAPI.csproj", "{BDEC8526-DB9D-49F3-93B5-8777339CC040}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElectronicsShopUserApp", "ElectronicsShopUserApp\ElectronicsShopUserApp.csproj", "{64A3B370-6FAB-4A28-B5CE-397DBE8653AB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{380E3833-D9AE-46C7-8881-9B15B8559411}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{380E3833-D9AE-46C7-8881-9B15B8559411}.Debug|Any CPU.Build.0 = Debug|Any CPU
{380E3833-D9AE-46C7-8881-9B15B8559411}.Release|Any CPU.ActiveCfg = Release|Any CPU
{380E3833-D9AE-46C7-8881-9B15B8559411}.Release|Any CPU.Build.0 = Release|Any CPU
{69411E41-F304-4D1B-8F15-48DD08585C7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69411E41-F304-4D1B-8F15-48DD08585C7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69411E41-F304-4D1B-8F15-48DD08585C7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69411E41-F304-4D1B-8F15-48DD08585C7A}.Release|Any CPU.Build.0 = Release|Any CPU
{0CCDB712-EE03-4050-AC4B-4315FF14ABD2}.Debug|Any CPU.ActiveCfg = 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.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
{BDEC8526-DB9D-49F3-93B5-8777339CC040}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDEC8526-DB9D-49F3-93B5-8777339CC040}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDEC8526-DB9D-49F3-93B5-8777339CC040}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDEC8526-DB9D-49F3-93B5-8777339CC040}.Release|Any CPU.Build.0 = Release|Any CPU
{64A3B370-6FAB-4A28-B5CE-397DBE8653AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64A3B370-6FAB-4A28-B5CE-397DBE8653AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64A3B370-6FAB-4A28-B5CE-397DBE8653AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64A3B370-6FAB-4A28-B5CE-397DBE8653AB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection

View File

@ -0,0 +1,89 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.StorageContracts;
using ElectronicsShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopBusinessLogic.BusinessLogic
{
public class CategoryProductLogic : ICategoryProductLogic
{
private readonly ILogger _logger;
private readonly ICategoryProductStorage _storage;
public CategoryProductLogic(ILogger<CategoryProductLogic> logger, ICategoryProductStorage storage) {
_logger = logger;
_storage = storage;
}
public bool Create(CategoryProductBindingModel model)
{
CheckModel(model);
if (_storage.Insert(model) == null) {
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(CategoryProductBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation($"Delete. ID:{model.ID}");
if (_storage.Insert(model) == null) {
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public bool Update(CategoryProductBindingModel model)
{
CheckModel(model);
if (_storage.Insert(model) == null) {
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public List<CategoryProductViewModel>? ReadList(CategoryProductSearchModel? model)
{
_logger.LogInformation($"ReadList. ID:{model?.ID}");
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
if (list == null) {
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation($"ReadList. Count:{list.Count}");
return list;
}
private void CheckModel(CategoryProductBindingModel model, bool withParams = true) {
if (model == null) {
throw new ArgumentNullException(nameof(model));
}
if (!withParams) {
return;
}
if (string.IsNullOrEmpty(model.Name)) {
throw new ArgumentNullException("Нет названия категории продукта", nameof(model.Name));
}
_logger.LogInformation($"CategoryProduct. ID:{model.ID}.Name:{model.Name}");
var element = _storage.GetElement(new CategoryProductSearchModel
{
Name = model.Name
});
if (element != null && element.ID != model.ID) {
throw new InvalidOperationException("Категория с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,104 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.StorageContracts;
using ElectronicsShopContracts.ViewModels;
using ElectronicsShopDataModels.Enums;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopBusinessLogic.BusinessLogic
{
public class OrderLogic : IOrderLogic
{
private readonly ILogger _logger;
private readonly IOrderStorage _storage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage storage) {
_logger = logger;
_storage = storage;
}
public bool CreateOrder(OrderBindingModel model)
{
CheckModel(model);
model.Status = OrderStatus.Принят;
if (_storage.Insert(model) == null) {
_logger.LogInformation("Insert operation failed");
return false;
}
return true;
}
public bool DeliveryOrder(OrderBindingModel model)
{
return StatusUpdate(model, OrderStatus.Выдан);
}
public bool FinishOrder(OrderBindingModel model)
{
return StatusUpdate(model, OrderStatus.Готов);
}
public bool TakeOrderInWork(OrderBindingModel model)
{
return StatusUpdate(model, OrderStatus.Выполняется);
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{
_logger.LogInformation($"ReadList:ID:{model?.ID}");
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model); ;
if (list == null) {
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation($"ReadList.Count:{list.Count}");
return list;
}
private void CheckModel(OrderBindingModel model, bool withParams = true) {
if (model == null) {
throw new ArgumentNullException(nameof(model));
}
if (!withParams) {
return;
}
if (string.IsNullOrEmpty((model.ID).ToString())) {
throw new ArgumentNullException("Нет ID заказа", nameof(model.ID));
}
if (model.Sum <= 0) {
throw new ArgumentNullException("Цена зака должна быть больше 0", nameof(model.Sum));
}
_logger.LogInformation($"Order. ID:{model.ID}.Sum:{model.Sum}.Status:{model.Status}.PaymeantOption:{model.PaymeantOption}." +
$"DateCreate:{model.DateCreate}.DataImplement:{model.DateImplement}");
}
private bool StatusUpdate(OrderBindingModel model, OrderStatus newOrderStatus)
{
CheckModel(model, false);
var viewModel = _storage.GetElement(new OrderSearchModel { ID = model.ID });
if (viewModel == null) {
throw new ArgumentNullException(nameof(model));
}
if (viewModel.Status + 1 != newOrderStatus) {
_logger.LogWarning("Status update to " + newOrderStatus.ToString() + " operation failed.");
return false;
}
model.Status = newOrderStatus;
if (model.Status == OrderStatus.Готов) {
model.DateImplement = DateTime.Now;
}
else {
model.DateImplement = viewModel.DateImplement;
}
if (_storage.Update(model) == null) {
_logger.LogWarning("Update operarion failed");
return false;
}
return true;
}
}
}

View File

@ -0,0 +1,99 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.StorageContracts;
using ElectronicsShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopBusinessLogic.BusinessLogic
{
public class ProductLogic : IProductLogic
{
private readonly ILogger _logger;
private readonly IProductStorage _storage;
public ProductLogic(ILogger<ProductLogic> logger, IProductStorage productStorage) {
_logger = logger;
_storage = productStorage;
}
public bool Create(ProductBindingModel model)
{
CheckModel(model);
if (_storage.Insert(model) == null) {
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(ProductBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation($"Delete. ID:{model.ID}");
if (_storage.Delete(model) == null) {
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public bool Update(ProductBindingModel model)
{
CheckModel(model);
if (_storage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public ProductViewModel? ReadElement(ProductSearchModel? model)
{
if (model == null) throw new ArgumentNullException(nameof(model));
_logger.LogInformation($"ReadElement. ProductName:{model.ProductName}. ID:{model.ID}");
var element = _storage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement. elementn not found");
return null;
}
_logger.LogInformation($"ReadElement find. ID:{element.ID}");
return element;
}
public List<ProductViewModel>? ReadList(ProductSearchModel? model)
{
_logger.LogInformation($"ReadList. ProductName:{model?.ProductName}. ID:{model?.ID}");
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation($"ReadList. Count:{list.Count}");
return list;
}
private void CheckModel(ProductBindingModel model, bool withParams = true)
{
if (model == null) throw new ArgumentNullException(nameof(model));
if (!withParams) return;
if (string.IsNullOrEmpty(model.ProductName))
throw new ArgumentNullException("Нет названия продукта", nameof(model.ProductName));
if (model.Price <= 0)
throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.Price));
_logger.LogInformation($"Product. ID:{model.ID}.ProductName:{model.ProductName}.Price:{model.Price}.Count:{model.Count}" +
$".CategoryID:{model.CategoryID}");
var element = _storage.GetElement(new ProductSearchModel { ProductName = model.ProductName });
if (element != null && element.ID != model.ID)
throw new InvalidOperationException("Продукт с таким названием уже есть");
}
}
}

View File

@ -0,0 +1,42 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.StorageContracts;
using ElectronicsShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopBusinessLogic.BusinessLogic
{
public class ReportLogic : IReportLogic
{
private readonly IOrderStorage _orderStorage;
private readonly IProductStorage _productStorag;
public ReportLogic(IOrderStorage orderStorage, IProductStorage productStorag) {
_orderStorage = orderStorage;
_productStorag = productStorag;
}
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model) {
throw new NotImplementedException();
}
// Получение списка заказов за определенный период
public List<ReportOrdersViewModel> GerOrders(ReportBindingModel model) {
return _orderStorage.GetFilteredList(new OrderSearchModel {
DateFrom = model.DateFrom,
DateTo = model.DateTo,
}).Select(x => new ReportOrdersViewModel {
ID = x.ID,
DateCreate = x.DateCreate,
Sum = x.Sum,
PaymeantOption = x.PaymeantOption.ToString(),
OrderStatus = x.Status.ToString(),
}).ToList();
}
}
}

View File

@ -0,0 +1,99 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.StorageContracts;
using ElectronicsShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopBusinessLogic.BusinessLogic
{
public class RoleLogic : IRoleLogic
{
private readonly ILogger _logger;
private readonly IRoleStorage _storage;
public RoleLogic(ILogger<RoleLogic> logger, IRoleStorage storage)
{
_logger = logger;
_storage = storage;
}
public bool Create(RoleBindingModel model)
{
CheckModel(model);
if (_storage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Delete(RoleBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation($"Delete. ID:{model.ID}");
if (_storage.Insert(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public bool Update(RoleBindingModel model)
{
CheckModel(model);
if (_storage.Insert(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public List<RoleViewModel>? ReadList(RoleSearchModel? model)
{
_logger.LogInformation($"ReadList. ID:{model?.ID}");
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation($"ReadList. Count:{list.Count}");
return list;
}
private void CheckModel(RoleBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия категории продукта", nameof(model.Name));
}
_logger.LogInformation($"CategoryProduct. ID:{model.ID}.Name:{model.Name}");
var element = _storage.GetElement(new RoleSearchModel
{
Name = model.Name
});
if (element != null && element.ID != model.ID)
{
throw new InvalidOperationException("Такая роль уже есть");
}
}
}
}

View File

@ -0,0 +1,142 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.StorageContracts;
using ElectronicsShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopBusinessLogic.BusinessLogic
{
internal class UserLogic : IUserLogic
{
private readonly ILogger _logger;
private readonly IUserStorage _storage;
// todo нет интерфейса хранилища
public UserLogic(ILogger<UserLogic> logger, IUserStorage storage)
{
_logger = logger;
_storage = storage;
}
public bool Add(UserBindingModel model)
{
CheckModel(model);
if (_storage.Insert(model) == null)
{
_logger.LogWarning("Add operation failed");
return false;
}
return true;
}
public bool Update(UserBindingModel model)
{
CheckModel(model);
if (_storage.Insert(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(UserBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation($"Delete.ID:{model.ID}");
if (_storage.Insert(model) == null)
{
_logger.LogWarning("Delete operation failes");
return false;
}
return true;
}
public UserViewModel? ReadElemet(UserSearchModel? model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation($"ReadElement: logint:{model.Login}.ID:{model.ID}");
var element = _storage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not fount");
return null;
}
_logger.LogInformation($"ReadElement: find.ID:{element.ID}");
return element;
}
public List<UserViewModel>? ReadList(UserSearchModel? model)
{
_logger.LogInformation($"ReadList: ClientID:{model?.ID}");
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model); ;
if (list == null)
{
_logger.LogWarning("ReadList: return null list");
return null;
}
_logger.LogInformation($"ReadList:Count:{list.Count}");
return list;
}
private void CheckModel(UserBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Login))
{
throw new ArgumentNullException("Нет логина пользователя", nameof(model.Login));
}
if (string.IsNullOrEmpty(model.FirstName))
{
throw new ArgumentNullException("Нет имени пользователя", nameof(model.FirstName));
}
if (string.IsNullOrEmpty(model.LastName))
{
throw new ArgumentNullException("Нет фамилии пользоватея", nameof(model.LastName));
}
if (string.IsNullOrEmpty(model.Email))
{
throw new ArgumentNullException("Нет почты клиента", nameof(model.Email));
}
if (string.IsNullOrEmpty(model.Password))
{
throw new ArgumentNullException("Нет пароля пользователя", nameof(model.Password));
}
if (string.IsNullOrEmpty(model.PhoneNumber))
{
throw new ArgumentNullException("Нет номер телефона пользователя", nameof(model.PhoneNumber));
}
_logger.LogInformation($"Client. ID:{model.ID}.RoleID:{model.RoleID}.FirstName:{model.FirstName}." +
$"LastName:{model.LastName}.Password:{model.Password}.PhoneNumber:{model.PhoneNumber}.Login:{model.Login}." +
$"Email:{model.Email}");
var element = _storage.GetElement(new UserSearchModel
{
Login = model.Login
});
if (element != null && element.ID != model.ID)
{
throw new InvalidOperationException("Клиент с таким логином уже есть");
}
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ElectronicsShopContracts\ElectronicsShopContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,16 @@
using ElectronicsShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.BindingModels
{
public class CategoryProductBindingModel : ICategoryProductModel
{
public int ID { get; set; }
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,29 @@
using ElectronicsShopDataModels.Enums;
using ElectronicsShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.BindingModels
{
public class OrderBindingModel : IOrderModel
{
public int ID { get; set; }
public int UserID { get; set; }
public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public PaymeantOption PaymeantOption { get; set; } = PaymeantOption.Неизвестно;
public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; }
public Dictionary<int, (IProductModel, int)> ProductList { get; set; } = new();
}
}

View File

@ -0,0 +1,22 @@
using ElectronicsShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.BindingModels
{
public class ProductBindingModel : IProductModel
{
//ID категории продукта (товара)
public int CategoryID { get; set; }
//ID продукта (товара)
public int ID { get; set; }
public string ProductName { get; set; } = string.Empty;
public double Price { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.BindingModels
{
public class ReportBindingModel
{
public string FileName { get; set; } = string.Empty;
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using ElectronicsShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.BindingModels
{
public class RoleBindingModel : IRoleModel
{
public int ID { get; set; }
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,32 @@
using ElectronicsShopDataModels;
using ElectronicsShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.BindingModels
{
public class UserBindingModel : IUserModel
{
//ID пользователя
public int ID { 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;
}
}

View File

@ -0,0 +1,20 @@
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 ICategoryProductLogic
{
List<CategoryProductViewModel>? ReadList(CategoryProductSearchModel? model);
bool Create(CategoryProductBindingModel model);
bool Update(CategoryProductBindingModel model);
bool Delete(CategoryProductBindingModel model);
}
}

View File

@ -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.BusinessLogicContracts
{
public interface IOrderLogic
{
List<OrderViewModel>? ReadList(OrderSearchModel? model);
bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
bool DeliveryOrder(OrderBindingModel model);
}
}

View File

@ -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.BusinessLogicContracts
{
public interface IProductLogic
{
List<ProductViewModel>? ReadList(ProductSearchModel? model);
ProductViewModel? ReadElement(ProductSearchModel? model);
bool Create(ProductBindingModel model);
bool Update(ProductBindingModel model);
bool Delete(ProductBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.BusinessLogicContracts
{
public interface IReportLogic
{
// Получение списка заказов за определенный период
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
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 IRoleLogic
{
List<RoleViewModel>? ReadList(RoleSearchModel? model);
bool Create(RoleBindingModel model);
bool Update(RoleBindingModel model);
bool Delete(RoleBindingModel model);
}
}

View File

@ -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.BusinessLogicContracts
{
public interface IUserLogic
{
List<UserViewModel>? ReadList(UserSearchModel? model);
UserViewModel? ReadElemet(UserSearchModel? model);
bool Add(UserBindingModel model);
bool Update(UserBindingModel model);
bool Delete(UserBindingModel model);
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ElectronicsShopDataModels\ElectronicsShopDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.SearchModels
{
public class CategoryProductSearchModel
{
public int? ID { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using ElectronicsShopDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.SearchModels
{
public class OrderSearchModel
{
public int? ID { get; set; }
public int? UserID { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set;}
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.SearchModels
{
public class ProductSearchModel
{
public int? ID { get; set; }
public string? ProductName { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.SearchModels
{
public class RoleSearchModel
{
public int? ID { get; set; }
public string? Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.SearchModels
{
public class UserSearchModel
{
public int? ID { get; set; }
public string? Login { get; set; }
}
}

View File

@ -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 ICategoryProductStorage
{
List<CategoryProductViewModel> GetFullList();
List<CategoryProductViewModel> GetFilteredList(CategoryProductSearchModel model);
CategoryProductViewModel? GetElement(CategoryProductSearchModel model);
CategoryProductViewModel? Insert(CategoryProductBindingModel model);
CategoryProductViewModel? Update(CategoryProductBindingModel model);
CategoryProductViewModel? Delete(CategoryProductBindingModel model);
}
}

View File

@ -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 IOrderStorage
{
List<OrderViewModel> GetFullList();
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
OrderViewModel? GetElement(OrderSearchModel model);
OrderViewModel? Insert(OrderBindingModel model);
OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model);
}
}

View File

@ -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 IProductStorage
{
List<ProductViewModel> GetFullList();
List<ProductViewModel> GetFilteredList(ProductSearchModel model);
ProductViewModel? GetElement(ProductSearchModel model);
ProductViewModel? Insert(ProductBindingModel model);
ProductViewModel? Update(ProductBindingModel model);
ProductViewModel? Delete(ProductBindingModel model);
}
}

View File

@ -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 IRoleStorage
{
List<RoleViewModel> GetFullList();
List<RoleViewModel> GetFilteredList(RoleSearchModel model);
RoleViewModel? GetElement(RoleSearchModel model);
RoleViewModel? Insert(RoleBindingModel model);
RoleViewModel? Update(RoleBindingModel model);
RoleViewModel? Delete(RoleBindingModel model);
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,18 @@
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 CategoryProductViewModel : ICategoryProductModel
{
public int ID { get; set; }
[DisplayName("Название категории продукта")]
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,35 @@
using ElectronicsShopDataModels.Enums;
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 OrderViewModel : IOrderModel
{
public int ID { get; set; }
[DisplayName("Клиент ID")]
public int UserID { get; set; }
[DisplayName("Сумма")]
public double Sum { get; set; }
[DisplayName("Статус")]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DisplayName("Стутус оплаты")]
public PaymeantOption PaymeantOption { get; set; } = PaymeantOption.Неизвестно;
[DisplayName("Дата создания")]
public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Дата выполнения")]
public DateTime? DateImplement { get; set; }
public Dictionary<int, (IProductModel, int)> ProductList { get; set; } = new();
}
}

View File

@ -0,0 +1,24 @@
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 ProductViewModel : IProductModel
{
//ID категории продукта (товара)
public int CategoryID { get; set; }
//ID продукта (товара)
public int ID { get; set; }
[DisplayName("Название товара")]
public string ProductName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopContracts.ViewModels
{
public class ReportOrdersViewModel
{
public int ID { get; set; }
public DateTime DateCreate { get; set; }
public double Sum { get; set; }
public string PaymeantOption { get; set; } = string.Empty;
public string OrderStatus { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,21 @@
using ElectronicsShopDataModels;
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 RoleViewModel : IRoleModel
{
public int ID { get; set; }
[DisplayName("Название роли")]
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,38 @@
using ElectronicsShopDataModels;
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 UserViewModel : IUserModel
{
//ID пользователя
public int ID { 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;
}
}

View File

@ -0,0 +1,25 @@
using ElectronicsShopDataBaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
namespace ElectronicsShopDataBaseImplement
{
public class Database : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder
optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-E2VPEN3\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;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<Role> Roles { set; get; }
public virtual DbSet<Product> Products { set; get; }
public virtual DbSet<Order> Orders { set; get; }
}
}

View File

@ -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>

View File

@ -0,0 +1,83 @@
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;
namespace ElectronicsShopDataBaseImplement.Implements
{
public class CategoryProductStorage : ICategoryProductStorage
{
public CategoryProductViewModel? Delete(CategoryProductBindingModel model)
{
using var context = new Database();
var element = context.CategoryProducts.FirstOrDefault(rec => rec.ID == model.ID);
if (element != null)
{
context.CategoryProducts.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public CategoryProductViewModel? 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;
}
public List<CategoryProductViewModel> GetFilteredList(CategoryProductSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new Database();
return context.CategoryProducts.Where(x => x.Name.Contains(model.Name)).Select(x => x.GetViewModel).ToList();
}
public List<CategoryProductViewModel> GetFullList()
{
using var context = new Database();
return context.CategoryProducts.Select(x => x.GetViewModel).ToList();
}
public CategoryProductViewModel? 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;
}
public CategoryProductViewModel? Update(CategoryProductBindingModel model)
{
using var context = new Database();
var component = context.CategoryProducts.FirstOrDefault(x => x.ID == model.ID);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
}
}

View File

@ -0,0 +1,88 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.StorageContracts;
using ElectronicsShopContracts.ViewModels;
using ElectronicsShopDataBaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopDataBaseImplement.Implements
{
public class OrderStorage : IOrderStorage
{
public OrderViewModel? Delete(OrderBindingModel model)
{
using var context = new Database();
var element = context.Orders.FirstOrDefault(rec => rec.ID == model.ID);
if (element != null)
{
context.Orders.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.ID.HasValue)
{
return null;
}
using var context = new Database();
return context.Orders.FirstOrDefault(x =>
(x.DateCreate == model.DateFrom && (model.ID.HasValue && x.ID == model.ID)))?.GetViewModel;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.ID.HasValue && (model.DateFrom == null || model.DateTo == null))
{
return new();
}
using var context = new Database();
return context.Orders
.Include(x => x.Products)
.ThenInclude(x => x._product)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
public List<OrderViewModel> GetFullList()
{
using var context = new Database();
return context.Orders.Select(x => x.GetViewModel).ToList();
}
public OrderViewModel? Insert(OrderBindingModel model)
{
using var context = new Database();
var newComponent = Order.Create(context,model);
if (newComponent == null)
{
return null;
}
context.Orders.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
{
using var context = new Database();
var component = context.Orders.FirstOrDefault(x => x.ID == model.ID);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
}
}

View File

@ -0,0 +1,84 @@
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;
namespace ElectronicsShopDataBaseImplement.Implements
{
public class ProductStorage : IProductStorage
{
public ProductViewModel? Delete(ProductBindingModel model)
{
using var context = new Database();
var element = context.Products.FirstOrDefault(rec => rec.ID == model.ID);
if (element != null)
{
context.Products.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public ProductViewModel? GetElement(ProductSearchModel model)
{
if (string.IsNullOrEmpty(model.ProductName) && !model.ID.HasValue)
{
return null;
}
using var context = new Database();
return context.Products.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.ProductName) && (model.ID.HasValue && x.ID == model.ID)))?.GetViewModel;
}
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
{
if (string.IsNullOrEmpty(model.ProductName))
{
return new();
}
using var context = new Database();
return context.Products.Where(x => x.ProductName.Contains(model.ProductName)).Select(x => x.GetViewModel).ToList();
}
public List<ProductViewModel> GetFullList()
{
using var context = new Database();
return context.Products.Select(x => x.GetViewModel).ToList();
}
public ProductViewModel? Insert(ProductBindingModel model)
{
var newComponent = Product.Create(model);
if (newComponent == null)
{
return null;
}
using var context = new Database();
context.Products.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public ProductViewModel? Update(ProductBindingModel model)
{
using var context = new Database();
var component = context.Products.FirstOrDefault(x => x.ID == model.ID);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
}
}

View File

@ -0,0 +1,82 @@
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;
namespace ElectronicsShopDataBaseImplement.Implements
{
public class RoleStorage: IRoleStorage
{
public RoleViewModel? Delete(RoleBindingModel model)
{
using var context = new Database();
var element = context.Roles.FirstOrDefault(rec => rec.ID == model.ID);
if (element != null)
{
context.Roles.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public RoleViewModel? GetElement(RoleSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.ID.HasValue)
{
return null;
}
using var context = new Database();
return context.Roles.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.Name) && x.Name == model.Name && (model.ID.HasValue && x.ID == model.ID)))?.GetViewModel;
}
public List<RoleViewModel> GetFilteredList(RoleSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new Database();
return context.Roles.Where(x => x.Name.Contains(model.Name)).Select(x => x.GetViewModel).ToList();
}
public List<RoleViewModel> GetFullList()
{
using var context = new Database();
return context.Roles.Select(x => x.GetViewModel).ToList();
}
public RoleViewModel? Insert(RoleBindingModel model)
{
var newComponent = Role.Create(model);
if (newComponent == null)
{
return null;
}
using var context = new Database();
context.Roles.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public RoleViewModel? Update(RoleBindingModel model)
{
using var context = new Database();
var component = context.Roles.FirstOrDefault(x => x.ID == model.ID);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
}
}

View File

@ -0,0 +1,83 @@
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;
namespace ElectronicsShopDataBaseImplement.Implements
{
public class UserStorage : IUserStorage
{
public UserViewModel? Delete(UserBindingModel model)
{
using var context = new Database();
var element = context.Users.FirstOrDefault(rec => rec.ID == model.ID);
if (element != null)
{
context.Users.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public UserViewModel? GetElement(UserSearchModel model)
{
if (string.IsNullOrEmpty(model.Login) && !model.ID.HasValue)
{
return null;
}
using var context = new Database();
return context.Users.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.Login) && x.Login == model.Login ||
(model.ID.HasValue && x.ID == model.ID)))?.GetViewModel;
}
public List<UserViewModel> GetFilteredList(UserSearchModel model)
{
if (string.IsNullOrEmpty(model.Login))
{
return new();
}
using var context = new Database();
return context.Users.Where(x => x.Login.Contains(model.Login)).Select(x => x.GetViewModel).ToList();
}
public List<UserViewModel> GetFullList()
{
using var context = new Database();
return context.Users.Select(x => x.GetViewModel).ToList();
}
public UserViewModel? Insert(UserBindingModel model)
{
var newComponent = User.Create(model);
if (newComponent == null)
{
return null;
}
using var context = new Database();
context.Users.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public UserViewModel? Update(UserBindingModel model)
{
using var context = new Database();
var component = context.Users.FirstOrDefault(x => x.ID == model.ID);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
}
}

View File

@ -0,0 +1,57 @@
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; 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;
}
Name = model.Name;
}
public CategoryProductViewModel GetViewModel => new()
{
ID = ID,
Name = Name
};
}
}

View File

@ -0,0 +1,99 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
using ElectronicsShopDataModels.Enums;
using ElectronicsShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopDataBaseImplement.Models
{
public class Order : IOrderModel
{
public int ID { get; set; }
[Required]
public double Sum { get; set; }
[Required]
public int UserID { get; set; }
[Required]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[Required]
public PaymeantOption PaymeantOption { get; set; } = PaymeantOption.Неизвестно;
[Required]
public DateTime DateCreate { get; set; } = DateTime.Now;
[Required]
public DateTime? DateImplement { get; set; }
[Required]
public Dictionary<int, (IProductModel, int)> ProductList { get; set; } = new();
[NotMapped]
public Dictionary<int, (IProductModel, int)> _productList
{
get {
if (ProductList == null) {
ProductList = Products.ToDictionary(recPC => recPC.ProductID, recPC => (recPC._product as IProductModel, recPC.Count));
}
return _productList;
}
}
public virtual List<OrderProducts> Products { get; set; } = new();
public static Order? Create(Database context ,OrderBindingModel? model)
{
if (model == null)
{
return null;
}
return new Order()
{
ID = model.ID,
UserID=model.UserID,
Sum = model.Sum,
Status = model.Status,
PaymeantOption = model.PaymeantOption,
DateCreate = model.DateCreate,
Products = model.ProductList.Select(x => new OrderProducts
{
_product = context.Products.First(y => y.ID == x.Key),
Count = x.Value.Item2
}).ToList()
};
}
public void Update(OrderBindingModel model)
{
if (model == null)
{
return;
}
ID = model.ID;
UserID = model.UserID;
Sum = model.Sum;
PaymeantOption = model.PaymeantOption;
Status = model.Status;
DateCreate = model.DateCreate;
if (model.DateImplement != null)
{
DateImplement = model.DateImplement;
}
//todo ProductList
}
public OrderViewModel GetViewModel => new()
{
ID = ID,
UserID = UserID,
Sum = Sum,
PaymeantOption = PaymeantOption,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement,
ProductList = ProductList
};
}
}

View File

@ -0,0 +1,26 @@
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 OrderProducts
{
public int ID { get; set; }
[Required]
public int OrdersID { get; set; }
[Required]
public int ProductID { get; set; }
[Required]
public int Count { get; set; }
public virtual Order _order { get; set; } = new();
public virtual Product _product { get; set; } = new();
}
}

View File

@ -0,0 +1,66 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
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 Product : IProductModel
{
public int ID { get; set; }
[Required]
public string ProductName { get; set; }=string.Empty;
[Required]
public double Price { get; set; }
[Required]
public int CategoryID { get; set; }
public static Product? Create(ProductBindingModel? model)
{
if (model == null)
{
return null;
}
return new Product()
{
ID = model.ID,
ProductName = model.ProductName,
Price = model.Price,
CategoryID = model.CategoryID
};
}
public static Product? Create(ProductViewModel model)
{
return new Product
{
ID = model.ID,
ProductName = model.ProductName,
Price = model.Price,
CategoryID = model.CategoryID
};
}
public void Update(ProductBindingModel model)
{
if (model == null)
{
return;
}
ProductName = model.ProductName;
Price = model.Price;
CategoryID = model.CategoryID;
}
public ProductViewModel GetViewModel => new()
{
ID = ID,
ProductName = ProductName,
Price = Price,
CategoryID = CategoryID
};
}
}

View File

@ -0,0 +1,55 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
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 Role : IRoleModel
{
public int ID { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
public static Role? Create(RoleBindingModel? model)
{
if (model == null)
{
return null;
}
return new Role()
{
ID = model.ID,
Name = model.Name
};
}
public static Role? Create(RoleViewModel model)
{
return new Role
{
ID = model.ID,
Name = model.Name
};
}
public void Update(RoleBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
}
public RoleViewModel GetViewModel => new()
{
ID = ID,
Name = Name
};
}
}

View File

@ -0,0 +1,90 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
using ElectronicsShopDataModels;
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 User : IUserModel
{
public int ID { get; set; }
[Required]
public string FirstName { get; set; }=string.Empty;
[Required]
public string LastName {get; set; }=string.Empty;
[Required]
public string Password { get; set; } = string.Empty;
[Required]
public string PhoneNumber { get; set; } = string.Empty;
[Required]
public string Login { get; set; } = string.Empty;
[Required]
public string Email { get; set; } = string.Empty;
[Required]
public int RoleID { get; set; }
public static User? Create(UserBindingModel model)
{
if(model == null)
{
return null;
}
return new User()
{
ID = model.ID,
FirstName = model.FirstName,
LastName = model.LastName,
Password = model.Password,
PhoneNumber = model.PhoneNumber,
Login = model.Login,
Email = model.Email,
RoleID = model.RoleID
};
}
public static User Create(UserViewModel model)
{
return new User
{
ID = model.ID,
FirstName = model.FirstName,
LastName = model.LastName,
Password = model.Password,
PhoneNumber = model.PhoneNumber,
Login = model.Login,
Email = model.Email,
RoleID = model.RoleID
};
}
public void Update(UserBindingModel model)
{
if (model == null)
{
return;
}
FirstName = model.FirstName;
LastName = model.LastName;
Password = model.Password;
PhoneNumber = model.PhoneNumber;
Login = model.Login;
Email = model.Email;
RoleID = model.RoleID;
}
public UserViewModel GetViewModel => new()
{
ID = ID,
FirstName = FirstName,
LastName = LastName,
Password = Password,
PhoneNumber = PhoneNumber,
Login = Login,
Email = Email,
RoleID = RoleID
};
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopDataModels.Enums
{
public enum OrderStatus
{
Неизвестен = -1,
Принят = 0,
Выполняется = 1,
Готов = 2,
Выдан = 3
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopDataModels.Enums
{
public enum PaymeantOption
{
Неизвестно = -1,
Полная_оплата = 0,
Частичная_оплата = 1
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopDataModels
{
public interface IID
{
int ID { get; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopDataModels.Models
{
public interface ICategoryProductModel : IID
{
string Name { get; }
}
}

View File

@ -0,0 +1,21 @@
using ElectronicsShopDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopDataModels.Models
{
public interface IOrderModel : IID
{
double Sum { get; }
int UserID { get; }
OrderStatus Status { get; }
PaymeantOption PaymeantOption { get; }
DateTime DateCreate { get; }
DateTime? DateImplement { get; }
//список товаров в заказе
Dictionary<int, (IProductModel, int)> ProductList { get; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopDataModels.Models
{
public interface IProductModel : IID
{
string ProductName { get; }
double Price { get; }
int CategoryID { get; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopDataModels.Models
{
public interface IRoleModel : IID
{
string Name { get; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopDataModels
{
public interface IUserModel : IID
{
//ID role
int RoleID { get; }
string FirstName { get; }
string LastName { get; }
string Password { get; }
string PhoneNumber { get; }
string Login { get; }
string Email { get; }
}
}

View File

@ -0,0 +1,9 @@
using Microsoft.AspNetCore.Mvc;
namespace ElectronicsShopResrAPI.Controllers {
public class MainController : Controller {
public IActionResult Index() {
return View();
}
}
}

View File

@ -0,0 +1,9 @@
using Microsoft.AspNetCore.Mvc;
namespace ElectronicsShopResrAPI.Controllers {
public class UserController : Controller {
public IActionResult Index() {
return View();
}
}
}

View File

@ -0,0 +1,6 @@
@ElectronicsShopResrAPI_HostAddress = http://localhost:5176
GET {{ElectronicsShopResrAPI_HostAddress}}/weatherforecast/
Accept: application/json
###

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,27 @@
using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(x => x.SwaggerDoc("v1", new OpenApiInfo { Title = "ElectronicsShopResrAPI", Version = "v1" }));
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(x => x.SwaggerEndpoint("/swagger/v1/swagger.json", "ElectronicsShopResrAPI v1"));
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:50570",
"sslPort": 44304
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5176",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7183;http://localhost:5176",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,6 @@
namespace ElectronicsShopUserApp {
public class APIUser {
// авторизация полльзователя
// подключение
}
}

View File

@ -0,0 +1,26 @@
using ElectronicsShopUserApp.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
namespace ElectronicsShopUserApp.Controllers {
public class HomeController : Controller {
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger) {
_logger = logger;
}
public IActionResult Index() {
return View();
}
public IActionResult Privacy() {
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() {
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ElectronicsShopContracts\ElectronicsShopContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,7 @@
namespace ElectronicsShopUserApp.Models {
public class ErrorViewModel {
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@ -0,0 +1,32 @@
namespace ElectronicsShopUserApp {
public class Program {
public static void Main(string[] args) {
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) {
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
}
}
}

View File

@ -0,0 +1,38 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:28835",
"sslPort": 44305
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5064",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7219;http://localhost:5064",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,26 @@
@{
ViewData["Title"] = "Create";
}
<div class="text-center">
<h2 class="display-4">Создание заказа</h2>
</div>
<form method="post">
<table class="table">
<div class="row">
<div class="col-4">Продукт:</div>
<div class="col-8"></div>
</div>
<div class="row">
<div class="col-4">Количество:</div>
<div class="col-8"><input type="text" name="count" id="count" /></div>
</div>
<div class="row">
<div class="col-4">Сумма:</div>
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</table>
</form>

View File

@ -0,0 +1,30 @@
@{
ViewData["Title"] = "Create";
}
<div class="text-center">
<h2 class="display-4">Создание Товара</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Товар:</div>
<div class="col-8">
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"ID", "ProductName"))"></select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-8"><input type="text" name="Name" id="Name" /></div>
</div>
<div class="row">
<div class="col-4">Сумма:</div>
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
</div>
<div class="row">
<div class="col-4">Сумма:</div>
<div class="col-8"><input type="text" id="Category" name="Category" readonly /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,21 @@
@{
ViewData["Title"] = "Enter";
}
<div class="text-center">
<h2 class="display-4">Вход в приложение</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,44 @@
@using ElectronicsShopContracts.ViewModels
@model List<ProductViewModel>
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Товары</h1>
</div>
<div class="text-center">
@{
if (Model == null) {
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="Create">Каталог</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
категория товара
</th>
<th>
название
</th>
<th>
цена
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,32 @@
@using ElectronicsShopContracts.ViewModels
@model UserViewModel
@{
ViewData["Title"] = "Privacy Policy";
}
<div class="text-center">
<h2 class="display-4">Личные данные</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" value="@Model.Email"/></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" value="@Model.Password"/></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="text" name="phone number" value="@Model.PhoneNumber"/></div>
</div>
<div class="row">
<div class="col-4">логин:</div>
<div class="col-8"><input type="text" name="fio" value="@Model.Login"/></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,25 @@
@{
ViewData["Title"] = "Register";
}
<div class="text-center">
<h2 class="display-4">Регистрация</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-4">ФИО:</div>
<div class="col-8"><input type="text" name="fio" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Регистрация" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,25 @@
@model ErrorViewModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - ElectronicsShopUserApp</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/ElectronicsShopUserApp.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">ElectronicsShopUserApp</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Заказы</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2024 - ElectronicsShopUserApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>

View File

@ -0,0 +1,48 @@
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
a {
color: #0077cc;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}

View File

@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

View File

@ -0,0 +1,3 @@
@using ElectronicsShopUserApp
@using ElectronicsShopUserApp.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
// порт -> Свойства/отладка/пользовательский ин./URL адресс
"IPAddress" : "http://localhost:5176/"
}

View File

@ -0,0 +1,22 @@
html {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -0,0 +1,4 @@
// Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code.

View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2011-2021 Twitter, Inc.
Copyright (c) 2011-2021 The Bootstrap Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,427 @@
/*!
* Bootstrap Reboot v5.1.0 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors
* Copyright 2011-2021 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
@media (prefers-reduced-motion: no-preference) {
:root {
scroll-behavior: smooth;
}
}
body {
margin: 0;
font-family: var(--bs-body-font-family);
font-size: var(--bs-body-font-size);
font-weight: var(--bs-body-font-weight);
line-height: var(--bs-body-line-height);
color: var(--bs-body-color);
text-align: var(--bs-body-text-align);
background-color: var(--bs-body-bg);
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
hr {
margin: 1rem 0;
color: inherit;
background-color: currentColor;
border: 0;
opacity: 0.25;
}
hr:not([size]) {
height: 1px;
}
h6, h5, h4, h3, h2, h1 {
margin-top: 0;
margin-bottom: 0.5rem;
font-weight: 500;
line-height: 1.2;
}
h1 {
font-size: calc(1.375rem + 1.5vw);
}
@media (min-width: 1200px) {
h1 {
font-size: 2.5rem;
}
}
h2 {
font-size: calc(1.325rem + 0.9vw);
}
@media (min-width: 1200px) {
h2 {
font-size: 2rem;
}
}
h3 {
font-size: calc(1.3rem + 0.6vw);
}
@media (min-width: 1200px) {
h3 {
font-size: 1.75rem;
}
}
h4 {
font-size: calc(1.275rem + 0.3vw);
}
@media (min-width: 1200px) {
h4 {
font-size: 1.5rem;
}
}
h5 {
font-size: 1.25rem;
}
h6 {
font-size: 1rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-bs-original-title] {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul {
padding-left: 2rem;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: 0.5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 0.875em;
}
mark {
padding: 0.2em;
background-color: #fcf8e3;
}
sub,
sup {
position: relative;
font-size: 0.75em;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
a {
color: #0d6efd;
text-decoration: underline;
}
a:hover {
color: #0a58ca;
}
a:not([href]):not([class]), a:not([href]):not([class]):hover {
color: inherit;
text-decoration: none;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 1em;
direction: ltr /* rtl:ignore */;
unicode-bidi: bidi-override;
}
pre {
display: block;
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
font-size: 0.875em;
}
pre code {
font-size: inherit;
color: inherit;
word-break: normal;
}
code {
font-size: 0.875em;
color: #d63384;
word-wrap: break-word;
}
a > code {
color: inherit;
}
kbd {
padding: 0.2rem 0.4rem;
font-size: 0.875em;
color: #fff;
background-color: #212529;
border-radius: 0.2rem;
}
kbd kbd {
padding: 0;
font-size: 1em;
font-weight: 700;
}
figure {
margin: 0 0 1rem;
}
img,
svg {
vertical-align: middle;
}
table {
caption-side: bottom;
border-collapse: collapse;
}
caption {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
color: #6c757d;
text-align: left;
}
th {
text-align: inherit;
text-align: -webkit-match-parent;
}
thead,
tbody,
tfoot,
tr,
td,
th {
border-color: inherit;
border-style: solid;
border-width: 0;
}
label {
display: inline-block;
}
button {
border-radius: 0;
}
button:focus:not(:focus-visible) {
outline: 0;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
select {
text-transform: none;
}
[role=button] {
cursor: pointer;
}
select {
word-wrap: normal;
}
select:disabled {
opacity: 1;
}
[list]::-webkit-calendar-picker-indicator {
display: none;
}
button,
[type=button],
[type=reset],
[type=submit] {
-webkit-appearance: button;
}
button:not(:disabled),
[type=button]:not(:disabled),
[type=reset]:not(:disabled),
[type=submit]:not(:disabled) {
cursor: pointer;
}
::-moz-focus-inner {
padding: 0;
border-style: none;
}
textarea {
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
float: left;
width: 100%;
padding: 0;
margin-bottom: 0.5rem;
font-size: calc(1.275rem + 0.3vw);
line-height: inherit;
}
@media (min-width: 1200px) {
legend {
font-size: 1.5rem;
}
}
legend + * {
clear: left;
}
::-webkit-datetime-edit-fields-wrapper,
::-webkit-datetime-edit-text,
::-webkit-datetime-edit-minute,
::-webkit-datetime-edit-hour-field,
::-webkit-datetime-edit-day-field,
::-webkit-datetime-edit-month-field,
::-webkit-datetime-edit-year-field {
padding: 0;
}
::-webkit-inner-spin-button {
height: auto;
}
[type=search] {
outline-offset: -2px;
-webkit-appearance: textfield;
}
/* rtl:raw:
[type="tel"],
[type="url"],
[type="email"],
[type="number"] {
direction: ltr;
}
*/
::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-color-swatch-wrapper {
padding: 0;
}
::file-selector-button {
font: inherit;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
iframe {
border: 0;
}
summary {
display: list-item;
cursor: pointer;
}
progress {
vertical-align: baseline;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */

Some files were not shown because too many files have changed in this diff Show More