Готовый отчёты word + excel + решенные ошибки с обновлением связи многие ко многим + исправление страницы Students. Но ошибка с Attestation.StudentName
This commit is contained in:
parent
d7422d9547
commit
27d38f78fc
@ -149,7 +149,7 @@ public class ReportLogic : IReportLogic
|
||||
return reportDisciplineViewModels;
|
||||
}
|
||||
|
||||
public List<ReportPlanOfStudyViewModel> GetPlanOfStudyAndDisciplines()
|
||||
public List<ReportPlanOfStudyViewModel> GetPlanOfStudyAndDisciplines(int userId)
|
||||
{
|
||||
var planOfStudies = _planOfStudyStorage.GetFullList();
|
||||
var reportPlanOfStudyViewModels = new List<ReportPlanOfStudyViewModel>();
|
||||
@ -157,11 +157,12 @@ public class ReportLogic : IReportLogic
|
||||
foreach (var planOfStudy in planOfStudies)
|
||||
{
|
||||
// Получаем список дисциплин для текущего плана обучения
|
||||
var disciplines = _planOfStudyStorage.GetDisciplineFromStudentsFromPlanOfStudys(new PlanOfStudySearchModel { Id = planOfStudy.Id });
|
||||
var disciplines = _planOfStudyStorage.GetDisciplineFromStudentsFromPlanOfStudys(new PlanOfStudySearchModel { Id = planOfStudy.Id, UserId = userId });
|
||||
|
||||
// Создаем ReportPlanOfStudyViewModel и добавляем его в список
|
||||
reportPlanOfStudyViewModels.Add(new ReportPlanOfStudyViewModel
|
||||
{
|
||||
Id = planOfStudy.Id,
|
||||
PlanOfStudyName = planOfStudy.Profile,
|
||||
FormOfStudy = planOfStudy.FormOfStudy,
|
||||
Disciplines = disciplines.Select(d => d.Name).ToList() // Получаем только имена дисциплин
|
||||
@ -211,10 +212,12 @@ public class ReportLogic : IReportLogic
|
||||
}
|
||||
public void SavePlanOfStudyToExcel(ReportBindingModel option)
|
||||
{
|
||||
/*_saveToExcelWorker.CreateReport(new ExcelInfoWorker
|
||||
_saveToExcelWorker.CreateReport(new ExcelInfoWorker
|
||||
{
|
||||
|
||||
});*/
|
||||
FileName = option.FileName,
|
||||
Title = "Список дисциплин и планов обучения",
|
||||
PlanOfStudys = GetPlanOfStudyAndDisciplines(0)
|
||||
});
|
||||
}
|
||||
|
||||
public void SavePlanOfStudyToWord(ReportBindingModel option)
|
||||
@ -222,8 +225,8 @@ public class ReportLogic : IReportLogic
|
||||
_saveToWordWorker.CreateDoc(new WordInfoWorker
|
||||
{
|
||||
FileName = option.FileName,
|
||||
Title = "Список планов обучения",
|
||||
PlanOfStudys = GetPlanOfStudyAndDisciplines()
|
||||
Title = "Список дисциплин и планов обучения",
|
||||
PlanOfStudys = GetPlanOfStudyAndDisciplines(0)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace UniversityBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToExcelWorker
|
||||
{
|
||||
/*public void CreateReport(ExcelInfoWorker info)
|
||||
public void CreateReport(ExcelInfoWorker info)
|
||||
{
|
||||
CreateExcel(info);
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
@ -26,23 +26,23 @@ namespace UniversityBusinessLogic.OfficePackage
|
||||
CellToName = "C1"
|
||||
});
|
||||
uint rowIndex = 2;
|
||||
foreach (var wk in info.WorkComponents)
|
||||
foreach (var ps in info.PlanOfStudys)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = wk.WorkName,
|
||||
Text = ps.PlanOfStudyName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
}); ;
|
||||
rowIndex++;
|
||||
foreach (var (Component, Count) in wk.Components)
|
||||
foreach (var discipline in ps.Disciplines)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = Component,
|
||||
Text = ps.FormOfStudy,
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
@ -50,30 +50,16 @@ namespace UniversityBusinessLogic.OfficePackage
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = Count.ToString(),
|
||||
Text = discipline,
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
rowIndex++;
|
||||
}
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = "Итого",
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = wk.TotalCount.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
}
|
||||
SaveExcel(info);
|
||||
}*/
|
||||
}
|
||||
protected abstract void CreateExcel(ExcelInfoWorker info);
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace UniversityBusinessLogic.OfficePackage
|
||||
{
|
||||
@ -28,14 +29,29 @@ namespace UniversityBusinessLogic.OfficePackage
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> {
|
||||
(planOfStudys.PlanOfStudyName + " - ", new WordTextProperties { Size = "24", Bold = true, }),
|
||||
(planOfStudys.FormOfStudy, new WordTextProperties { Size = "24", }) },
|
||||
(planOfStudys.PlanOfStudyName + " :", new WordTextProperties { Size = "24", Bold = true, }),
|
||||
},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
foreach(var discipline in planOfStudys.Disciplines)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> {
|
||||
(planOfStudys.FormOfStudy + " : ", new WordTextProperties { Size = "24", }),
|
||||
(discipline, new WordTextProperties { Size = "24", }),
|
||||
},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
SaveWord(info);
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace UniversityBusinessLogic.OfficePackage.HelperModels
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfoWorker
|
||||
{
|
||||
@ -12,7 +14,7 @@
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
|
||||
public List<ReportPlanOfStudyViewModel> PlanOfStudys { get; set; } = new();
|
||||
public List<string> Headers { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace PlumbingRepairClientApp
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
@ -48,6 +48,20 @@ namespace PlumbingRepairClientApp
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<T?> GetRequestAsync<T>(string requestUrl)
|
||||
{
|
||||
var response = await _client.GetAsync(requestUrl);
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
public static void PostRequest<T>(string requestUrl, T model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
|
@ -82,13 +82,14 @@ namespace UniversityClientAppWorker.Controllers
|
||||
{
|
||||
throw new Exception("id íå ìîæåò áûòü ðàâåí 0");
|
||||
}
|
||||
var planOfStudyTeachers = teacherIds.ToDictionary(id => id, id => (ITeacherModel)null);
|
||||
APIClient.PostRequest("api/planofstudys/updateplanofstudy", new PlanOfStudyBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Profile = profile,
|
||||
FormOfStudy = formOfStudy,
|
||||
PlanOfStudyTeachers = teacherIds.ToDictionary(id => id, id => (ITeacherModel)null)
|
||||
});
|
||||
PlanOfStudyTeachers = planOfStudyTeachers
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpGet]
|
||||
@ -133,7 +134,8 @@ namespace UniversityClientAppWorker.Controllers
|
||||
}
|
||||
ViewBag.Students = APIClient.GetRequest<List<StudentViewModel>>($"api/student/getstudents?userId={APIClient.User.Id}");
|
||||
ViewBag.AttestationScore = Enum.GetValues(typeof(AttestationScore)).Cast<AttestationScore>();
|
||||
return View(APIClient.GetRequest<List<AttestationViewModel>>($"api/attestation/getattestations?userId={APIClient.User.Id}"));
|
||||
var obj = APIClient.GetRequest<List<AttestationViewModel>>($"api/attestation/getattestations?userId={APIClient.User.Id}");
|
||||
return View(obj);
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateAttestation(string formOfEvaluation, int student, AttestationScore score)
|
||||
@ -156,14 +158,15 @@ namespace UniversityClientAppWorker.Controllers
|
||||
Response.Redirect("Attestations");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Students()
|
||||
public async Task<IActionResult> Students()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.PlanOfStudys = APIClient.GetRequest<List<PlanOfStudyViewModel>>
|
||||
var planOfStudys = await APIClient.GetRequestPlanOfStudyAsync<List<PlanOfStudyViewModel>>
|
||||
($"api/planofstudys/getplanofstudys?userId={APIClient.User.Id}");
|
||||
ViewBag.PlanOfStudys = planOfStudys;
|
||||
return View(APIClient.GetRequest<List<StudentViewModel>>($"api/student/getstudents?userId={APIClient.User.Id}"));
|
||||
}
|
||||
[HttpPost]
|
||||
@ -234,13 +237,47 @@ namespace UniversityClientAppWorker.Controllers
|
||||
return;
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult ReportPlanOfStudyViewModel()
|
||||
public IActionResult ReportPlanOfStudys()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<ReportPlanOfStudyViewModel>>($"api/planofstudys/GetPlanOfStudyAndDisciplines"));
|
||||
return View("ReportPlanOfStudys", APIClient.GetRequest<List<ReportPlanOfStudyViewModel>>($"api/planofstudys/getplanofstudyanddisciplines?userId={APIClient.User.Id}"));
|
||||
}
|
||||
[HttpPost]
|
||||
public void ReportPlanOfStudys(string type)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
Redirect("~/Home/Enter");
|
||||
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(type))
|
||||
{
|
||||
throw new Exception("Íåâåðíûé òèï îò÷åòà");
|
||||
}
|
||||
|
||||
if (type == "docx")
|
||||
{
|
||||
APIClient.PostRequest("api/planofstudys/loadreporttoword", new ReportBindingModel
|
||||
{
|
||||
FileName = $"C:\\Users\\{Environment.UserName}\\Desktop\\Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.docx"
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "xlsx")
|
||||
{
|
||||
APIClient.PostRequest("api/planofstudys/loadreporttoexcel", new ReportBindingModel
|
||||
{
|
||||
FileName = $"C:\\Users\\{Environment.UserName}\\Desktop\\Ïëàíû îáó÷åíèé ïî äèñöèïëèíàì.xlsx"
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,4 @@
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</table>
|
@ -24,6 +24,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Преподаватели:</div>
|
||||
<div class="col-8">
|
||||
<div class="scrollable-list">
|
||||
@foreach (var teacher in ViewBag.Teachers)
|
||||
{
|
||||
<div class="form-check">
|
||||
@ -33,6 +34,7 @@
|
||||
</label>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -1,49 +0,0 @@
|
||||
@using UniversityContracts.ViewModels
|
||||
@model List<ReportPlanOfStudyViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Отчёт по планам обучения";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4 mt-2">
|
||||
<input type="submit" value="сохранить ворд" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>План обучения</th>
|
||||
<th>Форма обучения</th>
|
||||
<th>Дисциплины</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PlanOfStudyName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.FormOfStudy)
|
||||
</td>
|
||||
<td>
|
||||
@foreach (var discipline in item.Disciplines)
|
||||
{
|
||||
@Html.DisplayFor(modelItem => discipline)
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
@ -0,0 +1,62 @@
|
||||
@using UniversityContracts.ViewModels
|
||||
@model List<ReportPlanOfStudyViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Отчёт по планам обучения";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-8 btn-group"></div>
|
||||
<div class="col-4 mt-2">
|
||||
<form method="post">
|
||||
<input type="hidden" name="type" value="docx" />
|
||||
<input type="submit" value="Сохранить в формате Word" class="btn btn-primary" />
|
||||
</form>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" name="type" value="xlsx" />
|
||||
<input type="submit" value="Сохранить в формате Excel" class="btn btn-success" />
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-4 mt-2">
|
||||
</div>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>План обучения</th>
|
||||
<th>Форма обучения</th>
|
||||
<th>Дисциплины</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PlanOfStudyName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.FormOfStudy)
|
||||
</td>
|
||||
<td>
|
||||
@foreach (var discipline in item.Disciplines)
|
||||
{
|
||||
<div>
|
||||
@Html.DisplayFor(modelItem => discipline)
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
@ -39,7 +39,7 @@
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home"
|
||||
asp-action="ReportPlanOfStudyViewModel">Отчёт по планам обучения</a>
|
||||
asp-action="ReportPlanOfStudys">Отчёт по планам обучения</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -18,7 +18,7 @@ namespace UniversityContracts.BusinessLogicContracts
|
||||
/// <returns></returns>
|
||||
List<ReportTeacherViewModel> GetTeachers();
|
||||
List<ReportDisciplineViewModel> GetDisciplines(ReportBindingModel model);
|
||||
List<ReportPlanOfStudyViewModel> GetPlanOfStudyAndDisciplines();
|
||||
List<ReportPlanOfStudyViewModel> GetPlanOfStudyAndDisciplines(int userId);
|
||||
List<ReportPlanOfStudyAndStudentViewModel> GetPlanOfStudyAndStudents(ReportDateRangeBindingModel model);
|
||||
|
||||
void SaveTeachersToWord(ReportBindingModel option);
|
||||
|
@ -9,7 +9,7 @@ namespace UniversityContracts.SearchModels
|
||||
public class AttestationSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int? StudentId { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
public int StudentId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ namespace UniversityContracts.ViewModels
|
||||
{
|
||||
public class ReportPlanOfStudyViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string PlanOfStudyName { get; set; } = string.Empty;
|
||||
public string FormOfStudy { get; set; } = string.Empty;
|
||||
public List<string> Disciplines { get; set; } = new();
|
||||
|
@ -5,6 +5,7 @@ namespace UniversityDataModels.Models
|
||||
public interface IAttestationModel : IId
|
||||
{
|
||||
int UserId { get; }
|
||||
string StudentName { get; }
|
||||
string FormOfEvaluation { get; }
|
||||
AttestationScore Score { get; }
|
||||
int StudentId { get; }
|
||||
|
@ -30,11 +30,18 @@ namespace UniversityDatabaseImplement.Implements
|
||||
|
||||
using var context = new UniversityDatabase();
|
||||
|
||||
return context.Attestations
|
||||
.Include(x => x.Student)
|
||||
.Include(x => x.User)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
var query = context.Attestations
|
||||
.Include(x => x.Student)
|
||||
.ThenInclude(s => s.User) // Загружаем данные пользователя студента
|
||||
.Include(x => x.User)
|
||||
.AsQueryable();
|
||||
|
||||
if (model.UserId.HasValue)
|
||||
{
|
||||
query = query.Where(x => x.UserId == model.UserId.Value);
|
||||
}
|
||||
|
||||
return query.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public AttestationViewModel? GetElement(AttestationSearchModel model)
|
||||
|
@ -115,14 +115,20 @@ namespace UniversityDatabaseImplement.Implements
|
||||
public PlanOfStudyViewModel? Update(PlanOfStudyBindingModel model)
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
var order = context.PlanOfStudys.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
var planOfStudy = context.PlanOfStudys.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (planOfStudy == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
planOfStudy.Update(model);
|
||||
planOfStudy.UpdateTeachers(context, model);
|
||||
context.SaveChanges();
|
||||
return context.PlanOfStudys.Include(x => x.User).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
return context.PlanOfStudys
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Teachers)
|
||||
.ThenInclude(x => x.Teacher)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?
|
||||
.GetViewModel;
|
||||
}
|
||||
public PlanOfStudyViewModel? Delete(PlanOfStudyBindingModel model)
|
||||
{
|
||||
|
@ -0,0 +1,471 @@
|
||||
// <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("20240528222736_newFieldForAttestationViewModel")]
|
||||
partial class newFieldForAttestationViewModel
|
||||
{
|
||||
/// <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<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 newFieldForAttestationViewModel : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "StudentName",
|
||||
table: "Attestations",
|
||||
type: "nvarchar(max)",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "StudentName",
|
||||
table: "Attestations");
|
||||
}
|
||||
}
|
||||
}
|
@ -40,6 +40,10 @@ namespace UniversityDatabaseImplement.Migrations
|
||||
b.Property<int>("StudentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("StudentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ namespace UniversityRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<ReportPlanOfStudyViewModel>? GetPlanOfStudyAndDisciplines()
|
||||
public List<ReportPlanOfStudyViewModel>? GetPlanOfStudyAndDisciplines(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _reportLogic.GetPlanOfStudyAndDisciplines();
|
||||
return _reportLogic.GetPlanOfStudyAndDisciplines(userId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -61,6 +61,32 @@ namespace UniversityRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void LoadReportToWord(ReportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SavePlanOfStudyToWord(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void LoadReportToExcel(ReportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SavePlanOfStudyToExcel(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreatePlanOfStudy(PlanOfStudyBindingModel model)
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user