Создание базы данных

This commit is contained in:
FLARJ 2023-04-07 18:23:45 +04:00
parent b6f8cf61d3
commit a11c708c7b
5 changed files with 52 additions and 4 deletions

View File

@ -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<Manager> Managers { set; get; }
public virtual DbSet<SalesSalons> SalesSalons { set; get; }
public virtual DbSet<Headset> Headsets { set; get; }
public virtual DbSet<HeadsetSalesSalons> HeadsetSalesSalons { set; get; }
public virtual DbSet<Orders> Orders { set; get; }
public virtual DbSet<OrdersSalesSalons> OrdersSalesSalons { set; get; }
//public virtual DbSet<Master> Masters { set; get; }
public virtual DbSet<Material> Materials { set; get; }
}
}

View File

@ -10,6 +10,7 @@ using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Text;
using System.Threading.Tasks;
using FurnitureFactoryDataBaseImplement;
namespace FurnitureFactoryDataBaseImplements.Implements
{

View File

@ -10,6 +10,7 @@ using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Text;
using System.Threading.Tasks;
using FurnitureFactoryDataBaseImplement;
namespace FurnitureFactoryDataBaseImplements.Implements
{

View File

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

View File

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