From a11c708c7bb06d9e85727e74738e16b235c5d9e6 Mon Sep 17 00:00:00 2001 From: FLARJ <122087628+FLARJ@users.noreply.github.com> Date: Fri, 7 Apr 2023 18:23:45 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B1=D0=B0=D0=B7=D1=8B=20=D0=B4=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FurnitureDataBase.cs | 45 +++++++++++++++++++ .../Implements/ManagerStorage.cs | 1 + .../Implements/OrderStorage.cs | 1 + .../Implements/SalesSalonStorage.cs | 7 +-- .../Models/Headset.cs | 2 +- 5 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureDataBase.cs diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureDataBase.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureDataBase.cs new file mode 100644 index 0000000..e0c39c2 --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/FurnitureDataBase.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.EntityFrameworkCore; +using FurnitureFactoryDataBaseImplement.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reflection.Metadata; +using System.Runtime.ConstrainedExecution; +using System.Text; +using System.Threading.Tasks; +using HeadsetModule = FurnitureFactoryDataBaseImplement.Models.HeadsetModule; +using System.Threading.Tasks; + +namespace FurnitureFactoryDataBaseImplement +{ + public class FurnitureDataBase : DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (optionsBuilder.IsConfigured == false) + { + optionsBuilder.UseNpgsql("Server=PostgreSQL;Host=localhost;Port=5432;Database=FurnitureFactoryDataBase;Username=postgres;Password=postgres"); + } + base.OnConfiguring(optionsBuilder); + } + + public virtual DbSet Managers { set; get; } + + public virtual DbSet SalesSalons { set; get; } + + public virtual DbSet Headsets { set; get; } + public virtual DbSet HeadsetSalesSalons { set; get; } + public virtual DbSet Orders { set; get; } + public virtual DbSet OrdersSalesSalons { set; get; } + + //public virtual DbSet Masters { set; get; } + + public virtual DbSet Materials { set; get; } + + } +} diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/ManagerStorage.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/ManagerStorage.cs index 4830695..519f503 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/ManagerStorage.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/ManagerStorage.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Runtime.ConstrainedExecution; using System.Text; using System.Threading.Tasks; +using FurnitureFactoryDataBaseImplement; namespace FurnitureFactoryDataBaseImplements.Implements { diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/OrderStorage.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/OrderStorage.cs index dc1e37c..7876b15 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/OrderStorage.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/OrderStorage.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Runtime.ConstrainedExecution; using System.Text; using System.Threading.Tasks; +using FurnitureFactoryDataBaseImplement; namespace FurnitureFactoryDataBaseImplements.Implements { diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/SalesSalonStorage.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/SalesSalonStorage.cs index 443eabb..eaa7954 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/SalesSalonStorage.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Implements/SalesSalonStorage.cs @@ -2,6 +2,7 @@ using FurnitureContracts.SearchModels; using FurnitureContracts.StoragesContracts; using FurnitureContracts.ViewModel; +using FurnitureFactoryDataBaseImplement; using FurnitureFactoryDataBaseImplements.Models; using System; using System.Collections.Generic; @@ -29,8 +30,8 @@ namespace FurnitureFactoryDataBaseImplements.Implements return new(); } using var context = new FurnitureDataBase(); - return context.Interests - .Where(x => x.StudentId == model.ManagerId) + return context.SalesSalons + .Where(x => x.ManagerId == model.ManagerId) .Select(x => x.GetViewModel) .ToList(); } @@ -43,7 +44,7 @@ namespace FurnitureFactoryDataBaseImplements.Implements } using var context = new FurnitureDataBase(); return context.SalesSalons - .FirstOrDefault(x => ((!string.IsNullOrEmpty(model.Name) && x.Title == model.Name) || + .FirstOrDefault(x => ((!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id)) && x.ManagerId == model.ManagerId) ?.GetViewModel; } diff --git a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Headset.cs b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Headset.cs index c084d9b..f5ad514 100644 --- a/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Headset.cs +++ b/FurnitureFactory/FurnitureFactoryDataBaseImplement/Models/Headset.cs @@ -74,7 +74,7 @@ namespace FurnitureFactoryDataBaseImplement.Models HeadsetSalesSalons = HeadsetSalesSalons }; - public void UpdateInterests(FurnitureDataBase context, HeadsetBindingModel model) + public void UpdateSalesSalons(FurnitureDataBase context, HeadsetBindingModel model) { var headsetSalesSalons = context.HeadsetSalesSalons.Where(rec => rec.HeadsetId == model.Id).ToList(); if (headsetSalesSalons != null && HeadsetSalesSalons.Count > 0)