Merge pull request 'ЛЮТО ЗАФИГАЧИЛ ВОТ Я ЛЕГЕНДА ТОЖЕ' (#18) from sagirovFINAL into main

Reviewed-on: #18
This commit is contained in:
Marselchii 2024-05-29 20:35:48 +04:00
commit d69a9f5f4d
19 changed files with 200 additions and 1115 deletions

View File

@ -23,5 +23,7 @@ namespace CarCenterContracts.BindingModels
public double Sum { get; set; }
public Dictionary<int, IPresaleModel> OrderPresales { get; set; } = new();
}
public Dictionary<int, ICarModel> Cars { get; set; } = new();
}
}

View File

@ -21,6 +21,6 @@ namespace CarCenterContracts.BindingModels
public double Price { get; set; }
public Dictionary<int, IBundlingModel> PresaleBundlings { get; set; } = new();
public List<int> RequestIds { get; set; } = new();
public Dictionary<int, IRequestModel> Requests { get; set; } = new();
}
}

View File

@ -26,5 +26,6 @@ namespace CarCenterContracts.ViewModels
[DisplayName("Сумма")]
public double Sum { get; set; }
public Dictionary<int, IPresaleModel> OrderPresales { get; set; } = new();
}
public Dictionary<int, ICarModel> Cars { get; set; } = new();
}
}

View File

@ -21,6 +21,6 @@ namespace CarCenterContracts.ViewModels
[DisplayName("Цена")]
public double Price { get; set; }
public Dictionary<int, IBundlingModel> PresaleBundlings { get; set; } = new();
public List<IRequestModel> Requests { get; set; } = new();
public Dictionary<int, IRequestModel> Requests { get; set; } = new();
}
}

View File

@ -99,7 +99,7 @@ namespace CarCenterDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.Id.HasValue)
else if (model.WorkerId.HasValue)
{
return context.Orders
.Where(x => x.WorkerId == model.WorkerId)
@ -107,7 +107,6 @@ namespace CarCenterDatabaseImplement.Implements
.Include(x => x.Cars)
.Include(x => x.Presales)
.ThenInclude(x => x.Presale)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -103,6 +103,8 @@ namespace CarCenterDatabaseImplement.Implements
return null;
}
order.Update(model);
order.UpdateBundlings(context, model);
order.UpdateBundlings(context, model);
context.SaveChanges();
return context.Presales
.Include(x => x.Bundlings)

View File

@ -1,505 +0,0 @@
// <auto-generated />
using System;
using CarCenterDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CarCenterDatabaseImplement.Migrations
{
[DbContext(typeof(CarCenterDatabase))]
[Migration("20240528191551_InitFull")]
partial class InitFull
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.29")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Bundling", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("EquipmentPackage")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.Property<int>("TirePackage")
.HasColumnType("integer");
b.Property<int>("ToolKit")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Bundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CarBrand")
.HasColumnType("integer");
b.Property<int>("CarClass")
.HasColumnType("integer");
b.Property<int>("FeatureID")
.HasColumnType("integer");
b.Property<int?>("FeatureId")
.HasColumnType("integer");
b.Property<string>("Model")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("OrderId")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.Property<long>("VINnumber")
.HasColumnType("bigint");
b.Property<int>("Year")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("FeatureId");
b.HasIndex("OrderId");
b.HasIndex("StorekeeperId");
b.ToTable("Cars");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.CarBundling", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BundlingId")
.HasColumnType("integer");
b.Property<int>("CarId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("BundlingId");
b.HasIndex("CarId");
b.ToTable("CarBundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Feature", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("CabinColor")
.IsRequired()
.HasColumnType("text");
b.Property<int>("DriveType")
.HasColumnType("integer");
b.Property<int>("HelpDevice")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Features");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("BuyerFCS")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("PaymentDate")
.HasColumnType("timestamp without time zone");
b.Property<int>("PaymentStatus")
.HasColumnType("integer");
b.Property<int>("PaymentType")
.HasColumnType("integer");
b.Property<double>("Sum")
.HasColumnType("double precision");
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("WorkerId");
b.ToTable("Orders");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.OrderPresale", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("OrderId")
.HasColumnType("integer");
b.Property<int>("PresaleId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("PresaleId");
b.ToTable("OrderPresales");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DueTill")
.HasColumnType("timestamp without time zone");
b.Property<int>("PresaleStatus")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Presales");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleBundling", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BundlingId")
.HasColumnType("integer");
b.Property<int>("PresaleId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("BundlingId");
b.HasIndex("PresaleId");
b.ToTable("PresaleBundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Request", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("PresaleId")
.HasColumnType("integer");
b.Property<int>("RequestType")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PresaleId");
b.ToTable("Requests");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Storekeeper", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.HasColumnType("text");
b.Property<long>("PhoneNumber")
.HasColumnType("bigint");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Storekeepers");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Worker", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.HasColumnType("text");
b.Property<long>("PhoneNumber")
.HasColumnType("bigint");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Workers");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Feature", "Feature")
.WithMany("Cars")
.HasForeignKey("FeatureId");
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
.WithMany("Cars")
.HasForeignKey("OrderId");
b.HasOne("CarCenterDatabaseImplement.Models.Storekeeper", "Storekeeper")
.WithMany("Cars")
.HasForeignKey("StorekeeperId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Feature");
b.Navigation("Order");
b.Navigation("Storekeeper");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.CarBundling", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Bundling", "Bundling")
.WithMany("CarBundling")
.HasForeignKey("BundlingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarCenterDatabaseImplement.Models.Car", "Car")
.WithMany("Bundlings")
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Bundling");
b.Navigation("Car");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Worker", "Worker")
.WithMany("Orders")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Worker");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.OrderPresale", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
.WithMany("Presales")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
.WithMany("OrderPresales")
.HasForeignKey("PresaleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
b.Navigation("Presale");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleBundling", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Bundling", "Bundling")
.WithMany("PresaleBundling")
.HasForeignKey("BundlingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
.WithMany("Bundlings")
.HasForeignKey("PresaleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Bundling");
b.Navigation("Presale");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Request", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
.WithMany("Requests")
.HasForeignKey("PresaleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Presale");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Bundling", b =>
{
b.Navigation("CarBundling");
b.Navigation("PresaleBundling");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
{
b.Navigation("Bundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Feature", b =>
{
b.Navigation("Cars");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
{
b.Navigation("Cars");
b.Navigation("Presales");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
{
b.Navigation("Bundlings");
b.Navigation("OrderPresales");
b.Navigation("Requests");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Storekeeper", b =>
{
b.Navigation("Cars");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Worker", b =>
{
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,19 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CarCenterDatabaseImplement.Migrations
{
public partial class InitFull : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -1,511 +0,0 @@
// <auto-generated />
using System;
using CarCenterDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CarCenterDatabaseImplement.Migrations
{
[DbContext(typeof(CarCenterDatabase))]
[Migration("20240529141913_ababa4")]
partial class ababa4
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.29")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Bundling", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<int>("EquipmentPackage")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.Property<int>("TirePackage")
.HasColumnType("integer");
b.Property<int>("ToolKit")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Bundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CarBrand")
.HasColumnType("integer");
b.Property<int>("CarClass")
.HasColumnType("integer");
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<int>("FeatureID")
.HasColumnType("integer");
b.Property<int?>("FeatureId")
.HasColumnType("integer");
b.Property<string>("Model")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("OrderId")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.Property<long>("VINnumber")
.HasColumnType("bigint");
b.Property<int>("Year")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("FeatureId");
b.HasIndex("OrderId");
b.HasIndex("StorekeeperId");
b.ToTable("Cars");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.CarBundling", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BundlingId")
.HasColumnType("integer");
b.Property<int>("CarId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("BundlingId");
b.HasIndex("CarId");
b.ToTable("CarBundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Feature", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("CabinColor")
.IsRequired()
.HasColumnType("text");
b.Property<int>("DriveType")
.HasColumnType("integer");
b.Property<int>("HelpDevice")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("StorekeeperId")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Features");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("BuyerFCS")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("PaymentDate")
.HasColumnType("timestamp without time zone");
b.Property<int>("PaymentStatus")
.HasColumnType("integer");
b.Property<int>("PaymentType")
.HasColumnType("integer");
b.Property<double>("Sum")
.HasColumnType("double precision");
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("WorkerId");
b.ToTable("Orders");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.OrderPresale", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("OrderId")
.HasColumnType("integer");
b.Property<int>("PresaleId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("PresaleId");
b.ToTable("OrderPresales");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DueTill")
.HasColumnType("timestamp without time zone");
b.Property<int>("PresaleStatus")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Presales");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleBundling", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BundlingId")
.HasColumnType("integer");
b.Property<int>("PresaleId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("BundlingId");
b.HasIndex("PresaleId");
b.ToTable("PresaleBundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Request", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("PresaleId")
.HasColumnType("integer");
b.Property<int>("RequestType")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PresaleId");
b.ToTable("Requests");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Storekeeper", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.HasColumnType("text");
b.Property<long>("PhoneNumber")
.HasColumnType("bigint");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Storekeepers");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Worker", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.HasColumnType("text");
b.Property<long>("PhoneNumber")
.HasColumnType("bigint");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Workers");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Feature", "Feature")
.WithMany("Cars")
.HasForeignKey("FeatureId");
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
.WithMany("Cars")
.HasForeignKey("OrderId");
b.HasOne("CarCenterDatabaseImplement.Models.Storekeeper", "Storekeeper")
.WithMany("Cars")
.HasForeignKey("StorekeeperId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Feature");
b.Navigation("Order");
b.Navigation("Storekeeper");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.CarBundling", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Bundling", "Bundling")
.WithMany("CarBundling")
.HasForeignKey("BundlingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarCenterDatabaseImplement.Models.Car", "Car")
.WithMany("Bundlings")
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Bundling");
b.Navigation("Car");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Worker", "Worker")
.WithMany("Orders")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Worker");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.OrderPresale", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
.WithMany("Presales")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
.WithMany("OrderPresales")
.HasForeignKey("PresaleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
b.Navigation("Presale");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleBundling", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Bundling", "Bundling")
.WithMany("PresaleBundling")
.HasForeignKey("BundlingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
.WithMany("Bundlings")
.HasForeignKey("PresaleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Bundling");
b.Navigation("Presale");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Request", b =>
{
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
.WithMany("Requests")
.HasForeignKey("PresaleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Presale");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Bundling", b =>
{
b.Navigation("CarBundling");
b.Navigation("PresaleBundling");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
{
b.Navigation("Bundlings");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Feature", b =>
{
b.Navigation("Cars");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
{
b.Navigation("Cars");
b.Navigation("Presales");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
{
b.Navigation("Bundlings");
b.Navigation("OrderPresales");
b.Navigation("Requests");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Storekeeper", b =>
{
b.Navigation("Cars");
});
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Worker", b =>
{
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace CarCenterDatabaseImplement.Migrations
{
[DbContext(typeof(CarCenterDatabase))]
[Migration("20240529134131_FixTest")]
partial class FixTest
[Migration("20240529143434_preFin")]
partial class preFin
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -32,6 +32,9 @@ namespace CarCenterDatabaseImplement.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<int>("EquipmentPackage")
.HasColumnType("integer");
@ -66,6 +69,9 @@ namespace CarCenterDatabaseImplement.Migrations
b.Property<int>("CarClass")
.HasColumnType("integer");
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<int>("FeatureID")
.HasColumnType("integer");

View File

@ -6,11 +6,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace CarCenterDatabaseImplement.Migrations
{
<<<<<<<< HEAD:CarCenter/CarCenterDatabaseImplement/Migrations/20240529134131_FixTest.cs
public partial class FixTest : Migration
========
public partial class ababa4 : Migration
>>>>>>>> d89e50b210935777ba7b3d61880ea7525a5955b5:CarCenter/CarCenterDatabaseImplement/Migrations/20240529141913_ababa4.cs
public partial class preFin : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{

View File

@ -49,7 +49,7 @@ namespace CarCenterDatabaseImplement.Models
{
return null;
}
return new Order()
var order = new Order()
{
Id = model.Id,
WorkerId = model.WorkerId,
@ -60,9 +60,20 @@ namespace CarCenterDatabaseImplement.Models
Sum = model.Sum,
Presales = model.OrderPresales.Select(x => new OrderPresale
{
Presale = context.Presales.First(y => y.Id == x.Key)
Presale = context.Presales.First(y => y.Id == x.Value.Id)
}).ToList()
};
foreach (var car in model.Cars)
{
var cartmp = context.Cars.FirstOrDefault(x => x.Id == car.Value.Id);
if (cartmp != null)
{
order.Cars.Add(cartmp);
}
}
return order;
}
public void Update(OrderBindingModel? model)
@ -101,7 +112,8 @@ namespace CarCenterDatabaseImplement.Models
BuyerFCS = BuyerFCS,
PaymentDate = PaymentDate,
Sum = Sum,
OrderPresales = OrderPresales
};
OrderPresales = OrderPresales,
Cars = Cars.ToDictionary(x => x.Id, x => x as ICarModel),
};
}
}

View File

@ -49,7 +49,7 @@ namespace CarCenterDatabaseImplement.Models
{
return null;
}
var presale = new Presale()
var presale = new Presale()
{
Id = model.Id,
PresaleStatus = model.PresaleStatus,
@ -59,16 +59,16 @@ namespace CarCenterDatabaseImplement.Models
WorkerId = model.WorkerId,
Bundlings = model.PresaleBundlings.Select(x => new PresaleBundling
{
Bundling = context.Bundlings.First(y => y.Id == x.Key)
Bundling = context.Bundlings.First(y => y.Id == x.Value.Id)
}).ToList()
};
foreach (var requestId in model.RequestIds)
foreach (var request in model.Requests)
{
var request = context.Requests.FirstOrDefault(x => x.Id == requestId);
if (request != null)
var requesttmp = context.Requests.FirstOrDefault(x => x.Id == request.Value.Id);
if (requesttmp != null)
{
presale.Requests.Add(request);
presale.Requests.Add(requesttmp);
}
}
@ -78,25 +78,29 @@ namespace CarCenterDatabaseImplement.Models
public void UpdateBundlings(CarCenterDatabase context, PresaleBindingModel model)
{
var presale = context.Presales.First(x => x.Id == Id);
foreach (var pc in model.PresaleBundlings)
{
context.PresaleBundlings.Add(new PresaleBundling
{
Presale = presale,
Bundling = context.Bundlings.First(x => x.Id == pc.Key),
});
context.SaveChanges();
}
_presaleBundlings = null;
}
public void AddRequests(CarCenterDatabase context, List<int> requestIds)
foreach (var request in model.Requests)
{
var requesttmp = context.Requests.FirstOrDefault(x => x.Id == request.Value.Id);
if (requesttmp != null)
{
presale.Requests.Add(requesttmp);
}
}
}
public void UpdateRequests(CarCenterDatabase context, PresaleBindingModel model)
{
var presale = context.Presales.First(x => x.Id == Id);
foreach (var requestId in requestIds)
foreach (var pc in model.PresaleBundlings)
{
var request = context.Requests.First(x => x.Id == requestId);
presale.Requests.Add(request);
context.PresaleBundlings.Add(new PresaleBundling
{
Presale = presale,
Bundling = context.Bundlings.First(x => x.Id == pc.Value.Id),
});
context.SaveChanges();
}
_presaleBundlings = null;
}
public void Update(PresaleBindingModel? model)
{
@ -108,7 +112,8 @@ namespace CarCenterDatabaseImplement.Models
Price = model.Price;
DueTill = model.DueTill;
PresaleStatus = model.PresaleStatus;
}
}
public PresaleViewModel GetViewModel => new()
{
@ -118,6 +123,7 @@ namespace CarCenterDatabaseImplement.Models
DueTill = DueTill,
Price = Price,
PresaleBundlings = PresaleBundlings,
Requests = Requests.ToDictionary(x => x.Id, x => x as IRequestModel),
};
}
}

View File

@ -5,7 +5,6 @@ using CarCenterContracts.StoragesContracts;
using CarCenterContracts.SearchModels;
using CarCenterBusinessLogic.MailWorker;
using CarCenterBusinessLogic.OfficePackage;
using ImplementerApp;
namespace StorekeeperApp
{

View File

@ -158,7 +158,7 @@ namespace CarCenterWorkerApp.Controllers
return View(new PresaleViewModel());
}
[HttpPost]
public IActionResult CreatePresale(PresaleBindingModel model,int[] bundlingIds)
public IActionResult CreatePresale(PresaleBindingModel model,int[] bundlingIds, int[] requestIds)
{
var bundlings = _data.GetBundlings();
for (int i = 0; i < bundlingIds.Length; i++)
@ -167,8 +167,12 @@ namespace CarCenterWorkerApp.Controllers
model.PresaleBundlings.Add(i, bundling);
}
var requests = _data.GetRequests(UserWorker.user!.Id);
model.RequestIds = model.RequestIds.Where(id => requests.Any(r => r.Id == id)).ToList();
for (int i = 0; i < requestIds.Length; i++)
{
var request = requests!.FirstOrDefault(x => x.Id == requestIds[i])!;
model.Requests.Add(i, request);
}
model.WorkerId = UserWorker.user!.Id;
bool changed = false;
if (model.PresaleBundlings.Count > 0)
{
@ -189,6 +193,76 @@ namespace CarCenterWorkerApp.Controllers
return View(model);
}
}
[HttpGet]
public IActionResult IndexOrder()
{
if (UserWorker.user != null)
{
var productions = _data.GetOrders(UserWorker.user.Id);
return View(productions);
}
return RedirectToAction("IndexNonReg");
}
[HttpPost]
public IActionResult IndexOrder(int id)
{
_data.DeleteOrder(id);
return RedirectToAction("IndexOrder");
}
[HttpGet]
public IActionResult CreateOrder(int id)
{
var cars = _data.GetCars();
var presales = _data.GetPresales(UserWorker.user!.Id);
ViewBag.AllCars = cars;
ViewBag.AllPresales = presales;
if (id != 0)
{
var value = _data.GetOrder(id);
if (value != null)
return View(value);
}
return View(new OrderViewModel());
}
[HttpPost]
public IActionResult CreateOrder(OrderBindingModel model, int[] carIds, int[] presaleIds, string Sum)
{
var cars = _data.GetCars();
for (int i = 0; i < carIds.Length; i++)
{
var car = cars!.FirstOrDefault(x => x.Id == carIds[i])!;
model.Cars.Add(i, car);
}
var presales = _data.GetPresales(UserWorker.user!.Id);
for (int i = 0; i < presaleIds.Length; i++)
{
var presale = presales!.FirstOrDefault(x => x.Id == presaleIds[i])!;
model.OrderPresales.Add(i, presale);
}
model.WorkerId = UserWorker.user!.Id;
if(double.TryParse(Sum, out double val))
{
model.Sum = val;
}
bool changed = false;
if (model.OrderPresales.Count > 0)
{
if (model.Id != 0)
{
changed = _data.UpdateOrder(model);
}
else
{
changed = _data.CreateOrder(model);
}
}
if (changed)
return RedirectToAction("IndexOrder");
else
{
ViewBag.AllCars = cars;
return View(model);
}
}
}
}

View File

@ -6,6 +6,7 @@
@{
ViewData["Title"] = "CreateOrder";
ViewBag.Presales = Model.OrderPresales;
ViewBag.Cars = Model.Cars;
}
<div class="text-center">
<h2 class="display-4">Создание заказа</h2>
@ -23,6 +24,21 @@
<span id="PaymentTypeError" class="text-danger"></span>
</div>
</div>
@if (Model.Id != 0)
{
<div class="row">
<div class="col-4">Статус оплаты:</div>
<div class="col-8">
<select name="PaymentStatus" id="PaymentStatus" value="@Model.PaymentStatus">
@foreach (var value in Enum.GetValues(typeof(PaymentStatus)))
{
<option value="@value">@value</option>
}
</select>
<span id="PaymentStatusError" class="text-danger"></span>
</div>
</div>
}
<div class="row">
<div class="col-4">ФИО покупателя:</div>
<div class="col-8">
@ -30,10 +46,6 @@
<span id="BuyerFCSError" class="text-danger"></span>
</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="container">
<div>Предпродажные работы</div>
<div class="table-responsive-lg">
@ -67,10 +79,10 @@
<option value="">Выберите работу</option>
@foreach (var presale in ViewBag.AllPresales)
{
<option value="@presale.Id" data-price="@presale.Price">Комплектация @presale.Id</option>
<option value="@presale.Id" data-price="@presale.Price">Работа @presale.Id</option>
}
</select>
<button type="button" id="addPresale" class="btn btn-secondary">Добавить комплектацию</button>
<button type="button" id="addPresale" class="btn btn-secondary">Добавить работу</button>
</div>
<div class="container">
<div>Машины</div>
@ -105,14 +117,14 @@
<option value="">Выберите машину</option>
@foreach (var car in ViewBag.AllCars)
{
<option value="@car.Id" data-price="@car.Price">Комплектация @car.Id</option>
<option value="@car.Id" data-price="@car.Price">Машина @car.Id</option>
}
</select>
<button type="button" id="addCar" class="btn btn-secondary">Добавить комплектацию</button>
<button type="button" id="addCar" class="btn btn-secondary">Добавить машину</button>
</div>
<div class="row">
<div class="col-4">Сумма:</div>
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
<div class="col-8"><input type="text" id="Sum" name="Sum" readonly /></div>
</div>
<div class="row">
<div class="col-8"></div>
@ -125,16 +137,16 @@
<script>
$(document).ready(function () {
function updateSum() {
var sum = 0;
var Sum = 0;
$('#presalesTable tbody tr').each(function () {
var pricebd = $(this).find('.presale-price').data('price');
sum += parseFloat(pricebd);
Sum += parseFloat(pricebd);
});
$('#carsTable tbody tr').each(function () {
var pricecar = $(this).find('.car-price').data('price');
sum += parseFloat(pricecar);
Sum += parseFloat(pricecar);
});
$('#sum').val(sum.toFixed(2));
$('#Sum').val(Sum.toFixed(2));
}
$(document).on('click', '.deleteCar', function () {
@ -242,10 +254,12 @@
$('#orderForm').submit(function (event) {
var PaymentType = $('#PaymentType').val();
var PaymentStatus = $('#PaymentStatus').val();
var BuyerFCS = $('#BuyerFCS').val();
var isValid = true;
$('#PaymentTypeError').text('');
$('#PaymentStatusError').text('');
$('#BuyerFCSError').text('');
var totalCars = $('#carsTable tbody tr').length;
if (totalCars == 0) {

View File

@ -6,11 +6,13 @@
@{
ViewData["Title"] = "CreatePresale";
ViewBag.Bundlings = Model.PresaleBundlings;
ViewBag.Requests = Model.Requests;
}
<div class="text-center">
<h2 class="display-4">Создание предпродажной работы</h2>
</div>
<form id="presaleForm" method="post">
@if (Model.Id != 0){
<div class="row">
<div class="col-4">Статус:</div>
<div class="col-8">
@ -23,6 +25,7 @@
<span id="PresaleStatusError" class="text-danger"></span>
</div>
</div>
}
<div class="row">
<div class="col-4">Описание:</div>
<div class="col-8">
@ -66,7 +69,7 @@
<option value="">Выберите пожелания</option>
@foreach (var request in ViewBag.AllRequests)
{
<option value="@request.Id" data-price="@request.Price">Пожелание @request.Id</option>
<option value="@request.Id" data-request="@request.Id">Пожелание @request.Id</option>
}
</select>
<button type="button" id="addRequest" class="btn btn-secondary">Добавить пожелание</button>
@ -202,13 +205,13 @@
}
});
$('#addPresale').click(function () {
var selectedPresale = $('#presaleSelect option:selected');
if (selectedPresale.val()) {
var presaleId = selectedPresale.val();
$('#addRequest').click(function () {
var selectedRequest = $('#requestSelect option:selected');
if (selectedRequest.val()) {
var requestId = selectedRequest.val();
var exists = false;
$('#presalesTable tbody tr').each(function () {
if ($(this).data('presale-id') == presaleId) {
$('#requestsTable tbody tr').each(function () {
if ($(this).data('request-id') == requestId) {
exists = true;
return false;
}
@ -218,28 +221,27 @@
return;
}
var presaleName = selectedPresale.text();
var presalePrice = selectedPresale.data('price');
var requestName = selectedRequest.text();
var newRow = `
<tr data-presale-id="${presaleId}">
<tr data-request-id="${requestId}">
<td>
<input type="hidden" name="presaleIds" value="${presaleId}" />
${presaleId}
<input type="hidden" name="requestIds" value="${requestId}" />
${requestId}
</td>
<th> </th>
<td><button type="button" class="deletePresale" data-presale-id="${presaleId}">Удалить</button></td>
<td><button type="button" class="deleteRequest" data-request-id="${requestId}">Удалить</button></td>
</tr>
`;
$('#presalesTable tbody').append(newRow);
$('#requestsTable tbody').append(newRow);
$('.deletePresale').off('click').on('click', function () {
$('.deleteRequest').off('click').on('click', function () {
var row = $(this).closest('tr');
row.remove();
updateSum();
});
$('#presaleSelect').val('');
$('#requestSelect').val('');
updateSum();
} else {
@ -264,8 +266,8 @@
isValid = false;
}
var totalPresales = $('#presalesTable tbody tr').length;
if (totalPresales == 0) {
var totalRequests = $('#requestsTable tbody tr').length;
if (totalRequests == 0) {
alert('Пожалуйста, добавьте хотя бы одно пожелание.');
isValid = false;
}

View File

@ -21,13 +21,13 @@
<div class="row">
<div class="col-4">Тип пожелания:</div>
<div class="col-8">
<select name="Type" id="Type" value="@Model.RequestType">
<select name="RequestType" id="RequestType" value="@Model.RequestType">
@foreach (var value in Enum.GetValues(typeof(RequestTypes)))
{
<option value="@value">@value</option>
}
</select>
<span id="TypeError" class="text-danger"></span>
<span id="RequestTypeError" class="text-danger"></span>
</div>
</div>
<div class="row">
@ -40,10 +40,10 @@
<script>
$(document).ready(function () {
$('#requestForm').submit(function (event) {
var Type = $('#Type').val();
var RequestType = $('#RequestType').val();
var Description = $('#Description').val();
var isValid = true;
$('#TypeError').text('');
$('#RequestTypeError').text('');
$('#DescriptionError').text('');

View File

@ -14,9 +14,10 @@ namespace WorkerApp
private readonly IPresaleLogic _presaleLogic;
private readonly IRequestLogic _requestLogic;
private readonly IOrderLogic _orderLogic;
private readonly ICarLogic _carLogic;
private readonly IBundlingLogic _bundlingLogic;
public WorkerData(ILogger<WorkerData> logger, IWorkerLogic storekeeperLogic, IPresaleLogic presaleLogic, IRequestLogic requestLogic, IOrderLogic orderLogic, IBundlingLogic bundlingLogic)
public WorkerData(ILogger<WorkerData> logger, IWorkerLogic storekeeperLogic, IPresaleLogic presaleLogic, IRequestLogic requestLogic, IOrderLogic orderLogic, IBundlingLogic bundlingLogic, ICarLogic carLogic)
{
_logger = logger;
_storekeeperLogic = storekeeperLogic;
@ -24,6 +25,7 @@ namespace WorkerApp
_requestLogic = requestLogic;
_orderLogic = orderLogic;
_bundlingLogic = bundlingLogic;
_carLogic = carLogic;
}
public WorkerViewModel? Login(string email, string password)
@ -107,5 +109,10 @@ namespace WorkerApp
{
return _bundlingLogic.ReadList(null);
}
public List<CarViewModel>? GetCars()
{
return _carLogic.ReadList(null);
}
}
}