сделала возможными нулл поля SymptomId в таблице препаратов и CourseId в таблице рецептов, а еще допилила форму создания рецептов

This commit is contained in:
Елена Бакальская 2024-05-01 00:29:07 +04:00
parent 739ff21163
commit e136d71b67
14 changed files with 56 additions and 37 deletions

View File

@ -5,11 +5,9 @@ namespace PolyclinicContracts.BindingModels
public class MedicamentBindingModel : IMedicamentModel public class MedicamentBindingModel : IMedicamentModel
{ {
public int Id { get; set; } public int Id { get; set; }
public int SymptomId { get; set; } public int? SymptomId { get; set; }
public int ProcedureId { get; set; } public int ProcedureId { get; set; }
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty; public string Comment { get; set; } = string.Empty;
public Dictionary<int, ISymptomModel> MedicamentSymptomes { get; set; } = new();
public Dictionary<int, IProcedureModel> MedicamentProcedures { get; set; } = new();
} }
} }

View File

@ -5,7 +5,7 @@ namespace PolyclinicContracts.BindingModels
public class RecipeBindingModel : IRecipeModel public class RecipeBindingModel : IRecipeModel
{ {
public int Id { get; set; } public int Id { get; set; }
public int CourseId { get; set; } public int? CourseId { get; set; }
public int ProceduresCount { get; set; } public int ProceduresCount { get; set; }
public string Comment { get; set; } = string.Empty; public string Comment { get; set; } = string.Empty;
public Dictionary<int, IProcedureModel> RecipeProcedures { get; } = new(); public Dictionary<int, IProcedureModel> RecipeProcedures { get; } = new();

View File

@ -7,7 +7,7 @@ namespace PolyclinicContracts.ViewModels
{ {
public int Id { get; set; } public int Id { get; set; }
public int ProcedureId { get; set; } public int ProcedureId { get; set; }
public int SymptomId { get; set; } public int? SymptomId { get; set; }
[DisplayName("Название медикамента")] [DisplayName("Название медикамента")]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[DisplayName("Комментарий")] [DisplayName("Комментарий")]

View File

@ -12,7 +12,7 @@ namespace PolyclinicContracts.ViewModels
[DisplayName("Комментарий")] [DisplayName("Комментарий")]
public string Comment { get; set; } = string.Empty; public string Comment { get; set; } = string.Empty;
public int CourseId { get; set; } public int? CourseId { get; set; }
public Dictionary<int, IProcedureModel> RecipeProcedures { get; } = new(); public Dictionary<int, IProcedureModel> RecipeProcedures { get; } = new();
} }
} }

View File

@ -5,6 +5,6 @@
string Name { get; } string Name { get; }
string Comment { get; } string Comment { get; }
int ProcedureId { get; } int ProcedureId { get; }
int SymptomId { get; } int? SymptomId { get; }
} }
} }

View File

@ -4,7 +4,7 @@
{ {
int ProceduresCount { get; set; } int ProceduresCount { get; set; }
string Comment { get; set; } string Comment { get; set; }
int CourseId { get; set; } int? CourseId { get; set; }
Dictionary<int, IProcedureModel> RecipeProcedures { get; } Dictionary<int, IProcedureModel> RecipeProcedures { get; }
} }
} }

View File

@ -1,4 +1,5 @@
// <auto-generated /> // <auto-generated />
using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata;
@ -11,8 +12,8 @@ using SecuritySystemDatabaseImplement;
namespace PolyclinicDatabaseImplement.Migrations namespace PolyclinicDatabaseImplement.Migrations
{ {
[DbContext(typeof(PolyclinicDatabase))] [DbContext(typeof(PolyclinicDatabase))]
[Migration("20240430185032_InitDatabase")] [Migration("20240430202621_InitCreate")]
partial class InitDatabase partial class InitCreate
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -115,7 +116,8 @@ namespace PolyclinicDatabaseImplement.Migrations
b.Property<int>("ProcedureId") b.Property<int>("ProcedureId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("SymptomId") b.Property<int?>("SymptomId")
.IsRequired()
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -163,7 +165,7 @@ namespace PolyclinicDatabaseImplement.Migrations
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int>("CourseId") b.Property<int?>("CourseId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("ProceduresCount") b.Property<int>("ProceduresCount")
@ -347,9 +349,7 @@ namespace PolyclinicDatabaseImplement.Migrations
{ {
b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course") b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course")
.WithMany() .WithMany()
.HasForeignKey("CourseId") .HasForeignKey("CourseId");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Course"); b.Navigation("Course");
}); });

View File

@ -5,7 +5,7 @@
namespace PolyclinicDatabaseImplement.Migrations namespace PolyclinicDatabaseImplement.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class InitDatabase : Migration public partial class InitCreate : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
@ -78,7 +78,7 @@ namespace PolyclinicDatabaseImplement.Migrations
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
ProceduresCount = table.Column<int>(type: "int", nullable: false), ProceduresCount = table.Column<int>(type: "int", nullable: false),
Comment = table.Column<string>(type: "nvarchar(max)", nullable: false), Comment = table.Column<string>(type: "nvarchar(max)", nullable: false),
CourseId = table.Column<int>(type: "int", nullable: false) CourseId = table.Column<int>(type: "int", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@ -87,8 +87,7 @@ namespace PolyclinicDatabaseImplement.Migrations
name: "FK_Recipes_Courses_CourseId", name: "FK_Recipes_Courses_CourseId",
column: x => x.CourseId, column: x => x.CourseId,
principalTable: "Courses", principalTable: "Courses",
principalColumn: "Id", principalColumn: "Id");
onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(

View File

@ -1,4 +1,5 @@
// <auto-generated /> // <auto-generated />
using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata;
@ -112,7 +113,8 @@ namespace PolyclinicDatabaseImplement.Migrations
b.Property<int>("ProcedureId") b.Property<int>("ProcedureId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("SymptomId") b.Property<int?>("SymptomId")
.IsRequired()
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -160,7 +162,7 @@ namespace PolyclinicDatabaseImplement.Migrations
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int>("CourseId") b.Property<int?>("CourseId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("ProceduresCount") b.Property<int>("ProceduresCount")
@ -344,9 +346,7 @@ namespace PolyclinicDatabaseImplement.Migrations
{ {
b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course") b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course")
.WithMany() .WithMany()
.HasForeignKey("CourseId") .HasForeignKey("CourseId");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Course"); b.Navigation("Course");
}); });

View File

@ -20,7 +20,7 @@ namespace PolyclinicDatabaseImplement.Models
public int ProcedureId { get; set; } public int ProcedureId { get; set; }
[Required] [Required]
public int SymptomId { get; set; } public int? SymptomId { get; set; }
public virtual Symptom? Symptom { get; set; } public virtual Symptom? Symptom { get; set; }
public virtual Procedure? Procedure { get; set; } public virtual Procedure? Procedure { get; set; }
@ -49,7 +49,7 @@ namespace PolyclinicDatabaseImplement.Models
Name = Name, Name = Name,
Comment = Comment, Comment = Comment,
ProcedureId = ProcedureId, ProcedureId = ProcedureId,
SymptomId = SymptomId SymptomId = Symptom?.Id ?? null
}; };
} }
} }

View File

@ -16,7 +16,7 @@ namespace PolyclinicDatabaseImplement.Models
[Required] [Required]
public string Comment { get; set; } = string.Empty; public string Comment { get; set; } = string.Empty;
public int CourseId { get; set; } public int? CourseId { get; set; }
public virtual Course Course { get; set; } = new(); public virtual Course Course { get; set; } = new();
private Dictionary<int, IProcedureModel>? _recipeProcedures = null; private Dictionary<int, IProcedureModel>? _recipeProcedures = null;
@ -64,7 +64,7 @@ namespace PolyclinicDatabaseImplement.Models
Id = Id, Id = Id,
ProceduresCount = ProceduresCount, ProceduresCount = ProceduresCount,
Comment = Comment, Comment = Comment,
CourseId = CourseId, CourseId = Course?.Id ?? null,
}; };
public void UpdateProcedures(PolyclinicDatabase database, RecipeBindingModel bindingModel) public void UpdateProcedures(PolyclinicDatabase database, RecipeBindingModel bindingModel)

View File

@ -20,8 +20,4 @@
<ProjectReference Include="..\PolyclinicDataModels\PolyclinicDataModels.csproj" /> <ProjectReference Include="..\PolyclinicDataModels\PolyclinicDataModels.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project> </Project>

View File

@ -6,6 +6,13 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.16">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\PolyclinicBusinessLogic\PolyclinicBusinessLogic.csproj" /> <ProjectReference Include="..\PolyclinicBusinessLogic\PolyclinicBusinessLogic.csproj" />
<ProjectReference Include="..\PolyclinicContracts\PolyclinicContracts.csproj" /> <ProjectReference Include="..\PolyclinicContracts\PolyclinicContracts.csproj" />

View File

@ -15,22 +15,41 @@
<h3 class="col-3"> <h3 class="col-3">
Количество процедур: Количество процедур:
</h3> </h3>
<input class="col-6" type="text" /> <input class="col-6" type="text" style="width: 45vh" />
</div> </div>
<div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center"> <div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center">
<h3 class="col-3"> <h3 class="col-3">
Комментарий: Комментарий:
</h3> </h3>
<textarea class="col-6" id="comment" name="comment"> <textarea class="col-6" id="comment" name="comment" style="width: 45vh">
</textarea> </textarea>
</div> </div>
<div class="d-flex flex-row mb-5"> @* <div class="d-flex flex-row mb-5 flex-row justify-content-between align-items-center">
<select id="procedure" name="procedure" class="form-control"> <h3 class="col-3">
<option value="">Выберите процедуру/ы</option> Курс приема препарата:
</h3>
<select id="courseId" name="courseId" style="width: 45vh">
<option value="">Выберите курс приема</option>
@{
int countCourse = 10;
for (int i = 0; i < countCourse; i++)
{
<option value="@i">Курс составляет @i дней, имя у него @i</option>
}
}
</select>
</div> *@
<div class="d-flex flex-row mb-5 justify-content-between align-items-center">
<h3 class="col-3">
Выбор процедуры:
</h3>
<select id="procedureId" name="procedureId" style="width: 45vh">
@* <option value="">Выберите процедуру/ы</option> *@
@{ @{
int count = 3; int count = 3;
for (int i = 1; i <= count; i++) for (int i = 1; i <= count; i++)