Репорты готовые
This commit is contained in:
parent
f37916070e
commit
3535087e69
@ -1,10 +1,11 @@
|
||||
using AbstractLawFirmContracts.ViewModels;
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using University.ViewModels;
|
||||
using UniversityBusinessLogics.OfficePackage;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.BusinessLogicContracts;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StorageContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityBusinessLogics.BusinessLogics;
|
||||
|
||||
@ -125,10 +126,74 @@ private readonly AbstractSaveToPdf _saveToPdf;*/
|
||||
return reportDisciplineViewModels;
|
||||
}
|
||||
|
||||
public List<ReportPlanOfStudyViewModel> GetPlanOfStudyAndDisciplines()
|
||||
{
|
||||
var planOfStudies = _planOfStudyStorage.GetFullList();
|
||||
var reportPlanOfStudyViewModels = new List<ReportPlanOfStudyViewModel>();
|
||||
|
||||
foreach (var planOfStudy in planOfStudies)
|
||||
{
|
||||
// Получаем список дисциплин для текущего плана обучения
|
||||
var disciplines = _planOfStudyStorage.GetDisciplineFromStudentsFromPlanOfStudys(new PlanOfStudySearchModel { Id = planOfStudy.Id });
|
||||
|
||||
// Создаем ReportPlanOfStudyViewModel и добавляем его в список
|
||||
reportPlanOfStudyViewModels.Add(new ReportPlanOfStudyViewModel
|
||||
{
|
||||
PlanOfStudyName = planOfStudy.Profile,
|
||||
Disciplines = disciplines.Select(d => d.Name).ToList() // Получаем только имена дисциплин
|
||||
});
|
||||
}
|
||||
|
||||
return reportPlanOfStudyViewModels;
|
||||
}
|
||||
|
||||
public List<ReportPlanOfStudyAndStudentViewModel> GetPlanOfStudyAndStudents(ReportDateRangeBindingModel model)
|
||||
{
|
||||
var planOfStudies = _planOfStudyStorage.GetFullList();
|
||||
var reportPlanOfStudyAndStudentViewModels = new List<ReportPlanOfStudyAndStudentViewModel>();
|
||||
|
||||
foreach (var planOfStudy in planOfStudies)
|
||||
{
|
||||
// Получаем список студентов для текущего плана обучения
|
||||
var students = _studentStorage.GetFilteredList(new StudentSearchModel { Id = planOfStudy.Id });
|
||||
|
||||
var studentsAndDisciplines = new List<(string Student, string Discipline)>();
|
||||
|
||||
foreach (var student in students)
|
||||
{
|
||||
// Получаем список дисциплин для текущего студента
|
||||
var disciplines = _disciplineStorage.GetFilteredList(new DisciplineSearchModel { Id = student.Id });
|
||||
|
||||
foreach (var discipline in disciplines)
|
||||
{
|
||||
studentsAndDisciplines.Add((student.Name, discipline.Name));
|
||||
}
|
||||
}
|
||||
|
||||
// Создаем ReportPlanOfStudyAndStudentViewModel и добавляем его в список
|
||||
reportPlanOfStudyAndStudentViewModels.Add(new ReportPlanOfStudyAndStudentViewModel
|
||||
{
|
||||
PlanOfStudyName = planOfStudy.Profile,
|
||||
StudentsAndDisciplines = studentsAndDisciplines
|
||||
});
|
||||
}
|
||||
|
||||
return reportPlanOfStudyAndStudentViewModels;
|
||||
}
|
||||
|
||||
public void SaveTeachersToExcel(ReportBindingModel option)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void SavePlanOfStudyToExcel(ReportBindingModel option)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SavePlanOfStudyToWord(ReportBindingModel option)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveTeachersToWord(ReportBindingModel option)
|
||||
{
|
||||
@ -139,4 +204,9 @@ private readonly AbstractSaveToPdf _saveToPdf;*/
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SendPlanOfStudyToEmail(ReportDateRangeBindingModel option, string email)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
using AbstractLawFirmContracts.ViewModels;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using University.ViewModels;
|
||||
using UniversityContracts.BindingModels;
|
||||
|
||||
namespace UniversityContracts.BusinessLogicContracts
|
||||
|
@ -11,5 +11,7 @@ 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; }
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ namespace UniversityContracts.StorageContracts
|
||||
PlanOfStudyViewModel? Insert(PlanOfStudyBindingModel model);
|
||||
PlanOfStudyViewModel? Update(PlanOfStudyBindingModel model);
|
||||
PlanOfStudyViewModel? Delete(PlanOfStudyBindingModel model);
|
||||
List<DisciplineViewModel> GetDisciplineFromStudentsFromPlanOfStudys(PlanOfStudySearchModel model);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractLawFirmContracts.ViewModels
|
||||
namespace University.ViewModels
|
||||
{
|
||||
public class ReportDisciplineViewModel
|
||||
{
|
||||
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UniversityContracts.ViewModels
|
||||
{
|
||||
public class ReportPlanOfStudyAndStudentViewModel
|
||||
{
|
||||
public string PlanOfStudyName { get; set; } = string.Empty;
|
||||
public List<(string Student, string Discipline)> StudentsAndDisciplines { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UniversityContracts.ViewModels
|
||||
{
|
||||
public class ReportPlanOfStudyViewModel
|
||||
{
|
||||
public string PlanOfStudyName { get; set; } = string.Empty;
|
||||
public List<string> Disciplines { get; set; } = new();
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractLawFirmContracts.ViewModels
|
||||
namespace University.ViewModels
|
||||
{
|
||||
public class ReportTeacherViewModel
|
||||
{
|
||||
|
@ -21,16 +21,46 @@ namespace UniversityDatabaseImplement.Implements
|
||||
return context.PlanOfStudys.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<DisciplineViewModel> GetDisciplineFromStudentsFromPlanOfStudys(PlanOfStudySearchModel model)
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
|
||||
var students = context.Students
|
||||
.Where(s => s.PlanOfStudyId == model.Id)
|
||||
.Include(s => s.StudentDiscipline)
|
||||
.ToList();
|
||||
|
||||
if(students == null)
|
||||
{
|
||||
return new List<DisciplineViewModel>();
|
||||
}
|
||||
|
||||
// Получаем список дисциплин, которые соответствуют условиям поиска в модели PlanOfStudySearchModel
|
||||
var disciplines = students
|
||||
.SelectMany(s => s.StudentDiscipline)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
if (disciplines == null)
|
||||
{
|
||||
return new List<DisciplineViewModel>();
|
||||
}
|
||||
|
||||
// Преобразуем список дисциплин в список DisciplineViewModel и возвращаем его
|
||||
return disciplines
|
||||
.Select(d => d.Discipline.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<PlanOfStudyViewModel> GetFilteredList(PlanOfStudySearchModel model)
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
if (model.Id.HasValue)
|
||||
var query = context.PlanOfStudys
|
||||
.Include(x => x.Students)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.AsQueryable();
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
return context.PlanOfStudys
|
||||
.Include(x => x.Students)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
query = query.Where(x => model.DateFrom.Value <= x.Date && x.Date <= model.DateTo.Value);
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
public int UserId { get; private set; }
|
||||
[Required]
|
||||
public string Profile { get; private set; } = string.Empty;
|
||||
public DateOnly Date { get; private set; }
|
||||
[Required]
|
||||
public string FormOfStudy { get; private set; } = string.Empty;
|
||||
private Dictionary<int, ITeacherModel>? _planOfStudyTeachers = null;
|
||||
|
@ -10,8 +10,8 @@ namespace UniversityDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-N8BRIPR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DyCTaTOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -7,6 +7,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="6.1.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user