provider #6
@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.BusinessLogicContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StoragesContracts;
|
||||
using UniversityBusinessLogic.OfficePackage;
|
||||
|
||||
namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReportCustomerLogic : IReportCustomerLogic
|
||||
{
|
||||
private readonly IDocumentStorage _documentStorage;
|
||||
private readonly IStudentStorage _studentStorage;
|
||||
private readonly IEducationStatusStorage _educationStatusStorage;
|
||||
private readonly IEducationGroupStorage _educationGroupStorage;
|
||||
private readonly IDisciplineStorage _disciplineStorage;
|
||||
private readonly IStreamStorage _streamStorage;
|
||||
private readonly AbstractSaveToExcelProvider _saveToExcel;
|
||||
private readonly AbstractSaveToWordProvider _saveToWord;
|
||||
private readonly AbstractSaveToPdfProvider _saveToPdf;
|
||||
|
||||
public ReportCustomerLogic(IDocumentStorage documentStorage,
|
||||
IStudentStorage studentStorage,
|
||||
IEducationStatusStorage educationStatusStorage,
|
||||
IEducationGroupStorage educationGroupStorage,
|
||||
IDisciplineStorage disciplineStorage,
|
||||
IStreamStorage streamStorage,
|
||||
AbstractSaveToExcelProvider saveToExcel,
|
||||
AbstractSaveToWordProvider saveToWord,
|
||||
AbstractSaveToPdfProvider saveToPdf)
|
||||
{
|
||||
_documentStorage = documentStorage;
|
||||
_studentStorage = studentStorage;
|
||||
_educationStatusStorage = educationStatusStorage;
|
||||
_educationGroupStorage = educationGroupStorage;
|
||||
_disciplineStorage = disciplineStorage;
|
||||
_streamStorage = streamStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
|
||||
public List<ReportDisciplineViewModel> GetDisciplineReport(List<StudentViewModel> students)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<ReportStreamEducationStatusViewModel> GetStreamEdStat(ReportBindingModel model)
|
||||
{
|
||||
|
||||
var result = _streamStorage
|
||||
.GetFilteredList(new StreamSearchModel { UserId = model.UserId })
|
||||
.Select(stream => new ReportStreamStudentEdStatPeriodViewModel
|
||||
{
|
||||
StreamName = stream.Name,
|
||||
StudentEdStatus = stream.StudentStream
|
||||
.Where(student => _documentStorage.GetFilteredList(new DocumentSearchModel
|
||||
{
|
||||
UserId = model.UserId,
|
||||
})
|
||||
.Select(student => (
|
||||
StudentFIO: $"{student.Value.Name} {student.Value.Surname}",
|
||||
EdStatus: _educationStatusStorage.GetElement(new EducationStatusSearchModel { Id = student.Value.EducationStatusId })?.Name ?? "не удалось получить"))
|
||||
.ToList())
|
||||
})
|
||||
.ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void SaveBlanksToWordFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveDocumentBlankToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IReportCustomerLogic
|
||||
{
|
||||
List<ReportStudentsDisciplineViewModel> GetStudentsDiscipline(List<StudentViewModel> students);
|
||||
List<ReportStreamEducationStatusViewModel> StreamStudentEdStatPeriod(ReportBindingModel model);
|
||||
|
||||
void SaveBlanksToWordFile(ReportBindingModel model);
|
||||
|
||||
void SaveDocumentBlankToExcelFile(ReportBindingModel model);
|
||||
|
||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
15
UniversityContracts/ViewModels/ReportDisciplineViewModel.cs
Normal file
15
UniversityContracts/ViewModels/ReportDisciplineViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UniversityContracts.ViewModels
|
||||
{
|
||||
public class ReportDisciplineViewModel
|
||||
{
|
||||
public string DisciplineName { get; set; } = string.Empty;
|
||||
public List<(string StudentFIO, string DocumentDate, string EdStatus)> StudentEdStatus { get; set; } = new();
|
||||
//выбираем дисциплину, выбираем период, отображаются студенты зачисленные через приказ в этот период со статусами обучения
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UniversityContracts.ViewModels
|
||||
{
|
||||
public class ReportStreamEducationStatusViewModel
|
||||
{
|
||||
public string StreamName { get; set; } = string.Empty;
|
||||
public List<(string StudentFIO, string EdStatus)> StudentEdStatus { get; set; } = new();
|
||||
// при выборе потока показывается список студентов на потоке и их статус обучения
|
||||
|
||||
}
|
||||
}
|
106
UniversityDataBaseImplemet/Implements/DisciplineStorage.cs
Normal file
106
UniversityDataBaseImplemet/Implements/DisciplineStorage.cs
Normal file
@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StoragesContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDataBaseImplemet.Models;
|
||||
|
||||
namespace UniversityDataBaseImplemet.Implements
|
||||
{
|
||||
public class DisciplineStorage:IDisciplineStorage
|
||||
{
|
||||
public DisciplineViewModel? GetElement(DisciplineSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.Discipline
|
||||
.FirstOrDefault(record => record.Id == model.Id
|
||||
|| record.Name.Equals(model.Name))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public List<DisciplineViewModel> GetFilteredList(DisciplineSearchModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Discipline
|
||||
.Where(record => record.Id.Equals(model.Id))
|
||||
.Select(record => record.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.UserId.HasValue)
|
||||
{
|
||||
return context.Discipline
|
||||
.Where(record => record.UserId == model.UserId)
|
||||
.Select(record => record.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
public List<DisciplineViewModel> GetFullList()
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.Discipline
|
||||
.Select(record => record.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public DisciplineViewModel? Insert(DisciplineBindingModel model)
|
||||
{
|
||||
var newDiscipline = Discipline.Create(model);
|
||||
if (newDiscipline == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
context.Discipline.Add(newDiscipline);
|
||||
context.SaveChanges();
|
||||
return newDiscipline.GetViewModel;
|
||||
}
|
||||
public DisciplineViewModel? Update(DisciplineBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var stream = context.Discipline
|
||||
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||
if (stream == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
stream.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return stream.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public DisciplineViewModel? Delete(DisciplineBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var stream = context.Discipline
|
||||
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||
if (stream == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Discipline.Remove(stream);
|
||||
context.SaveChanges();
|
||||
return stream.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
105
UniversityDataBaseImplemet/Implements/EducationGroupStorage.cs
Normal file
105
UniversityDataBaseImplemet/Implements/EducationGroupStorage.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDataBaseImplemet.Models;
|
||||
|
||||
namespace UniversityDataBaseImplemet.Implements
|
||||
{
|
||||
public class EducationGroupStorage
|
||||
{
|
||||
public EducationGroupViewModel? GetElement(EducationGroupSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.EducationGroups
|
||||
.FirstOrDefault(record => record.Id == model.Id
|
||||
|| record.Name.Equals(model.Name))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public List<EducationGroupViewModel> GetFilteredList(EducationGroupSearchModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.EducationGroups
|
||||
.Where(record => record.Id.Equals(model.Id))
|
||||
.Select(record => record.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.UserId.HasValue)
|
||||
{
|
||||
return context.EducationGroups
|
||||
.Where(record => record.UserId == model.UserId)
|
||||
.Select(record => record.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
public List<EducationGroupViewModel> GetFullList()
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.EducationGroups
|
||||
.Select(record => record.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public EducationGroupViewModel? Insert(EducationGroupBindingModel model)
|
||||
{
|
||||
var newEducationGroup = EducationGroup.Create(model);
|
||||
if (newEducationGroup == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
context.EducationGroups.Add(newEducationGroup);
|
||||
context.SaveChanges();
|
||||
return newEducationGroup.GetViewModel;
|
||||
}
|
||||
public EducationGroupViewModel? Update(EducationGroupBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var educationgroup = context.EducationGroups
|
||||
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||
if (educationgroup == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
educationgroup.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return educationgroup.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public EducationGroupViewModel? Delete(EducationGroupBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var educationgroup = context.EducationGroups
|
||||
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||
if (educationgroup == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.EducationGroups.Remove(educationgroup);
|
||||
context.SaveChanges();
|
||||
return educationgroup.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
107
UniversityDataBaseImplemet/Implements/StreamStorage.cs
Normal file
107
UniversityDataBaseImplemet/Implements/StreamStorage.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StoragesContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using Stream = UniversityDataBaseImplemet.Models.Stream;
|
||||
|
||||
namespace UniversityDataBaseImplemet.Implements
|
||||
{
|
||||
public class StreamStorage:IStreamStorage
|
||||
{
|
||||
public StreamViewModel? GetElement(StreamSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.Streams
|
||||
.FirstOrDefault(record => record.Id == model.Id
|
||||
|| record.Name.Equals(model.Name))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public List<StreamViewModel> GetFilteredList(StreamSearchModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Streams
|
||||
.Where(record => record.Id.Equals(model.Id))
|
||||
.Select(record => record.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.UserId.HasValue)
|
||||
{
|
||||
return context.Streams
|
||||
.Where(record => record.UserId == model.UserId)
|
||||
.Select(record => record.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
public List<StreamViewModel> GetFullList()
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.Streams
|
||||
.Select(record => record.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public StreamViewModel? Insert(StreamBindingModel model)
|
||||
{
|
||||
var newStream = Stream.Create(model);
|
||||
if (newStream == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
context.Streams.Add(newStream);
|
||||
context.SaveChanges();
|
||||
return newStream.GetViewModel;
|
||||
}
|
||||
public StreamViewModel? Update(StreamBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var stream = context.Streams
|
||||
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||
if (stream == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
stream.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return stream.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public StreamViewModel? Delete(StreamBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var stream = context.Streams
|
||||
.FirstOrDefault(record => record.Id.Equals(model.Id));
|
||||
if (stream == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Streams.Remove(stream);
|
||||
context.SaveChanges();
|
||||
return stream.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StoragesContracts;
|
||||
|
Loading…
Reference in New Issue
Block a user