сделала возможными нулл поля 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 int Id { get; set; }
public int SymptomId { get; set; }
public int? SymptomId { get; set; }
public int ProcedureId { get; set; }
public string Name { 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 int Id { get; set; }
public int CourseId { get; set; }
public int? CourseId { get; set; }
public int ProceduresCount { get; set; }
public string Comment { get; set; } = string.Empty;
public Dictionary<int, IProcedureModel> RecipeProcedures { get; } = new();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,6 +6,13 @@
<ImplicitUsings>enable</ImplicitUsings>
</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>
<ProjectReference Include="..\PolyclinicBusinessLogic\PolyclinicBusinessLogic.csproj" />
<ProjectReference Include="..\PolyclinicContracts\PolyclinicContracts.csproj" />

View File

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