2022-03-15 13:20:46 +04:00
|
|
|
|
using AcademicProgressBusinessLogic.BindingModels;
|
|
|
|
|
using AcademicProgressBusinessLogic.Interfaces;
|
|
|
|
|
using AcademicProgressBusinessLogic.ViewModels;
|
|
|
|
|
using DatabaseCore;
|
|
|
|
|
using DatabaseCore.Models.AcademicProgress;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using ModuleTools.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace AcademicProgressDatabaseImplementation.Implementations
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Реализация IStudentAcademicProgress
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class StudentAcademicProgressService :
|
|
|
|
|
AbstractGenerticEntityService<StudentAcademicProgressGetBindingModel, StudentAcademicProgressSetBindingModel, StudentAcademicProgress, StudentAcademicProgressListViewModel, StudentAcademicProgressViewModels>,
|
2022-03-16 12:27:40 +04:00
|
|
|
|
IStudentAcademicProgressService
|
2022-03-15 13:20:46 +04:00
|
|
|
|
{
|
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, StudentAcademicProgressSetBindingModel model) => OperationResultModel.Success(null);
|
|
|
|
|
|
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, StudentAcademicProgress entity, StudentAcademicProgressGetBindingModel model) => OperationResultModel.Success(null);
|
|
|
|
|
|
|
|
|
|
protected override IQueryable<StudentAcademicProgress> AdditionalCheckingWhenReadingList(IQueryable<StudentAcademicProgress> query, StudentAcademicProgressGetBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model.StudentId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.StudentId == model.StudentId.Value);
|
|
|
|
|
}
|
|
|
|
|
if (model.DisciplineId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(x => x.DisciplineId == model.DisciplineId.Value);
|
|
|
|
|
}
|
|
|
|
|
return query;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, StudentAcademicProgressSetBindingModel model) => OperationResultModel.Success(null);
|
|
|
|
|
|
|
|
|
|
protected override void AdditionalDeleting(DbContext context, StudentAcademicProgress entity, StudentAcademicProgressGetBindingModel model) { }
|
|
|
|
|
|
2022-03-28 22:03:10 +04:00
|
|
|
|
protected override StudentAcademicProgress GetUniqueEntity(StudentAcademicProgressSetBindingModel model, DbContext context) => context.Set<StudentAcademicProgress>().FirstOrDefault(x => x.StudentId == model.StudentId && x.DisciplineId == model.DisciplineId && x.Semester == (int)model.Semester && x.Id != model.Id);
|
2022-03-15 13:20:46 +04:00
|
|
|
|
|
|
|
|
|
protected override IQueryable<StudentAcademicProgress> IncludingWhenReading(IQueryable<StudentAcademicProgress> query) => query.Include(x => x.Student).Include(x => x.Discipline);
|
|
|
|
|
|
|
|
|
|
protected override IQueryable<StudentAcademicProgress> OrderingWhenReading(IQueryable<StudentAcademicProgress> query) => query.OrderBy(x => x.Student.LastName).ThenBy(x => x.Student.FirstName);
|
|
|
|
|
|
2022-03-28 22:03:10 +04:00
|
|
|
|
|
2022-03-15 13:20:46 +04:00
|
|
|
|
}
|
|
|
|
|
}
|