Фикс продаж + добавление остальных view
This commit is contained in:
parent
689a71b016
commit
932493b9f7
@ -100,7 +100,7 @@ namespace CarCenterBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new InvalidOperationException("Сумма не может быть отрицательной");
|
||||
}
|
||||
_logger.LogInformation("Sale. SaleDateTime:{SaleDateTime}. Sum:{Sum}. CarId:{CarId}. ReceiptId:{ReceiptId}. ConfigurationId:{ConfigurationId}. Id:{Id}", model.SaleDateTime, model.Sum, model.CarId, model.ReceiptId, model.ConfigurationId, model.Id);
|
||||
_logger.LogInformation("Sale. SaleDateTime:{SaleDateTime}. Sum:{Sum}. CarId:{CarId}. Id:{Id}", model.SaleDateTime, model.Sum, model.CarId, model.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ namespace CarCenterContracts.BindingModels
|
||||
public class PresaleBindingModel : IPresaleModel
|
||||
{
|
||||
public int EmployeeId { get; set; }
|
||||
public String Name { get; set; }
|
||||
|
||||
public DateTime PresaleDate { get; set; } = DateTime.Now;
|
||||
|
||||
|
@ -15,10 +15,6 @@ namespace CarCenterContracts.BindingModels
|
||||
public DateTime SaleDateTime { get; set; } = DateTime.Now;
|
||||
|
||||
public int CarId { get; set; }
|
||||
|
||||
public int ReceiptId { get; set; }
|
||||
|
||||
public int ConfigurationId { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ namespace CarCenterContracts.ViewModels
|
||||
|
||||
[DisplayName("Номер работника")]
|
||||
public int EmployeeId { get; set; }
|
||||
[DisplayName("Название")]
|
||||
public String Name { get; set; }
|
||||
[DisplayName("ФИО работника")]
|
||||
public int? TypeOfJobId { get; set; }
|
||||
[DisplayName("Название вида работы")]
|
||||
|
@ -18,12 +18,6 @@ namespace CarCenterContracts.ViewModels
|
||||
public DateTime SaleDateTime {get; set;} = DateTime.Now;
|
||||
[DisplayName("Номер машины")]
|
||||
public int CarId {get; set;}
|
||||
|
||||
[DisplayName("Номер поступления")]
|
||||
public int ReceiptId {get; set;}
|
||||
public int ConfigurationId { get; set; }
|
||||
[DisplayName("Название комплектации")]
|
||||
public string ConfigurationName { get; set; } = string.Empty;
|
||||
public int EmployeeId { get; set; }
|
||||
[DisplayName("ФИО работника")]
|
||||
public string EmployeeName { get; set; } = string.Empty;
|
||||
|
@ -8,6 +8,7 @@ namespace CarCenterDataModels.Models
|
||||
{
|
||||
public interface IPresaleModel : IId
|
||||
{
|
||||
String Name {get;}
|
||||
DateTime PresaleDate { get; }
|
||||
int EmployeeId { get; }
|
||||
int? TypeOfJobId { get; }
|
||||
|
@ -12,7 +12,5 @@ namespace CarCenterDataModels.Models
|
||||
DateTime SaleDateTime { get; }
|
||||
int CarId { get; }
|
||||
int EmployeeId { get; }
|
||||
int ReceiptId { get; }
|
||||
int ConfigurationId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace CarCenterDatabaseImplement.Implements
|
||||
public List<SaleViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
return context.Sales.Include(x => x.Car).Include(x => x.Receipt).Include(x => x.Configuration).Include(x => x.EmployeeId)
|
||||
return context.Sales.Include(x => x.Car).Include(x => x.EmployeeId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -30,7 +30,7 @@ namespace CarCenterDatabaseImplement.Implements
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
return context.Sales.Include(x => x.Car).Include(x => x.Receipt).Include(x => x.Configuration).Include(x => x.EmployeeId)
|
||||
return context.Sales.Include(x => x.Car).Include(x => x.EmployeeId)
|
||||
.Where(x => x.SaleDateTime >= model.DateFrom && x.SaleDateTime <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -38,7 +38,7 @@ namespace CarCenterDatabaseImplement.Implements
|
||||
if (model.EmployeeId.HasValue)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
return context.Sales.Include(x => x.Car).Include(x => x.Receipt).Include(x => x.Configuration).Include(x => x.EmployeeId)
|
||||
return context.Sales.Include(x => x.Car).Include(x => x.Employee)
|
||||
.Where(x => x.EmployeeId == model.EmployeeId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -46,7 +46,7 @@ namespace CarCenterDatabaseImplement.Implements
|
||||
else
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
return context.Sales.Include(x => x.Car).Include(x => x.Receipt).Include(x => x.Configuration).Include(x => x.EmployeeId)
|
||||
return context.Sales.Include(x => x.Car).Include(x => x.EmployeeId)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -59,7 +59,7 @@ namespace CarCenterDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new CarCenterDatabase();
|
||||
return context.Sales.Include(x => x.Car).Include(x => x.Receipt).Include(x => x.Configuration).Include(x => x.EmployeeId)
|
||||
return context.Sales.Include(x => x.Car).Include(x => x.EmployeeId)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
505
CarCenter/CarCenterDatabaseImplement/Migrations/20230520041254_Presale.Designer.cs
generated
Normal file
505
CarCenter/CarCenterDatabaseImplement/Migrations/20230520041254_Presale.Designer.cs
generated
Normal file
@ -0,0 +1,505 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using CarCenterDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(CarCenterDatabase))]
|
||||
[Migration("20230520041254_Presale")]
|
||||
partial class Presale
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Boss", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Bosses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Configuration", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BossId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BossId");
|
||||
|
||||
b.ToTable("Configurations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.ConfigurationCar", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ConfigurationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("ConfigurationId");
|
||||
|
||||
b.ToTable("ConfigurationCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("PresaleDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("TypeOfJobId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.HasIndex("TypeOfJobId");
|
||||
|
||||
b.ToTable("Presales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleCar", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PresaleId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("PresaleId");
|
||||
|
||||
b.ToTable("PresaleCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BossId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ConfigurationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("ReceiptDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<float>("Sum")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BossId");
|
||||
|
||||
b.HasIndex("ConfigurationId");
|
||||
|
||||
b.ToTable("Receipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Sale", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ConfigurationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("SaleDateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<float>("Sum")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("ConfigurationId");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("Sales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.TypeOfJob", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BossId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BossId");
|
||||
|
||||
b.ToTable("TypeOfJobs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.TypeOfJobConfiguration", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConfigurationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TypeOfJobId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConfigurationId");
|
||||
|
||||
b.HasIndex("TypeOfJobId");
|
||||
|
||||
b.ToTable("TypeOfJobConfigurations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany()
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Configuration", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Boss", "Boss")
|
||||
.WithMany()
|
||||
.HasForeignKey("BossId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Boss");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.ConfigurationCar", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Car", "Car")
|
||||
.WithMany("Configurations")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Configuration", "Configuration")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConfigurationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Configuration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany()
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.TypeOfJob", "TypeOfJob")
|
||||
.WithMany()
|
||||
.HasForeignKey("TypeOfJobId");
|
||||
|
||||
b.Navigation("Employee");
|
||||
|
||||
b.Navigation("TypeOfJob");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleCar", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Car", "Car")
|
||||
.WithMany("Presales")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
|
||||
.WithMany("PresaleCars")
|
||||
.HasForeignKey("PresaleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Presale");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Boss", "Boss")
|
||||
.WithMany()
|
||||
.HasForeignKey("BossId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Configuration", "Configuration")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConfigurationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Boss");
|
||||
|
||||
b.Navigation("Configuration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Sale", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Car", "Car")
|
||||
.WithMany()
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Configuration", "Configuration")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConfigurationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany()
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany()
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Configuration");
|
||||
|
||||
b.Navigation("Employee");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.TypeOfJob", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Boss", "Boss")
|
||||
.WithMany()
|
||||
.HasForeignKey("BossId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Boss");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.TypeOfJobConfiguration", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Configuration", "Configuration")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConfigurationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.TypeOfJob", "TypeOfJob")
|
||||
.WithMany("Configurations")
|
||||
.HasForeignKey("TypeOfJobId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Configuration");
|
||||
|
||||
b.Navigation("TypeOfJob");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Navigation("Configurations");
|
||||
|
||||
b.Navigation("Presales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
|
||||
{
|
||||
b.Navigation("PresaleCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.TypeOfJob", b =>
|
||||
{
|
||||
b.Navigation("Configurations");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Presale : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Name",
|
||||
table: "Presales",
|
||||
type: "nvarchar(max)",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Name",
|
||||
table: "Presales");
|
||||
}
|
||||
}
|
||||
}
|
479
CarCenter/CarCenterDatabaseImplement/Migrations/20230520043811_Sales.Designer.cs
generated
Normal file
479
CarCenter/CarCenterDatabaseImplement/Migrations/20230520043811_Sales.Designer.cs
generated
Normal file
@ -0,0 +1,479 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using CarCenterDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(CarCenterDatabase))]
|
||||
[Migration("20230520043811_Sales")]
|
||||
partial class Sales
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Boss", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Bosses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Configuration", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BossId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BossId");
|
||||
|
||||
b.ToTable("Configurations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.ConfigurationCar", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ConfigurationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("ConfigurationId");
|
||||
|
||||
b.ToTable("ConfigurationCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("PresaleDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("TypeOfJobId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.HasIndex("TypeOfJobId");
|
||||
|
||||
b.ToTable("Presales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleCar", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PresaleId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("PresaleId");
|
||||
|
||||
b.ToTable("PresaleCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BossId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ConfigurationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("ReceiptDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<float>("Sum")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BossId");
|
||||
|
||||
b.HasIndex("ConfigurationId");
|
||||
|
||||
b.ToTable("Receipts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Sale", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("SaleDateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<float>("Sum")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Sales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.TypeOfJob", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BossId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BossId");
|
||||
|
||||
b.ToTable("TypeOfJobs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.TypeOfJobConfiguration", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConfigurationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TypeOfJobId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConfigurationId");
|
||||
|
||||
b.HasIndex("TypeOfJobId");
|
||||
|
||||
b.ToTable("TypeOfJobConfigurations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany()
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Configuration", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Boss", "Boss")
|
||||
.WithMany()
|
||||
.HasForeignKey("BossId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Boss");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.ConfigurationCar", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Car", "Car")
|
||||
.WithMany("Configurations")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Configuration", "Configuration")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConfigurationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Configuration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany()
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.TypeOfJob", "TypeOfJob")
|
||||
.WithMany()
|
||||
.HasForeignKey("TypeOfJobId");
|
||||
|
||||
b.Navigation("Employee");
|
||||
|
||||
b.Navigation("TypeOfJob");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleCar", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Car", "Car")
|
||||
.WithMany("Presales")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
|
||||
.WithMany("PresaleCars")
|
||||
.HasForeignKey("PresaleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Presale");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Receipt", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Boss", "Boss")
|
||||
.WithMany()
|
||||
.HasForeignKey("BossId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Configuration", "Configuration")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConfigurationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Boss");
|
||||
|
||||
b.Navigation("Configuration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Sale", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Car", "Car")
|
||||
.WithMany()
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany()
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.TypeOfJob", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Boss", "Boss")
|
||||
.WithMany()
|
||||
.HasForeignKey("BossId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Boss");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.TypeOfJobConfiguration", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Configuration", "Configuration")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConfigurationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.TypeOfJob", "TypeOfJob")
|
||||
.WithMany("Configurations")
|
||||
.HasForeignKey("TypeOfJobId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Configuration");
|
||||
|
||||
b.Navigation("TypeOfJob");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Navigation("Configurations");
|
||||
|
||||
b.Navigation("Presales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
|
||||
{
|
||||
b.Navigation("PresaleCars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.TypeOfJob", b =>
|
||||
{
|
||||
b.Navigation("Configurations");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Sales : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Sales_Configurations_ConfigurationId",
|
||||
table: "Sales");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Sales_Receipts_ReceiptId",
|
||||
table: "Sales");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Sales_ConfigurationId",
|
||||
table: "Sales");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Sales_ReceiptId",
|
||||
table: "Sales");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ConfigurationId",
|
||||
table: "Sales");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ReceiptId",
|
||||
table: "Sales");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ConfigurationId",
|
||||
table: "Sales",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ReceiptId",
|
||||
table: "Sales",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Sales_ConfigurationId",
|
||||
table: "Sales",
|
||||
column: "ConfigurationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Sales_ReceiptId",
|
||||
table: "Sales",
|
||||
column: "ReceiptId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Sales_Configurations_ConfigurationId",
|
||||
table: "Sales",
|
||||
column: "ConfigurationId",
|
||||
principalTable: "Configurations",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Sales_Receipts_ReceiptId",
|
||||
table: "Sales",
|
||||
column: "ReceiptId",
|
||||
principalTable: "Receipts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
@ -164,6 +164,10 @@ namespace CarCenterDatabaseImplement.Migrations
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("PresaleDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
@ -242,15 +246,9 @@ namespace CarCenterDatabaseImplement.Migrations
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ConfigurationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceiptId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("SaleDateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
@ -261,12 +259,8 @@ namespace CarCenterDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.HasIndex("ConfigurationId");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.HasIndex("ReceiptId");
|
||||
|
||||
b.ToTable("Sales");
|
||||
});
|
||||
|
||||
@ -419,31 +413,15 @@ namespace CarCenterDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Configuration", "Configuration")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConfigurationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany()
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Receipt", "Receipt")
|
||||
.WithMany()
|
||||
.HasForeignKey("ReceiptId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Car");
|
||||
|
||||
b.Navigation("Configuration");
|
||||
|
||||
b.Navigation("Employee");
|
||||
|
||||
b.Navigation("Receipt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.TypeOfJob", b =>
|
||||
|
@ -57,6 +57,7 @@ namespace CarCenterDatabaseImplement.Models
|
||||
return new Car()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name=model.Name,
|
||||
Configurations = model.ConfigurationCars.Select(x => new ConfigurationCar
|
||||
{
|
||||
Configuration = context.Configurations.First(y => y.Id == x.Key)
|
||||
@ -71,7 +72,6 @@ namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
}
|
||||
public CarViewModel GetViewModel => new()
|
||||
{
|
||||
|
@ -18,6 +18,7 @@ namespace CarCenterDatabaseImplement.Models
|
||||
public DateTime PresaleDate { get; set; } = DateTime.Now;
|
||||
[Required]
|
||||
public int EmployeeId { get; set; }
|
||||
public String Name { get; set; }
|
||||
public virtual Employee Employee { get; set; } = new();
|
||||
public int? TypeOfJobId {get; set; }
|
||||
public virtual TypeOfJob? TypeOfJob { get; set; }
|
||||
@ -32,6 +33,7 @@ namespace CarCenterDatabaseImplement.Models
|
||||
return new Presale()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
PresaleDate = model.PresaleDate,
|
||||
EmployeeId = model.EmployeeId,
|
||||
Employee = context.Employees.First(x => x.Id == model.EmployeeId)
|
||||
@ -44,11 +46,13 @@ namespace CarCenterDatabaseImplement.Models
|
||||
return;
|
||||
}
|
||||
if (model.TypeOfJobId.HasValue) TypeOfJobId = TypeOfJobId;
|
||||
Name = Name;
|
||||
}
|
||||
public PresaleViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
TypeOfJobId = TypeOfJobId,
|
||||
Name=Name,
|
||||
PresaleDate = PresaleDate,
|
||||
EmployeeId = EmployeeId,
|
||||
EmployeeName = Employee.Surname + " " + Employee.Name + " " + Employee.Patronymic,
|
||||
|
@ -20,10 +20,6 @@ namespace CarCenterDatabaseImplement.Models
|
||||
[Required]
|
||||
public int CarId { get; set; }
|
||||
public virtual Car Car { get; set; } = new();
|
||||
public int ReceiptId { get; set; }
|
||||
public virtual Receipt Receipt { get; set; } = new();
|
||||
public int ConfigurationId { get; set; }
|
||||
public virtual Configuration Configuration { get; set; } = new();
|
||||
public int EmployeeId { get; set; }
|
||||
public virtual Employee Employee { get; set; } = new();
|
||||
public static Sale? Create(CarCenterDatabase context, SaleBindingModel model)
|
||||
@ -39,10 +35,6 @@ namespace CarCenterDatabaseImplement.Models
|
||||
SaleDateTime = model.SaleDateTime,
|
||||
CarId = model.CarId,
|
||||
Car = context.Cars.First(x => x.Id == model.CarId),
|
||||
ReceiptId = model.ReceiptId,
|
||||
Receipt = context.Receipts.First(x => x.Id == model.ReceiptId),
|
||||
ConfigurationId = model.ConfigurationId,
|
||||
Configuration = context.Configurations.First(x => x.Id == model.ConfigurationId),
|
||||
EmployeeId = model.EmployeeId,
|
||||
Employee = context.Employees.First(x => x.Id == model.EmployeeId)
|
||||
};
|
||||
@ -56,10 +48,6 @@ namespace CarCenterDatabaseImplement.Models
|
||||
SaleDateTime = model.SaleDateTime,
|
||||
CarId = model.CarId,
|
||||
Car = context.Cars.First(x => x.Id == model.CarId),
|
||||
ReceiptId = model.ReceiptId,
|
||||
Receipt = context.Receipts.First(x => x.Id == model.ReceiptId),
|
||||
ConfigurationId = model.ConfigurationId,
|
||||
Configuration = context.Configurations.First(x => x.Id == model.ConfigurationId)
|
||||
};
|
||||
}
|
||||
public void Update(SaleBindingModel? model)
|
||||
|
@ -25,7 +25,7 @@ namespace EmployeeApp.Controllers
|
||||
_employeeLogic = employeeLogic;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
public IActionResult Index(String name)
|
||||
{
|
||||
if (APIClient.Employee == null)
|
||||
{
|
||||
@ -131,7 +131,7 @@ namespace EmployeeApp.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreatePresale(int carid)
|
||||
public void CreatePresale(String name)
|
||||
{
|
||||
if (APIClient.Employee == null)
|
||||
{
|
||||
@ -140,6 +140,7 @@ namespace EmployeeApp.Controllers
|
||||
_presaleLogic.Create(new PresaleBindingModel
|
||||
{
|
||||
EmployeeId = APIClient.Employee.Id,
|
||||
Name = name
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
@ -158,7 +159,7 @@ namespace EmployeeApp.Controllers
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateCar(List<int> presales)
|
||||
public void CreateCar(List<int> presales, String name)
|
||||
{
|
||||
if (APIClient.Employee == null)
|
||||
{
|
||||
@ -170,7 +171,7 @@ namespace EmployeeApp.Controllers
|
||||
var presale = _presaleLogic.ReadElement(new PresaleSearchModel { Id = id });
|
||||
if (presale != null) PresaleCars.Add(presale.Id, presale);
|
||||
}
|
||||
_carLogic.Create(new CarBindingModel { EmployeeId = APIClient.Employee.Id, PresaleCars = PresaleCars, });
|
||||
_carLogic.Create(new CarBindingModel { EmployeeId = APIClient.Employee.Id, Name=name, PresaleCars = PresaleCars });
|
||||
Response.Redirect("Cars");
|
||||
}
|
||||
[HttpGet]
|
||||
@ -194,19 +195,19 @@ namespace EmployeeApp.Controllers
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
ViewBag.Cars = _carLogic.ReadList(new CarSearchModel { EmployeeId = APIClient.Employee.Id });
|
||||
ViewBag.Cars = _carLogic.ReadList(new CarSearchModel { EmployeeId = APIClient.Employee.Id});
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateSale(string sum, int carid)
|
||||
public void CreateSale(string sum, int car)
|
||||
{
|
||||
if (APIClient.Employee == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
|
||||
_saleLogic.Create(new SaleBindingModel { EmployeeId = APIClient.Employee.Id, Sum = (float)Convert.ToDouble(sum), CarId = carid });
|
||||
Response.Redirect("Transfers");
|
||||
_saleLogic.Create(new SaleBindingModel { EmployeeId = APIClient.Employee.Id, Sum = (float)Convert.ToDouble(sum), CarId=car });
|
||||
Response.Redirect("Sales");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,28 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@using CarCenterContracts.ViewModels
|
||||
|
||||
@model CarViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Car";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1>Машина №@Model.Id</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
}
|
||||
<h3 class="display-4">Название @Model.Name</h3>
|
||||
<h3 class="display-4">Работник: @Model.EmployeeName</h3>
|
||||
<h3 class="display-4">Предпродажные работы:</h3>
|
||||
@foreach (var presale in Model.PresaleCars){
|
||||
<h5 class="display-4"><b>Предпродажная работа №@presale.Value.Id</b>, от @presale.Value.PresaleDate</h5>
|
||||
}
|
||||
</div>
|
||||
|
@ -1,5 +1,62 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@using CarCenterContracts.ViewModels
|
||||
|
||||
@model List<CarViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Cars";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Машины</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateCar">Создать машину</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер машины
|
||||
</th>
|
||||
<th>
|
||||
Название машины
|
||||
</th>
|
||||
<th>
|
||||
ФИО работника
|
||||
</th>
|
||||
<th>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.EmployeeName)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Car" asp-route-id="@item.Id">Посмотреть</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -6,9 +6,11 @@
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Название машины:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" /></div>
|
||||
<div class="col-4">Предпродажные работы:</div>
|
||||
<div class="col-8">
|
||||
<select id="deals" name="deals" class="form-control" multiple asp-items="@(new SelectList(@ViewBag.Deals,"Id", "DealDate"))"></select>
|
||||
<select id="presales" name="presales" class="form-control" multiple asp-items="@(new SelectList(@ViewBag.Presales,"Id", "PresaleDate"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -1,13 +1,13 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateDeal";
|
||||
ViewData["Title"] = "CreatePresale";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание сделки</h2>
|
||||
<h2 class="display-4">Создание предпродажной работы</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">ID машины:</div>
|
||||
<div class="col-8"><input type="text" name="carid" id="carid" /></div>
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
|
@ -20,7 +20,7 @@
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateDeal">Создать предпродажную работу</a>
|
||||
<a asp-action="CreatePresale">Создать предпродажную работу</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
@ -29,10 +29,10 @@
|
||||
Номер предпродажной работы
|
||||
</th>
|
||||
<th>
|
||||
ФИО работника
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Вид работы
|
||||
ФИО работника
|
||||
</th>
|
||||
<th>
|
||||
Дата
|
||||
@ -47,10 +47,10 @@
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.EmployeeName)
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.TypeOfJobName)
|
||||
@Html.DisplayFor(modelItem => item.EmployeeName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PresaleDate)
|
||||
|
@ -20,7 +20,7 @@
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateTransfer">Создать продажу</a>
|
||||
<a asp-action="CreateSale">Создать продажу</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
Loading…
Reference in New Issue
Block a user