diff --git a/ServiceStation/ServiceStationBusinessLogic/BusinessLogic/WorkClientLogic.cs b/ServiceStation/ServiceStationBusinessLogic/BusinessLogic/WorkClientLogic.cs new file mode 100644 index 0000000..5b39bca --- /dev/null +++ b/ServiceStation/ServiceStationBusinessLogic/BusinessLogic/WorkClientLogic.cs @@ -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 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("Нет такой работы или такого клиента"); + } + } + } +} diff --git a/ServiceStation/ServiceStationContracts/BusinessLogic/IWorkClientLogic.cs b/ServiceStation/ServiceStationContracts/BusinessLogic/IWorkClientLogic.cs new file mode 100644 index 0000000..2e7a18e --- /dev/null +++ b/ServiceStation/ServiceStationContracts/BusinessLogic/IWorkClientLogic.cs @@ -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); + } +} diff --git a/ServiceStation/ServiceStationContracts/StorageContracts/IWorkClientStorage.cs b/ServiceStation/ServiceStationContracts/StorageContracts/IWorkClientStorage.cs new file mode 100644 index 0000000..8a254f3 --- /dev/null +++ b/ServiceStation/ServiceStationContracts/StorageContracts/IWorkClientStorage.cs @@ -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); + } +} diff --git a/ServiceStation/ServiceStationContracts/StorageContracts/WorkClientBindingModel.cs b/ServiceStation/ServiceStationContracts/StorageContracts/WorkClientBindingModel.cs new file mode 100644 index 0000000..24276d2 --- /dev/null +++ b/ServiceStation/ServiceStationContracts/StorageContracts/WorkClientBindingModel.cs @@ -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; } + } +} diff --git a/ServiceStation/ServiceStationRestAPI/Controllers/MainController.cs b/ServiceStation/ServiceStationRestAPI/Controllers/MainController.cs index 9cb85ed..4f03015 100644 --- a/ServiceStation/ServiceStationRestAPI/Controllers/MainController.cs +++ b/ServiceStation/ServiceStationRestAPI/Controllers/MainController.cs @@ -4,6 +4,7 @@ using ServiceStationBusinessLogic.MailKitWorker; using ServiceStationContracts.BindingModels; using ServiceStationContracts.BusinessLogic; using ServiceStationContracts.SearchModels; +using ServiceStationContracts.StorageContracts; using ServiceStationContracts.ViewModels; namespace ServiceStationRestAPI.Controllers { @@ -17,17 +18,20 @@ namespace ServiceStationRestAPI.Controllers { private readonly IReportLogic _reportLogic; private readonly ITaskLogic _taskLogic; private readonly IWorkLogic _workLogic; + private readonly IWorkClientLogic _workClientLogic; private readonly AbstractMailWorker _mailWorker; public MainController(ILogger 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; _clientLogic = clientLogic; _executorLogic = executorLogic; _reportLogic = reportLogic; _taskLogic = taskLogic; _workLogic = workLogic; + _workClientLogic = workClientLogic; _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)] public List Make_Report_Ids(string _ids) { @@ -232,6 +245,5 @@ namespace ServiceStationRestAPI.Controllers { throw; } } - } } diff --git a/ServiceStation/ServiceStationRestAPI/Program.cs b/ServiceStation/ServiceStationRestAPI/Program.cs index ed969da..b9913a1 100644 --- a/ServiceStation/ServiceStationRestAPI/Program.cs +++ b/ServiceStation/ServiceStationRestAPI/Program.cs @@ -23,6 +23,7 @@ namespace ServiceStationRestAPI { builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); + builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); @@ -33,6 +34,7 @@ namespace ServiceStationRestAPI { builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); + builder.Services.AddTransient(); builder.Services.AddSingleton(); diff --git a/ServiceStation/ServiceStationRestAPI/ServiceStationRestAPI.csproj b/ServiceStation/ServiceStationRestAPI/ServiceStationRestAPI.csproj index 1cd778c..4f536a8 100644 --- a/ServiceStation/ServiceStationRestAPI/ServiceStationRestAPI.csproj +++ b/ServiceStation/ServiceStationRestAPI/ServiceStationRestAPI.csproj @@ -8,6 +8,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/ServiceStation/ServiceStationsDataBaseImplement/DataBase.cs b/ServiceStation/ServiceStationsDataBaseImplement/DataBase.cs index 7736724..4e260aa 100644 --- a/ServiceStation/ServiceStationsDataBaseImplement/DataBase.cs +++ b/ServiceStation/ServiceStationsDataBaseImplement/DataBase.cs @@ -14,7 +14,7 @@ namespace ServiceStationsDataBaseImplement { 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); } diff --git a/ServiceStation/ServiceStationsDataBaseImplement/Implements/WorkClientStorage.cs b/ServiceStation/ServiceStationsDataBaseImplement/Implements/WorkClientStorage.cs new file mode 100644 index 0000000..80a55dc --- /dev/null +++ b/ServiceStation/ServiceStationsDataBaseImplement/Implements/WorkClientStorage.cs @@ -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; + } + } +} diff --git a/ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240820063305_InitMigration.Designer.cs b/ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240820063305_InitMigration.Designer.cs new file mode 100644 index 0000000..aabcd2e --- /dev/null +++ b/ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240820063305_InitMigration.Designer.cs @@ -0,0 +1,193 @@ +// +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 + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Login") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Executors"); + }); + + modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.TaskByWork", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tasks"); + }); + + modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("ExecutorId") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("TaskId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ExecutorId"); + + b.ToTable("Works"); + }); + + modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("PointCount") + .HasColumnType("int"); + + b.Property("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 + } + } +} diff --git a/ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240820063305_InitMigration.cs b/ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240820063305_InitMigration.cs new file mode 100644 index 0000000..a53ccd6 --- /dev/null +++ b/ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240820063305_InitMigration.cs @@ -0,0 +1,141 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ServiceStationsDataBaseImplement.Migrations +{ + /// + public partial class InitMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Clients", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FIO = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + Login = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Clients", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Executors", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + FIO = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Executors", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Tasks", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Tasks", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Works", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Date = table.Column(type: "datetime2", nullable: false), + Price = table.Column(type: "float", nullable: false), + ExecutorId = table.Column(type: "int", nullable: false), + TaskId = table.Column(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(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + WorkId = table.Column(type: "int", nullable: false), + ClientId = table.Column(type: "int", nullable: false), + PointCount = table.Column(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"); + } + + /// + 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"); + } + } +} diff --git a/ServiceStation/ServiceStationsDataBaseImplement/Migrations/DatabaseModelSnapshot.cs b/ServiceStation/ServiceStationsDataBaseImplement/Migrations/DatabaseModelSnapshot.cs new file mode 100644 index 0000000..7f914d0 --- /dev/null +++ b/ServiceStation/ServiceStationsDataBaseImplement/Migrations/DatabaseModelSnapshot.cs @@ -0,0 +1,190 @@ +// +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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Login") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Executors"); + }); + + modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.TaskByWork", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tasks"); + }); + + modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("ExecutorId") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("TaskId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ExecutorId"); + + b.ToTable("Works"); + }); + + modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("PointCount") + .HasColumnType("int"); + + b.Property("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 + } + } +} diff --git a/ServiceStation/ServiceStationsDataBaseImplement/Models/WorkClient.cs b/ServiceStation/ServiceStationsDataBaseImplement/Models/WorkClient.cs index ef9d050..04fa5a7 100644 --- a/ServiceStation/ServiceStationsDataBaseImplement/Models/WorkClient.cs +++ b/ServiceStation/ServiceStationsDataBaseImplement/Models/WorkClient.cs @@ -1,4 +1,5 @@ -using System; +using ServiceStationContracts.StorageContracts; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; @@ -15,8 +16,17 @@ namespace ServiceStationsDataBaseImplement.Models { [Required] public int ClientId { get; set; } + public int PointCount { get; set; } public virtual Work _work { 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; + } + } }