AddclientPoints method
This commit is contained in:
parent
506aac2e22
commit
9bf9ca9874
@ -0,0 +1,46 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ServiceStationContracts.BusinessLogic;
|
||||||
|
using ServiceStationContracts.StorageContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ServiceStationBusinessLogic.BusinessLogic {
|
||||||
|
public class WorkClientLogic : IWorkClientLogic {
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IWorkClientStorage _storage;
|
||||||
|
private readonly IWorkStorage _workStorage;
|
||||||
|
private readonly IClientStorage _clientStorage;
|
||||||
|
|
||||||
|
public WorkClientLogic(ILogger<WorkClientLogic> logger, IWorkClientStorage storage, IWorkStorage workStorage, IClientStorage clientStorage) {
|
||||||
|
_logger = logger;
|
||||||
|
_storage = storage;
|
||||||
|
_workStorage = workStorage;
|
||||||
|
_clientStorage = clientStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Add_Points(WorkClientBindingModel model) {
|
||||||
|
CheckModel(model);
|
||||||
|
if (!_storage.Add_Points(model)) {
|
||||||
|
_logger.LogWarning("Add_Points operatin failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(WorkClientBindingModel model) {
|
||||||
|
if (model.Point_count < 0) {
|
||||||
|
throw new ArgumentNullException("Нельзя ставить отрицательное количество баллов");
|
||||||
|
}
|
||||||
|
var work = _workStorage.GetElement(new ServiceStationContracts.SearchModels.WorkSearchModel { Id = model.Work_Id });
|
||||||
|
var client = _clientStorage.GetElement(new ServiceStationContracts.SearchModels.ClientSearchModel { Id = model.Client_Id });
|
||||||
|
|
||||||
|
if (work == null || client == null) {
|
||||||
|
throw new ArgumentNullException("Нет такой работы или такого клиента");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using ServiceStationContracts.StorageContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ServiceStationContracts.BusinessLogic {
|
||||||
|
public interface IWorkClientLogic {
|
||||||
|
bool Add_Points(WorkClientBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ServiceStationContracts.StorageContracts {
|
||||||
|
public interface IWorkClientStorage {
|
||||||
|
bool Add_Points(WorkClientBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ServiceStationContracts.StorageContracts {
|
||||||
|
public class WorkClientBindingModel {
|
||||||
|
public int Work_Id { get; set; }
|
||||||
|
public int Client_Id { get; set; }
|
||||||
|
public int Point_count { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ using ServiceStationBusinessLogic.MailKitWorker;
|
|||||||
using ServiceStationContracts.BindingModels;
|
using ServiceStationContracts.BindingModels;
|
||||||
using ServiceStationContracts.BusinessLogic;
|
using ServiceStationContracts.BusinessLogic;
|
||||||
using ServiceStationContracts.SearchModels;
|
using ServiceStationContracts.SearchModels;
|
||||||
|
using ServiceStationContracts.StorageContracts;
|
||||||
using ServiceStationContracts.ViewModels;
|
using ServiceStationContracts.ViewModels;
|
||||||
|
|
||||||
namespace ServiceStationRestAPI.Controllers {
|
namespace ServiceStationRestAPI.Controllers {
|
||||||
@ -17,17 +18,20 @@ namespace ServiceStationRestAPI.Controllers {
|
|||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
private readonly ITaskLogic _taskLogic;
|
private readonly ITaskLogic _taskLogic;
|
||||||
private readonly IWorkLogic _workLogic;
|
private readonly IWorkLogic _workLogic;
|
||||||
|
private readonly IWorkClientLogic _workClientLogic;
|
||||||
|
|
||||||
private readonly AbstractMailWorker _mailWorker;
|
private readonly AbstractMailWorker _mailWorker;
|
||||||
|
|
||||||
public MainController(ILogger<MainController> logger, IClientLogic clientLogic, IExecutorLogic executorLogic,
|
public MainController(ILogger<MainController> logger, IClientLogic clientLogic, IExecutorLogic executorLogic,
|
||||||
IReportLogic reportLogic, ITaskLogic taskLogic, IWorkLogic workLogic, AbstractMailWorker mailWorker) {
|
IReportLogic reportLogic, ITaskLogic taskLogic, IWorkLogic workLogic, IWorkClientLogic workClientLogic,
|
||||||
|
AbstractMailWorker mailWorker) {
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_clientLogic = clientLogic;
|
_clientLogic = clientLogic;
|
||||||
_executorLogic = executorLogic;
|
_executorLogic = executorLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
_taskLogic = taskLogic;
|
_taskLogic = taskLogic;
|
||||||
_workLogic = workLogic;
|
_workLogic = workLogic;
|
||||||
|
_workClientLogic = workClientLogic;
|
||||||
_mailWorker = mailWorker;
|
_mailWorker = mailWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +171,16 @@ namespace ServiceStationRestAPI.Controllers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo Post method -- AddClientPoints
|
[HttpPost]
|
||||||
|
public void AddClientPoints(WorkClientBindingModel model) {
|
||||||
|
try {
|
||||||
|
_workClientLogic.Add_Points(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, "Ошибка добавления баллов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ApiExplorerSettings(IgnoreApi = true)]
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public List<int> Make_Report_Ids(string _ids) {
|
public List<int> Make_Report_Ids(string _ids) {
|
||||||
@ -232,6 +245,5 @@ namespace ServiceStationRestAPI.Controllers {
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ namespace ServiceStationRestAPI {
|
|||||||
builder.Services.AddTransient<IExecutorStorage, ExecutorStorage>();
|
builder.Services.AddTransient<IExecutorStorage, ExecutorStorage>();
|
||||||
builder.Services.AddTransient<ITaskStorage, TaskStorage>();
|
builder.Services.AddTransient<ITaskStorage, TaskStorage>();
|
||||||
builder.Services.AddTransient<IWorkStorage, WorkStorage>();
|
builder.Services.AddTransient<IWorkStorage, WorkStorage>();
|
||||||
|
builder.Services.AddTransient<IWorkClientStorage, WorkClientStorage>();
|
||||||
|
|
||||||
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
@ -33,6 +34,7 @@ namespace ServiceStationRestAPI {
|
|||||||
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
builder.Services.AddTransient<ITaskLogic, TaskLogic>();
|
builder.Services.AddTransient<ITaskLogic, TaskLogic>();
|
||||||
builder.Services.AddTransient<IWorkLogic, WorkLogic>();
|
builder.Services.AddTransient<IWorkLogic, WorkLogic>();
|
||||||
|
builder.Services.AddTransient<IWorkClientLogic, WorkClientLogic>();
|
||||||
|
|
||||||
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||||
|
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.19" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.19" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.15">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Serilog" Version="4.0.1" />
|
<PackageReference Include="Serilog" Version="4.0.1" />
|
||||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||||
|
@ -14,7 +14,7 @@ namespace ServiceStationsDataBaseImplement
|
|||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured == false)
|
if (optionsBuilder.IsConfigured == false)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-E2VPEN3\SQLEXPRESS;Initial Catalog=ServiceStationDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer(@"Data Source=WIN-4HUIDGH3G02\SQLEXPRESS;Initial Catalog=ServiceStationDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
using ServiceStationContracts.StorageContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ServiceStationsDataBaseImplement.Implements {
|
||||||
|
public class WorkClientStorage : IWorkClientStorage {
|
||||||
|
public bool Add_Points(WorkClientBindingModel model) {
|
||||||
|
using var context = new Database();
|
||||||
|
var rec = context.WorksClients.FirstOrDefault(x => x.WorkId == model.Work_Id && x.ClientId == model.Client_Id);
|
||||||
|
if (rec == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var ans = rec.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
193
ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240820063305_InitMigration.Designer.cs
generated
Normal file
193
ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240820063305_InitMigration.Designer.cs
generated
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using ServiceStationsDataBaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ServiceStationsDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Database))]
|
||||||
|
[Migration("20240820063305_InitMigration")]
|
||||||
|
partial class InitMigration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.18")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("FIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Login")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("FIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Executors");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.TaskByWork", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Tasks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("ExecutorId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<int>("TaskId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ExecutorId");
|
||||||
|
|
||||||
|
b.ToTable("Works");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PointCount")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("WorkId");
|
||||||
|
|
||||||
|
b.ToTable("WorksClients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Executor", null)
|
||||||
|
.WithMany("Works")
|
||||||
|
.HasForeignKey("ExecutorId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Client", "_client")
|
||||||
|
.WithMany("WorkClients")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Work", "_work")
|
||||||
|
.WithMany("WorkClients")
|
||||||
|
.HasForeignKey("WorkId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("_client");
|
||||||
|
|
||||||
|
b.Navigation("_work");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("WorkClients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Works");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("WorkClients");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,141 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ServiceStationsDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitMigration : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Clients",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
FIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Login = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Executors",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
FIO = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Executors", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Tasks",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Tasks", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Works",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
|
Price = table.Column<double>(type: "float", nullable: false),
|
||||||
|
ExecutorId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
TaskId = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Works", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Works_Executors_ExecutorId",
|
||||||
|
column: x => x.ExecutorId,
|
||||||
|
principalTable: "Executors",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "WorksClients",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
WorkId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
PointCount = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_WorksClients", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_WorksClients_Clients_ClientId",
|
||||||
|
column: x => x.ClientId,
|
||||||
|
principalTable: "Clients",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_WorksClients_Works_WorkId",
|
||||||
|
column: x => x.WorkId,
|
||||||
|
principalTable: "Works",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Works_ExecutorId",
|
||||||
|
table: "Works",
|
||||||
|
column: "ExecutorId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_WorksClients_ClientId",
|
||||||
|
table: "WorksClients",
|
||||||
|
column: "ClientId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_WorksClients_WorkId",
|
||||||
|
table: "WorksClients",
|
||||||
|
column: "WorkId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Tasks");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "WorksClients");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Works");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Executors");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,190 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using ServiceStationsDataBaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ServiceStationsDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Database))]
|
||||||
|
partial class DatabaseModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.18")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("FIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Login")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("FIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Executors");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.TaskByWork", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Tasks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("ExecutorId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<int>("TaskId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ExecutorId");
|
||||||
|
|
||||||
|
b.ToTable("Works");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PointCount")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("WorkId");
|
||||||
|
|
||||||
|
b.ToTable("WorksClients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Executor", null)
|
||||||
|
.WithMany("Works")
|
||||||
|
.HasForeignKey("ExecutorId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Client", "_client")
|
||||||
|
.WithMany("WorkClients")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Work", "_work")
|
||||||
|
.WithMany("WorkClients")
|
||||||
|
.HasForeignKey("WorkId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("_client");
|
||||||
|
|
||||||
|
b.Navigation("_work");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("WorkClients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Works");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("WorkClients");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using ServiceStationContracts.StorageContracts;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -15,8 +16,17 @@ namespace ServiceStationsDataBaseImplement.Models {
|
|||||||
[Required]
|
[Required]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
|
public int PointCount { get; set; }
|
||||||
|
|
||||||
public virtual Work _work { get; set; } = new();
|
public virtual Work _work { get; set; } = new();
|
||||||
public virtual Client _client { get; set; } = new();
|
public virtual Client _client { get; set; } = new();
|
||||||
|
|
||||||
|
public bool Update(WorkClientBindingModel? model) {
|
||||||
|
if (model == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PointCount += model.Point_count;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user