50 lines
2.3 KiB
C#
50 lines
2.3 KiB
C#
|
using DatabaseCore;
|
|||
|
using DatabaseCore.Models.Department;
|
|||
|
using DepartmentBusinessLogic.BindingModels;
|
|||
|
using DepartmentBusinessLogic.Interfaces;
|
|||
|
using DepartmentBusinessLogic.ViewModels;
|
|||
|
using Microsoft.EntityFrameworkCore;
|
|||
|
using ModuleTools.Models;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace DepartmentDatabaseImplementation.Implementations
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Реализация IStudentGroupService
|
|||
|
/// </summary>
|
|||
|
public class StudentGroupService :
|
|||
|
AbstractGenerticEntityService<StudentGroupGetBindingModel, StudentGroupSetBindingModel, StudentGroup, StudentGroupListViewModel, StudentGroupViewModel>,
|
|||
|
IStudentGroupService
|
|||
|
{
|
|||
|
protected override OperationResultModel AdditionalCheckingWhenAdding(DbContext context, StudentGroupSetBindingModel model) => OperationResultModel.Success(null);
|
|||
|
|
|||
|
protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, StudentGroup entity, StudentGroupGetBindingModel model)
|
|||
|
{
|
|||
|
|
|||
|
return OperationResultModel.Success(null);
|
|||
|
}
|
|||
|
|
|||
|
protected override IQueryable<StudentGroup> AdditionalCheckingWhenReadingList(IQueryable<StudentGroup> query, StudentGroupGetBindingModel model)
|
|||
|
{
|
|||
|
if (model.AcademicPlanId.HasValue)
|
|||
|
{
|
|||
|
query = query.Where(x => x.AcademicPlanId == model.AcademicPlanId.Value);
|
|||
|
}
|
|||
|
if (model.LecturerId.HasValue)
|
|||
|
{
|
|||
|
query = query.Where(x => x.LecturerId == model.LecturerId.Value);
|
|||
|
}
|
|||
|
return query;
|
|||
|
}
|
|||
|
|
|||
|
protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, StudentGroupSetBindingModel model) => OperationResultModel.Success(null);
|
|||
|
|
|||
|
protected override void AdditionalDeleting(DbContext context, StudentGroup entity, StudentGroupGetBindingModel model) { }
|
|||
|
|
|||
|
protected override StudentGroup GetUniqueEntity(StudentGroupSetBindingModel model, DbContext context) => context.Set<StudentGroup>().FirstOrDefault(x => x.AcademicPlanId == model.AcademicPlanId && x.EnrollmentYear == model.EnrollmentYear && x.GroupNumber == model.GroupNumber && x.Id != model.Id);
|
|||
|
|
|||
|
protected override IQueryable<StudentGroup> IncludingWhenReading(IQueryable<StudentGroup> query) => query.Include(x => x.AcademicPlan).Include(x => x.Lecturer);
|
|||
|
|
|||
|
protected override IQueryable<StudentGroup> OrderingWhenReading(IQueryable<StudentGroup> query) => query.OrderBy(x => x.EnrollmentYear).ThenBy(x => x.GroupNumber);
|
|||
|
}
|
|||
|
}
|