слил
This commit is contained in:
commit
84d8c3dc4a
@ -49,6 +49,24 @@ namespace PlumbingRepairClientApp
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<T?> GetRequestStudentsAsync<T>(string requestUrl)
|
||||
{
|
||||
var response = await _client.GetAsync(requestUrl);
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var settings = new JsonSerializerSettings
|
||||
{
|
||||
Converters = new List<JsonConverter> { new TeacherConverter() }
|
||||
};
|
||||
return JsonConvert.DeserializeObject<T>(result, settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<T?> GetRequestAsync<T>(string requestUrl)
|
||||
{
|
||||
var response = await _client.GetAsync(requestUrl);
|
||||
|
@ -1,10 +1,12 @@
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PlumbingRepairClientApp;
|
||||
using System.Diagnostics;
|
||||
using UniversityClientAppWorker.Models;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDatabaseImplement.Models;
|
||||
using UniversityDataModels.Enums;
|
||||
using UniversityDataModels.Models;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
@ -231,7 +233,7 @@ namespace UniversityClientAppWorker.Controllers
|
||||
return View(APIClient.GetRequest<List<StudentViewModel>>($"api/student/getstudents?userId={APIClient.User.Id}"));
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateStudent(string name, int planOfStudy, string phoneNumber)
|
||||
public async Task<IActionResult> CreateStudent(string name, int planOfStudy, string phoneNumber)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
@ -241,14 +243,84 @@ namespace UniversityClientAppWorker.Controllers
|
||||
{
|
||||
throw new Exception("Ââåäèòå ÔÈÎ, ïëàí îáó÷åíèÿ è òåëåôîí");
|
||||
}
|
||||
var PlanOfStudy = await APIClient.GetRequestPlanOfStudyAsync<PlanOfStudyViewModel>($"api/planofstudys/getplanofstudy?id={planOfStudy}");
|
||||
if(PlanOfStudy == null)
|
||||
{
|
||||
throw new Exception("Ïëàí îáó÷åíèÿ íå íàéäåí");
|
||||
}
|
||||
APIClient.PostRequest("api/student/createstudent", new StudentBindingModel
|
||||
{
|
||||
UserId = APIClient.User.Id,
|
||||
Name = name,
|
||||
PlanOfStudyId = planOfStudy,
|
||||
PlanOfStudyProfile = PlanOfStudy.Profile,
|
||||
PhoneNumber = phoneNumber,
|
||||
|
||||
});
|
||||
return Redirect("/Home/Students");
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> InfoStudent(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
if(id == 0)
|
||||
{
|
||||
throw new Exception("id íå ìîæåò áûòü 0");
|
||||
}
|
||||
var planOfStudys = await APIClient.GetRequestPlanOfStudyAsync<List<PlanOfStudyViewModel>>
|
||||
($"api/planofstudys/getplanofstudys?userId={APIClient.User.Id}");
|
||||
ViewBag.PlanOfStudys = planOfStudys;
|
||||
var obj = APIClient.GetRequest<StudentViewModel>($"api/student/getstudent?userId={APIClient.User.Id}&studentId={id}");
|
||||
return View(obj);
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> UpdateStudent(int id, string name, int planOfStudy, string phoneNumber)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
if(id == 0)
|
||||
{
|
||||
throw new Exception("id íå ìîæåò áûòü 0");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || planOfStudy == 0 || string.IsNullOrEmpty(phoneNumber))
|
||||
{
|
||||
throw new Exception("Ââåäèòå ÔÈÎ, ïëàí îáó÷åíèÿ è òåëåôîí");
|
||||
}
|
||||
var PlanOfStudy = await APIClient.GetRequestPlanOfStudyAsync<PlanOfStudyViewModel>($"api/planofstudys/getplanofstudy?id={planOfStudy}");
|
||||
if (PlanOfStudy == null)
|
||||
{
|
||||
throw new Exception("Ïëàí îáó÷åíèÿ íå íàéäåí");
|
||||
}
|
||||
APIClient.PostRequest("api/student/updatestudent", new StudentBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
PlanOfStudyId = planOfStudy,
|
||||
PlanOfStudyProfile = PlanOfStudy.Profile,
|
||||
PhoneNumber = phoneNumber,
|
||||
});
|
||||
return Redirect("/Home/Students");
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteStudent(int id)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
if (id == 0)
|
||||
{
|
||||
throw new Exception("id íå ìîæåò áûòü 0");
|
||||
}
|
||||
APIClient.PostRequest("api/student/deletestudent", new StudentBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
Response.Redirect("Students");
|
||||
}
|
||||
[HttpGet]
|
||||
|
@ -15,6 +15,6 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Вход" class="btn btndanger" /></div>
|
||||
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -7,9 +7,16 @@
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<form asp-action="ReportPlanOfStudys" method="get">
|
||||
<input type="submit" value="Отчёт по планам обучения" class="btn btn-info" />
|
||||
</form>
|
||||
<form asp-action="ReportPlanOfStudyAndStudents" method="get">
|
||||
<input type="submit" value="Сведения по планам обучения" class="btn btn-secondary" />
|
||||
</form>
|
||||
</div>
|
||||
<form asp-action="CreatePlanOfStudy" method="post">
|
||||
<div class="row">
|
||||
<div class="row mt-2">
|
||||
<div class="col-4">Профиль:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="profile" id="profile" class="form-control" />
|
||||
@ -49,9 +56,9 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Profile</th>
|
||||
<th>FormOfStudy</th>
|
||||
<th>Actions</th>
|
||||
<th>Профиль</th>
|
||||
<th>Форма обучения</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -1,10 +1,10 @@
|
||||
@using UniversityContracts.ViewModels
|
||||
@model AttestationViewModel
|
||||
@{
|
||||
ViewData["Title"] = "План обучения";
|
||||
ViewData["Title"] = "Аттестация";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||
<h2 class="display-4">@ViewData["Title"] - @Model.Id</h2>
|
||||
</div>
|
||||
<form asp-action="UpdateAttestation" method="post">
|
||||
<div class="row">
|
||||
@ -32,8 +32,11 @@
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4 mt-2">
|
||||
<form asp-action="Attestations">
|
||||
<input type="submit" value="Отмена" class="btn btn-primary" />
|
||||
</form>
|
||||
<input type="hidden" name="id" value="@Model.Id" />
|
||||
<input type="submit" value="Сохранить" class="btn btn-primary" />
|
||||
<input type="submit" value="Сохранить" class="btn btn-danger" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -4,7 +4,7 @@
|
||||
ViewData["Title"] = "План обучения";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||
<h2 class="display-4">@ViewData["Title"] - @Model.Id</h2>
|
||||
</div>
|
||||
<form asp-action="UpdatePlanOfStudy" method="post">
|
||||
<div class="row">
|
||||
@ -33,6 +33,9 @@
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<form asp-action="Index">
|
||||
<input type="submit" value="Отмена" class="btn btn-primary" />
|
||||
</form>
|
||||
<input type="hidden" name="id" value="@Model.Id" />
|
||||
<input type="submit" value="Сохранить" class="btn btn-danger" />
|
||||
</div>
|
||||
|
@ -0,0 +1,39 @@
|
||||
@using UniversityContracts.ViewModels
|
||||
@model StudentViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Студент";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">@ViewData["Title"] - @Model.Id</h2>
|
||||
</div>
|
||||
<form asp-action="UpdateStudent" method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" id="name" class="form-control" value="@Model.Name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">План обучения:</div>
|
||||
<div class="col-8">
|
||||
<select name="planOfStudy" id="planOfStudy" class="form-control" asp-items="@(new SelectList(ViewBag.PlanOfStudys, "Id", "Profile", Model.PlanOfStudyId))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Номер телефона:</div>
|
||||
<div class="col-8">
|
||||
<input id="phoneNumber" name="phoneNumber" class="form-control" value="@Model.PhoneNumber"></input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4 mt-2">
|
||||
<form asp-action="Students">
|
||||
<input type="submit" value="Отмена" class="btn btn-primary" />
|
||||
</form>
|
||||
<input type="hidden" name="id" value="@Model.Id" />
|
||||
<input type="submit" value="Сохранить" class="btn btn-danger" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -21,6 +21,6 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-danger" /></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -14,7 +14,7 @@
|
||||
<div class="col-4 mt-2">
|
||||
<form method="post">
|
||||
<input type="hidden" name="type" value="pdf" />
|
||||
<input type="submit" value="Отправить в формате Pdf на почту" class="btn btn-primary" />
|
||||
<input type="submit" value="Отправить в формате Pdf на почту" class="btn btn-secondary" />
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-4 mt-2">
|
||||
|
@ -24,7 +24,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Номер телефона:</div>
|
||||
<div class="col-8">
|
||||
<textarea id="phoneNumber" name="phoneNumber" class="form-control"></textarea>
|
||||
<input id="phoneNumber" name="phoneNumber" class="form-control"></input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -56,15 +56,15 @@
|
||||
@Html.DisplayFor(modelItem => student.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => student.PlanOfStudyId)
|
||||
@Html.DisplayFor(modelItem => student.PlanOfStudyProfile)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => student.PhoneNumber)
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<a asp-controller="Home" asp-action="" asp-route-id="@student.Id" class="btn btn-warning">Изменить</a>
|
||||
<form asp-controller="Home" asp-action="DeletePlanOfStudy" method="post">
|
||||
<a asp-controller="Home" asp-action="InfoStudent" asp-route-id="@student.Id" class="btn btn-warning">Изменить</a>
|
||||
<form asp-controller="Home" asp-action="DeleteStudent" method="post">
|
||||
<input type="hidden" name="id" value="@student.Id" />
|
||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||
</form>
|
||||
|
@ -37,14 +37,6 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home"
|
||||
asp-action="ReportPlanOfStudys">Отчёт по планам обучения</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home"
|
||||
asp-action="ReportPlanOfStudyAndStudents">Сведения по планам обучения</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -7,6 +7,7 @@ namespace UniversityContracts.BindingModels
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int PlanOfStudyId { get; set; }
|
||||
public string PlanOfStudyProfile { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
}
|
||||
|
@ -11,7 +11,5 @@ namespace UniversityContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string? Profile { get; set; }
|
||||
public DateOnly? DateFrom { get; set; }
|
||||
public DateOnly? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ namespace UniversityContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int PlanOfStudyId { get; set; }
|
||||
[DisplayName("Профиль")]
|
||||
public string PlanOfStudyProfile { get; set; } = string.Empty;
|
||||
[DisplayName("ФИО")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Номер Телефона")]
|
||||
|
@ -32,7 +32,7 @@ namespace UniversityDatabaseImplement.Implements
|
||||
|
||||
var query = context.Attestations
|
||||
.Include(x => x.Student)
|
||||
.ThenInclude(s => s.User) // Загружаем данные пользователя студента
|
||||
.ThenInclude(s => s.User)
|
||||
.Include(x => x.User)
|
||||
.AsQueryable();
|
||||
|
||||
|
@ -74,10 +74,6 @@ namespace UniversityDatabaseImplement.Implements
|
||||
{
|
||||
query = query.Where(x => x.Id == model.Id.Value);
|
||||
}
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
query = query.Where(x => model.DateFrom.Value <= x.Date && x.Date <= model.DateTo.Value);
|
||||
};
|
||||
return query.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
|
475
University/UniversityDatabaseImplement/Migrations/20240529193238_newViewForStudent.Designer.cs
generated
Normal file
475
University/UniversityDatabaseImplement/Migrations/20240529193238_newViewForStudent.Designer.cs
generated
Normal file
@ -0,0 +1,475 @@
|
||||
// <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 UniversityDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(UniversityDatabase))]
|
||||
[Migration("20240529193238_newViewForStudent")]
|
||||
partial class newViewForStudent
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Attestation", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FormOfEvaluation")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Score")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("StudentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Attestations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("TeacherId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TeacherId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Disciplines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("FormOfStudy")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Profile")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("PlanOfStudys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudyTeacher", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("PlanOfStudyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TeacherId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PlanOfStudyId");
|
||||
|
||||
b.HasIndex("TeacherId");
|
||||
|
||||
b.ToTable("PlanOfStudyTeachers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("TeacherId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TeacherId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Statements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PlanOfStudyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("PlanOfStudyProfile")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PlanOfStudyId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentDiscipline", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("DisciplineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DisciplineId");
|
||||
|
||||
b.HasIndex("StudentId");
|
||||
|
||||
b.ToTable("StudentDisciplines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AcademicDegree")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Position")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Teachers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.User", 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>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Role")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Attestation", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
|
||||
.WithMany("Attestations")
|
||||
.HasForeignKey("StudentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Attestations")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Student");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
|
||||
.WithMany("Disciplines")
|
||||
.HasForeignKey("TeacherId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Disciplines")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Teacher");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
|
||||
.WithMany("PlanOfStudys")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudyTeacher", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.PlanOfStudy", "PlanOfStudy")
|
||||
.WithMany("Teachers")
|
||||
.HasForeignKey("PlanOfStudyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
|
||||
.WithMany("PlanOfStudyTeachers")
|
||||
.HasForeignKey("TeacherId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PlanOfStudy");
|
||||
|
||||
b.Navigation("Teacher");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
|
||||
.WithMany("Statements")
|
||||
.HasForeignKey("TeacherId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Statements")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Teacher");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.PlanOfStudy", "PlanOfStudy")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("PlanOfStudyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PlanOfStudy");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentDiscipline", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Discipline", "Discipline")
|
||||
.WithMany("Students")
|
||||
.HasForeignKey("DisciplineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
|
||||
.WithMany("StudentDiscipline")
|
||||
.HasForeignKey("StudentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Discipline");
|
||||
|
||||
b.Navigation("Student");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
|
||||
.WithMany("Teachers")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
|
||||
{
|
||||
b.Navigation("Students");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
|
||||
{
|
||||
b.Navigation("Students");
|
||||
|
||||
b.Navigation("Teachers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
|
||||
{
|
||||
b.Navigation("Attestations");
|
||||
|
||||
b.Navigation("StudentDiscipline");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
|
||||
{
|
||||
b.Navigation("Disciplines");
|
||||
|
||||
b.Navigation("PlanOfStudyTeachers");
|
||||
|
||||
b.Navigation("Statements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Attestations");
|
||||
|
||||
b.Navigation("Disciplines");
|
||||
|
||||
b.Navigation("PlanOfStudys");
|
||||
|
||||
b.Navigation("Statements");
|
||||
|
||||
b.Navigation("Students");
|
||||
|
||||
b.Navigation("Teachers");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class newViewForStudent : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PlanOfStudyProfile",
|
||||
table: "Students",
|
||||
type: "nvarchar(max)",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PlanOfStudyProfile",
|
||||
table: "Students");
|
||||
}
|
||||
}
|
||||
}
|
@ -191,6 +191,10 @@ namespace UniversityDatabaseImplement.Migrations
|
||||
b.Property<int>("PlanOfStudyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("PlanOfStudyProfile")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
|
@ -19,6 +19,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
public int UserId { get; private set; }
|
||||
[Required]
|
||||
public int PlanOfStudyId { get; private set; }
|
||||
public string PlanOfStudyProfile { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
@ -38,6 +39,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
User = context.Users.First(x => x.Id == model.UserId),
|
||||
PlanOfStudyId = model.PlanOfStudyId,
|
||||
PlanOfStudy = context.PlanOfStudys.First(x => x.Id == model.PlanOfStudyId),
|
||||
PlanOfStudyProfile = model.PlanOfStudyProfile,
|
||||
Name = model.Name,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
};
|
||||
@ -51,11 +53,13 @@ namespace UniversityDatabaseImplement.Models
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
Name = model.Name;
|
||||
PlanOfStudyId = model.PlanOfStudyId;
|
||||
PlanOfStudyProfile = model.PlanOfStudyProfile;
|
||||
}
|
||||
public StudentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PlanOfStudyId = PlanOfStudyId,
|
||||
PlanOfStudyProfile = PlanOfStudyProfile,
|
||||
UserId = UserId,
|
||||
Name = Name,
|
||||
PhoneNumber = PhoneNumber
|
||||
|
@ -11,7 +11,7 @@ namespace UniversityDatabaseImplement
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-N8BRIPR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DyCTaTOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace UniversityRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
[HttpPost]
|
||||
public void UpdateStudent(StudentBindingModel model)
|
||||
{
|
||||
try
|
||||
@ -69,7 +69,7 @@ namespace UniversityRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
[HttpPost]
|
||||
public void DeleteStudent(StudentBindingModel model)
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user