Исправление хранилищ
This commit is contained in:
parent
e558896d4f
commit
1160862303
@ -1,33 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace HardwareShopClientApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,25 +0,0 @@
|
||||
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();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
@ -1,31 +0,0 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:26489",
|
||||
"sslPort": 44339
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"HardwareShopClientApi": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7118;http://localhost:5118",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
namespace HardwareShopClientApi
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
@ -43,7 +43,6 @@ namespace HardwareShopClientApp.Controllers
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
//return RedirectToAction("MainWorker", "Worker");
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
@ -74,16 +73,15 @@ namespace HardwareShopClientApp.Controllers
|
||||
{
|
||||
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите логин и пароль");
|
||||
throw new Exception("Введите почту и пароль");
|
||||
}
|
||||
APIClient.User = APIClient.GetRequest<UserViewModel>($"api/client/login?email={email}&password={password}");
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
throw new Exception("Неверные почта и/или пароль");
|
||||
}
|
||||
if ((int)APIClient.User.Role == 1)
|
||||
{
|
||||
//TempData["UserId"] = APIClient.User.Id;
|
||||
return RedirectToAction("WorkerReport", "Worker");
|
||||
}
|
||||
else
|
||||
|
@ -6,6 +6,14 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Views\Storekeeper\Components.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Views\Storekeeper\Components.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<input type="password" class="form-control" name="password">
|
||||
</div>
|
||||
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4">Submit</button>
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4">Подтвердить</button>
|
||||
<a asp-action="Register">Регистрация</a>
|
||||
</div>
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
@section Header {
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
||||
|
@ -25,7 +25,8 @@
|
||||
<option value="2">Кладовщик</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4">Submit</button>
|
||||
<button type="submit" class="btn btn-primary mt-3 px-4">Подтвердить</button>
|
||||
<a asp-action="Enter">Вернуться на вход</a>
|
||||
|
||||
</form>
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -11,5 +11,11 @@ namespace HardwareShopContracts.BindingModels
|
||||
public double Cost { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
public Dictionary<int, (IBuildModel, int)> ComponentsBuilds
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
||||
|
@ -4,5 +4,6 @@
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ComponentName { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -4,5 +4,6 @@
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? GoodName { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,5 +5,6 @@
|
||||
public int? Id { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,6 @@ namespace HardwareShopContracts.SearchModels
|
||||
|
||||
public string? Email { get; set; } = string.Empty;
|
||||
|
||||
public int? UserId { get; set; }
|
||||
|
||||
public string? Password { get; set; } = string.Empty;
|
||||
|
||||
public UserRole? Role { get; set; } = UserRole.Неизвестен;
|
||||
|
@ -13,5 +13,10 @@ namespace HardwareShopContracts.ViewModels
|
||||
public int UserId { get; set; }
|
||||
[DisplayName("Логин кладовщика")]
|
||||
public string UserLogin { get; set; } = string.Empty;
|
||||
public Dictionary<int, (IBuildModel, int)>? ComponentsBuilds
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace HardwareShopContracts.ViewModels
|
||||
public int UserId { get; set; }
|
||||
[DisplayName("Логин кладовщика")]
|
||||
public string UserLogin { get; set; } = string.Empty;
|
||||
public Dictionary<int, (IComponentModel, int)> GoodComponents
|
||||
public Dictionary<int, (IComponentModel, int)> GoodsComponents
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
@ -10,10 +10,10 @@ namespace HardwareShopContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
public int GoodId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
[DisplayName("Комлектующая")]
|
||||
public string GoodName { get; set; } = string.Empty;
|
||||
[DisplayName("Логин кладовщика")]
|
||||
public string UserLogin { get; set; } = string.Empty;
|
||||
[DisplayName("Товар")]
|
||||
public string GoodName { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Count{ get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
|
@ -5,5 +5,6 @@
|
||||
string ComponentName { get; }
|
||||
double Cost { get; }
|
||||
int UserId { get; }
|
||||
Dictionary<int, (IBuildModel, int)>? ComponentsBuilds { get; }
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,6 @@
|
||||
string GoodName { get; }
|
||||
double Price { get; }
|
||||
int UserId { get; }
|
||||
Dictionary<int, (IComponentModel, int)> GoodComponents { get; }
|
||||
Dictionary<int, (IComponentModel, int)> GoodsComponents { get; }
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,12 @@ namespace HardwareShopDatabaseImplement
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=Computer_Hardware_Store1;Username=postgres;Password=1234");
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5433;Database=Computer_Hardware_Store;Username=user;Password=12345");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<BuildComponent>().HasKey(x => new { x.ComponentId, x.BuildId });
|
||||
modelBuilder.Entity<ComponentBuild>().HasKey(x => new { x.ComponentId, x.BuildId });
|
||||
modelBuilder.Entity<PurchaseBuild>().HasKey(x => new { x.PurchaseId, x.BuildId });
|
||||
modelBuilder.Entity<PurchaseGood>().HasKey(x => new { x.PurchaseId, x.GoodId });
|
||||
modelBuilder.Entity<GoodComponent>().HasKey(x => new { x.GoodId, x.ComponentId });
|
||||
@ -28,7 +28,7 @@ namespace HardwareShopDatabaseImplement
|
||||
|
||||
public virtual DbSet<Build> Builds { set; get; }
|
||||
|
||||
public virtual DbSet<BuildComponent> BuildsComponents { set; get; }
|
||||
public virtual DbSet<ComponentBuild> ComponentsBuilds { set; get; }
|
||||
|
||||
public virtual DbSet<Comment> Comments { set; get; }
|
||||
|
||||
@ -36,7 +36,7 @@ namespace HardwareShopDatabaseImplement
|
||||
|
||||
public virtual DbSet<Good> Goods { set; get; }
|
||||
|
||||
public virtual DbSet<GoodComponent> GoodComponents { set; get; }
|
||||
public virtual DbSet<GoodComponent> GoodsComponents { set; get; }
|
||||
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
|
||||
|
@ -12,7 +12,11 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
||||
public ComponentViewModel? Delete(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new HardwareShopDatabase();
|
||||
var element = context.Components.Include(x => x.User).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Components
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Builds)
|
||||
.ThenInclude(x => x.Build)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Components.Remove(element);
|
||||
@ -24,64 +28,103 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
||||
|
||||
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new HardwareShopDatabase();
|
||||
return context.Components.Include(x => x.User)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
if (!string.IsNullOrEmpty(model.ComponentName) || model.Id.HasValue)
|
||||
return context.Components
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Builds)
|
||||
.ThenInclude(x => x.Build)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName)
|
||||
&& x.ComponentName == model.ComponentName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
if (model.UserId.HasValue)
|
||||
return context.Components
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Builds)
|
||||
.ThenInclude(x => x.Build)
|
||||
.FirstOrDefault(x => x.UserId == model.UserId)?.GetViewModel;
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ComponentName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new HardwareShopDatabase();
|
||||
if (model.UserId.HasValue)
|
||||
{
|
||||
return context.Components
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Builds)
|
||||
.ThenInclude(x => x.Build)
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.ComponentName))
|
||||
{
|
||||
return context.Components
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Builds)
|
||||
.ThenInclude(x => x.Build)
|
||||
.Where(x => x.ComponentName.Contains(model.ComponentName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<ComponentViewModel> GetFullList()
|
||||
{
|
||||
using var context = new HardwareShopDatabase();
|
||||
return context.Components
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Builds)
|
||||
.ThenInclude(x => x.Build)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ComponentViewModel? Insert(ComponentBindingModel model)
|
||||
{
|
||||
var newComponent = Component.Create(model);
|
||||
using var context = new HardwareShopDatabase();
|
||||
var newComponent = Component.Create(context, model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new HardwareShopDatabase();
|
||||
context.Components.Add(newComponent);
|
||||
context.SaveChanges();
|
||||
return context.Components
|
||||
.Include(x => x.User).FirstOrDefault(x => x.Id == newComponent.Id)?.GetViewModel;
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Builds)
|
||||
.ThenInclude(x => x.Build)
|
||||
.FirstOrDefault(x => x.Id == newComponent.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public ComponentViewModel? Update(ComponentBindingModel model)
|
||||
{
|
||||
using var context = new HardwareShopDatabase();
|
||||
var component = context.Components.Include(x => x.User).FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var good = context.Components
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Builds)
|
||||
.ThenInclude(x => x.Build)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (good == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
good.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
good.UpdateBuilds(context, model);
|
||||
transaction.Commit();
|
||||
return good.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,11 +28,15 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
||||
|
||||
public GoodViewModel? GetElement(GoodSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.GoodName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new HardwareShopDatabase();
|
||||
if (model.UserId.HasValue)
|
||||
return context.Goods
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.FirstOrDefault(x => x.UserId == model.UserId)
|
||||
?.GetViewModel;
|
||||
if (!string.IsNullOrEmpty(model.GoodName) || model.Id.HasValue)
|
||||
return context.Goods
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Components)
|
||||
@ -40,15 +44,21 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.GoodName) && x.GoodName == model.GoodName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<GoodViewModel> GetFilteredList(GoodSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.GoodName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new HardwareShopDatabase();
|
||||
if (model.UserId.HasValue)
|
||||
return context.Goods
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
if (!string.IsNullOrEmpty(model.GoodName))
|
||||
return context.Goods
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Components)
|
||||
@ -56,6 +66,7 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
|
||||
.Where(x => x.GoodName.Contains(model.GoodName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<GoodViewModel> GetFullList()
|
||||
|
@ -1,526 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HardwareShopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HardwareShopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(HardwareShopDatabase))]
|
||||
[Migration("20230401181954_init")]
|
||||
partial class init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
|
||||
{
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ComponentId", "BuildId");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.ToTable("BuildsComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
|
||||
{
|
||||
b.Property<int>("GoodId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("GoodId", "ComponentId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("GoodComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
|
||||
{
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("PurchaseId", "BuildId");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.ToTable("PurchasesBuilds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
|
||||
{
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("GoodId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("PurchaseId", "GoodId");
|
||||
|
||||
b.HasIndex("GoodId");
|
||||
|
||||
b.ToTable("PurchasesGoods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("GoodName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Goods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("GoodId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("GoodId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Role")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Email")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("Login")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("BuildName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("numeric");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Builds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Comments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime?>("DatePurchase")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("PurchaseStatus")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<decimal>("Sum")
|
||||
.HasColumnType("numeric");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
|
||||
.WithMany("Goods")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("GoodId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Good");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("GoodId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
|
||||
.WithMany("Goods")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Good");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Goods")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("GoodId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Good");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
|
||||
.WithMany("Comments")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Comments")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Goods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Comments");
|
||||
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Goods");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
|
||||
{
|
||||
b.Navigation("Comments");
|
||||
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Goods");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,390 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HardwareShopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class init : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Login = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false),
|
||||
Role = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Builds",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Price = table.Column<decimal>(type: "numeric", nullable: false),
|
||||
BuildName = table.Column<string>(type: "text", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
ClientId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Builds", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Builds_Users_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ComponentName = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
ClientId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Components_Users_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Goods",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
GoodName = table.Column<string>(type: "text", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
ClientId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Goods", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Goods_Users_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Purchases",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Sum = table.Column<decimal>(type: "numeric", nullable: false),
|
||||
PurchaseStatus = table.Column<int>(type: "integer", nullable: false),
|
||||
DatePurchase = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
ClientId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Purchases", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Purchases_Users_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Comments",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Text = table.Column<string>(type: "text", nullable: false),
|
||||
BuildId = table.Column<int>(type: "integer", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
ClientId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Comments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Comments_Builds_BuildId",
|
||||
column: x => x.BuildId,
|
||||
principalTable: "Builds",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Comments_Users_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "BuildsComponents",
|
||||
columns: table => new
|
||||
{
|
||||
BuildId = table.Column<int>(type: "integer", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_BuildsComponents", x => new { x.ComponentId, x.BuildId });
|
||||
table.ForeignKey(
|
||||
name: "FK_BuildsComponents_Builds_BuildId",
|
||||
column: x => x.BuildId,
|
||||
principalTable: "Builds",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_BuildsComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GoodComponents",
|
||||
columns: table => new
|
||||
{
|
||||
GoodId = table.Column<int>(type: "integer", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GoodComponents", x => new { x.GoodId, x.ComponentId });
|
||||
table.ForeignKey(
|
||||
name: "FK_GoodComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_GoodComponents_Goods_GoodId",
|
||||
column: x => x.GoodId,
|
||||
principalTable: "Goods",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
GoodId = table.Column<int>(type: "integer", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||
ClientId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Goods_GoodId",
|
||||
column: x => x.GoodId,
|
||||
principalTable: "Goods",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Users_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PurchasesBuilds",
|
||||
columns: table => new
|
||||
{
|
||||
BuildId = table.Column<int>(type: "integer", nullable: false),
|
||||
PurchaseId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PurchasesBuilds", x => new { x.PurchaseId, x.BuildId });
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchasesBuilds_Builds_BuildId",
|
||||
column: x => x.BuildId,
|
||||
principalTable: "Builds",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchasesBuilds_Purchases_PurchaseId",
|
||||
column: x => x.PurchaseId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PurchasesGoods",
|
||||
columns: table => new
|
||||
{
|
||||
PurchaseId = table.Column<int>(type: "integer", nullable: false),
|
||||
GoodId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PurchasesGoods", x => new { x.PurchaseId, x.GoodId });
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchasesGoods_Goods_GoodId",
|
||||
column: x => x.GoodId,
|
||||
principalTable: "Goods",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchasesGoods_Purchases_PurchaseId",
|
||||
column: x => x.PurchaseId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Builds_ClientId",
|
||||
table: "Builds",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_BuildsComponents_BuildId",
|
||||
table: "BuildsComponents",
|
||||
column: "BuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Comments_BuildId",
|
||||
table: "Comments",
|
||||
column: "BuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Comments_ClientId",
|
||||
table: "Comments",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Components_ClientId",
|
||||
table: "Components",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GoodComponents_ComponentId",
|
||||
table: "GoodComponents",
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Goods_ClientId",
|
||||
table: "Goods",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_GoodId",
|
||||
table: "Orders",
|
||||
column: "GoodId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_ClientId",
|
||||
table: "Purchases",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchasesBuilds_BuildId",
|
||||
table: "PurchasesBuilds",
|
||||
column: "BuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchasesGoods_GoodId",
|
||||
table: "PurchasesGoods",
|
||||
column: "GoodId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Users_Email",
|
||||
table: "Users",
|
||||
column: "Email",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Users_Login",
|
||||
table: "Users",
|
||||
column: "Login",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "BuildsComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Comments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "GoodComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PurchasesBuilds");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PurchasesGoods");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Builds");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Goods");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Purchases");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,523 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HardwareShopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HardwareShopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(HardwareShopDatabase))]
|
||||
partial class HardwareShopDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
|
||||
{
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ComponentId", "BuildId");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.ToTable("BuildsComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
|
||||
{
|
||||
b.Property<int>("GoodId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("GoodId", "ComponentId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("GoodComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
|
||||
{
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("PurchaseId", "BuildId");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.ToTable("PurchasesBuilds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
|
||||
{
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("GoodId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("PurchaseId", "GoodId");
|
||||
|
||||
b.HasIndex("GoodId");
|
||||
|
||||
b.ToTable("PurchasesGoods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("GoodName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Goods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("GoodId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("GoodId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Role")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Email")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("Login")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("BuildName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("numeric");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Builds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Comments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime?>("DatePurchase")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("PurchaseStatus")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<decimal>("Sum")
|
||||
.HasColumnType("numeric");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
|
||||
.WithMany("Goods")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("GoodId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Good");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("GoodId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
|
||||
.WithMany("Goods")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Good");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Goods")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("GoodId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Good");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
|
||||
.WithMany("Comments")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Comments")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Goods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Comments");
|
||||
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Goods");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
|
||||
{
|
||||
b.Navigation("Comments");
|
||||
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Goods");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace HardwareShopDatabaseImplement.Models.ManyToMany
|
||||
{
|
||||
public class BuildComponent
|
||||
public class ComponentBuild
|
||||
{
|
||||
|
||||
public int BuildId { get; set; }
|
@ -24,11 +24,27 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
||||
public virtual List<GoodComponent> Goods { get; set; } = new();
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<BuildComponent> Builds { get; set; } = new();
|
||||
public virtual List<ComponentBuild> Builds { get; set; } = new();
|
||||
|
||||
public virtual User User { get; set; } = null!;
|
||||
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
private Dictionary<int, (IBuildModel, int)>? _componentsBuilds = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IBuildModel, int)>? ComponentsBuilds
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_componentsBuilds == null)
|
||||
{
|
||||
_componentsBuilds = Builds
|
||||
.ToDictionary(recCB => recCB.BuildId, recCB => (recCB.Build as IBuildModel, recCB.Count));
|
||||
}
|
||||
return _componentsBuilds;
|
||||
}
|
||||
}
|
||||
|
||||
public static Component? Create(HardwareShopDatabase context, ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -39,7 +55,12 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost,
|
||||
UserId = model.UserId
|
||||
UserId = model.UserId,
|
||||
Builds = model.ComponentsBuilds.Select(x => new ComponentBuild
|
||||
{
|
||||
Build = context.Builds.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
@ -59,7 +80,37 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
||||
ComponentName = ComponentName,
|
||||
Cost = Cost,
|
||||
UserId = UserId,
|
||||
UserLogin = User.Login
|
||||
UserLogin = User.Login,
|
||||
ComponentsBuilds = ComponentsBuilds
|
||||
};
|
||||
|
||||
public void UpdateBuilds(HardwareShopDatabase context, ComponentBindingModel model)
|
||||
{
|
||||
var componentBuilds = context.ComponentsBuilds.Where(rec => rec.ComponentId == model.Id).ToList();
|
||||
if (componentBuilds != null && componentBuilds.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.ComponentsBuilds.RemoveRange(componentBuilds.Where(rec => !model.ComponentsBuilds.ContainsKey(rec.BuildId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateBuild in componentBuilds)
|
||||
{
|
||||
updateBuild.Count = model.ComponentsBuilds[updateBuild.BuildId].Item2;
|
||||
model.ComponentsBuilds.Remove(updateBuild.BuildId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var component = context.Components.First(x => x.Id == Id);
|
||||
foreach (var cb in model.ComponentsBuilds)
|
||||
{
|
||||
context.ComponentsBuilds.Add(new ComponentBuild
|
||||
{
|
||||
Component = component,
|
||||
Build = context.Builds.First(x => x.Id == cb.Key),
|
||||
Count = cb.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_componentsBuilds = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
||||
|
||||
public virtual User User { get; set; } = null!;
|
||||
|
||||
private Dictionary<int, (IComponentModel, int)>? _goodComponents = null;
|
||||
private Dictionary<int, (IComponentModel, int)>? _goodsComponents = null;
|
||||
|
||||
[ForeignKey("GoodId")]
|
||||
public virtual List<GoodComponent> Components { get; set; } = new();
|
||||
@ -34,16 +34,16 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
||||
public virtual List<PurchaseGood> Purchases { get; set; } = new();
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> GoodComponents
|
||||
public Dictionary<int, (IComponentModel, int)> GoodsComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_goodComponents == null)
|
||||
if (_goodsComponents == null)
|
||||
{
|
||||
_goodComponents = Components
|
||||
_goodsComponents = Components
|
||||
.ToDictionary(recGC => recGC.ComponentId, recGC => (recGC.Component as IComponentModel, recGC.Count));
|
||||
}
|
||||
return _goodComponents;
|
||||
return _goodsComponents;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,6 +65,10 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
||||
|
||||
public void Update(GoodBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GoodName = model.GoodName;
|
||||
Price = model.Price;
|
||||
}
|
||||
@ -76,16 +80,16 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
||||
Price = Price,
|
||||
UserId = UserId,
|
||||
UserLogin = User.Login,
|
||||
GoodComponents = GoodComponents
|
||||
GoodComponents = GoodsComponents
|
||||
};
|
||||
|
||||
public void UpdateComponents(HardwareShopDatabase context, GoodBindingModel model)
|
||||
{
|
||||
var goodComponents = context.GoodComponents
|
||||
var goodComponents = context.GoodsComponents
|
||||
.Where(rec => rec.GoodId == model.Id).ToList();
|
||||
if (goodComponents != null && goodComponents.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.GoodComponents
|
||||
context.GoodsComponents
|
||||
.RemoveRange(goodComponents
|
||||
.Where(rec => !model.GoodComponents.ContainsKey(rec.ComponentId)));
|
||||
context.SaveChanges();
|
||||
@ -100,7 +104,7 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
||||
var good = context.Goods.First(x => x.Id == Id);
|
||||
foreach (var gc in model.GoodComponents)
|
||||
{
|
||||
context.GoodComponents.Add(new GoodComponent
|
||||
context.GoodsComponents.Add(new GoodComponent
|
||||
{
|
||||
Good = good,
|
||||
Component = context.Components.First(x => x.Id == gc.Key),
|
||||
@ -108,7 +112,7 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_goodComponents = null;
|
||||
_goodsComponents = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace HardwareShopDatabaseImplement.Models.Worker
|
||||
public virtual List<Comment>? Comments { get; set; }
|
||||
|
||||
[ForeignKey("BuildId")]
|
||||
public virtual List<BuildComponent>? Components { get; set; }
|
||||
public virtual List<ComponentBuild>? Components { get; set; }
|
||||
|
||||
|
||||
[ForeignKey("BuildId")]
|
||||
@ -56,7 +56,7 @@ namespace HardwareShopDatabaseImplement.Models.Worker
|
||||
Price = model.Price,
|
||||
BuildName = model.BuildName,
|
||||
UserId = model.UserId,
|
||||
Components = model.BuildComponents.Select(x => new BuildComponent
|
||||
Components = model.BuildComponents.Select(x => new ComponentBuild
|
||||
{
|
||||
Component = context.Components.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
@ -82,10 +82,10 @@ namespace HardwareShopDatabaseImplement.Models.Worker
|
||||
|
||||
public void UpdateComponents(HardwareShopDatabase context, BuildBindingModel model)
|
||||
{
|
||||
var buildComponents = context.BuildsComponents.Where(rec => rec.BuildId == model.Id).ToList();
|
||||
var buildComponents = context.ComponentsBuilds.Where(rec => rec.BuildId == model.Id).ToList();
|
||||
if (buildComponents != null && buildComponents.Count > 0)
|
||||
{ // удалили те в бд, которых нет в модели
|
||||
context.BuildsComponents.RemoveRange(buildComponents.Where(rec => !model.BuildComponents.ContainsKey(rec.ComponentId)));
|
||||
context.ComponentsBuilds.RemoveRange(buildComponents.Where(rec => !model.BuildComponents.ContainsKey(rec.ComponentId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateComponent in buildComponents)
|
||||
@ -99,7 +99,7 @@ namespace HardwareShopDatabaseImplement.Models.Worker
|
||||
//добавляем в бд блюда которые есть в моделе, но ещё нет в бд
|
||||
foreach (var dc in model.BuildComponents)
|
||||
{
|
||||
context.BuildsComponents.Add(new BuildComponent
|
||||
context.ComponentsBuilds.Add(new ComponentBuild
|
||||
{
|
||||
Build = build,
|
||||
Component = context.Components.First(x => x.Id == dc.Key),
|
||||
|
Loading…
Reference in New Issue
Block a user