привязка года обучения к студенту
This commit is contained in:
parent
d1fcf069b3
commit
df73a0d314
@ -24,7 +24,7 @@ namespace CoreDatabase
|
||||
return result;
|
||||
}
|
||||
|
||||
var exsistEntity = GetUniqueEntity(model, context);
|
||||
var exsistEntity = GetUniqueEntity(model, IncludingWhenReading(context.Set<T>().AsQueryable()));
|
||||
if (exsistEntity == null)
|
||||
{
|
||||
var entity = Mapper.MapToClass<S, T>(model, true);
|
||||
@ -94,7 +94,7 @@ namespace CoreDatabase
|
||||
{
|
||||
using var context = DatabaseManager.GetContext;
|
||||
var entity = model.Id.HasValue ? IncludingWhenReading(context.Set<T>().AsQueryable()).FirstOrDefault(x => x.Id == model.Id.Value)
|
||||
: GetSingleRecord(context.Set<T>().AsQueryable(), model);
|
||||
: GetSingleRecord(IncludingWhenReading(context.Set<T>().AsQueryable()), model);
|
||||
if (entity == null)
|
||||
{
|
||||
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
|
||||
@ -121,7 +121,7 @@ namespace CoreDatabase
|
||||
if (model.Id.HasValue || AdditionalCheckForSingleGet(model))
|
||||
{
|
||||
var entity = model.Id.HasValue ? IncludingWhenReading(context.Set<T>().AsQueryable()).FirstOrDefault(x => x.Id == model.Id.Value)
|
||||
: GetSingleRecord(context.Set<T>().AsQueryable(), model);
|
||||
: GetSingleRecord(IncludingWhenReading(context.Set<T>().AsQueryable()), model);
|
||||
if (entity == null)
|
||||
{
|
||||
return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound);
|
||||
@ -167,9 +167,13 @@ namespace CoreDatabase
|
||||
return result;
|
||||
}
|
||||
|
||||
var exsistEntity = GetUniqueEntity(model, context);
|
||||
var exsistEntity = GetUniqueEntity(model, IncludingWhenReading(context.Set<T>().AsQueryable()));
|
||||
if (exsistEntity != null)
|
||||
{
|
||||
if (exsistEntity.IsDeleted)
|
||||
{
|
||||
return OperationResultModel.Error("Error:", "Существует удаленная запись с такими значениями", ResultServiceStatusCode.ExsistItem);
|
||||
}
|
||||
return OperationResultModel.Error("Error:", "Существует запись с такими значениями", ResultServiceStatusCode.ExsistItem);
|
||||
}
|
||||
|
||||
@ -194,7 +198,7 @@ namespace CoreDatabase
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
protected abstract T GetUniqueEntity(S model, DbContext context);
|
||||
protected abstract T GetUniqueEntity(S model, IQueryable<T> query);
|
||||
|
||||
/// <summary>
|
||||
/// Возможные дополнительные проверки при добавлении
|
||||
|
@ -70,7 +70,7 @@ namespace CoreDatabase
|
||||
|
||||
modelBuilder.Entity<Student>().HasIndex(d => new { d.NumberOfBook }).IsUnique();
|
||||
|
||||
modelBuilder.Entity<Order>().HasIndex(d => new { d.OrderNumber }).IsUnique();
|
||||
modelBuilder.Entity<Order>().HasIndex(d => new { d.OrderNumber, d.OrderDate, d.OrderType }).IsUnique();
|
||||
|
||||
modelBuilder.Entity<OrderStudentRecord>().HasIndex(d => new { d.StudentId, d.OrderId }).IsUnique();
|
||||
|
||||
|
1581
DepartmentPortal/Common/CoreDatabase/Migrations/20220329053045_ChangeOrderIndexUnique.Designer.cs
generated
Normal file
1581
DepartmentPortal/Common/CoreDatabase/Migrations/20220329053045_ChangeOrderIndexUnique.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,33 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace CoreDatabase.Migrations
|
||||
{
|
||||
public partial class ChangeOrderIndexUnique : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Orders_OrderNumber",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_OrderNumber_OrderDate_OrderType",
|
||||
table: "Orders",
|
||||
columns: new[] { "OrderNumber", "OrderDate", "OrderType" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Orders_OrderNumber_OrderDate_OrderType",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_OrderNumber",
|
||||
table: "Orders",
|
||||
column: "OrderNumber",
|
||||
unique: true);
|
||||
}
|
||||
}
|
||||
}
|
@ -686,7 +686,7 @@ namespace CoreDatabase.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderNumber")
|
||||
b.HasIndex("OrderNumber", "OrderDate", "OrderType")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Orders");
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -61,6 +61,11 @@ namespace ToolsModule.ManagmentEntity
|
||||
{
|
||||
Errors.Add(("Ошибка получения", ex.Message));
|
||||
Errors.Add(("Ошибка получения (Stack)", ex.StackTrace));
|
||||
while (ex.InnerException != null)
|
||||
{
|
||||
ex = ex.InnerException;
|
||||
Errors.Add(("Ошибка получения (Inner)", ex.Message));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -92,6 +97,11 @@ namespace ToolsModule.ManagmentEntity
|
||||
{
|
||||
Errors.Add(("Ошибка получения", ex.Message));
|
||||
Errors.Add(("Ошибка получения (Stack)", ex.StackTrace));
|
||||
while (ex.InnerException != null)
|
||||
{
|
||||
ex = ex.InnerException;
|
||||
Errors.Add(("Ошибка получения (Inner)", ex.Message));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -123,6 +133,11 @@ namespace ToolsModule.ManagmentEntity
|
||||
{
|
||||
Errors.Add(("Ошибка создания", ex.Message));
|
||||
Errors.Add(("Ошибка создания (Stack)", ex.StackTrace));
|
||||
while (ex.InnerException != null)
|
||||
{
|
||||
ex = ex.InnerException;
|
||||
Errors.Add(("Ошибка создания (Inner)", ex.Message));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -154,6 +169,11 @@ namespace ToolsModule.ManagmentEntity
|
||||
{
|
||||
Errors.Add(("Ошибка изменения", ex.Message));
|
||||
Errors.Add(("Ошибка изменения (Stack)", ex.StackTrace));
|
||||
while (ex.InnerException != null)
|
||||
{
|
||||
ex = ex.InnerException;
|
||||
Errors.Add(("Ошибка изменения (Inner)", ex.Message));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -185,6 +205,11 @@ namespace ToolsModule.ManagmentEntity
|
||||
{
|
||||
Errors.Add(("Ошибка удаления", ex.Message));
|
||||
Errors.Add(("Ошибка удаления (Stack)", ex.StackTrace));
|
||||
while (ex.InnerException != null)
|
||||
{
|
||||
ex = ex.InnerException;
|
||||
Errors.Add(("Ошибка удаления (Inner)", ex.Message));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -216,6 +241,11 @@ namespace ToolsModule.ManagmentEntity
|
||||
{
|
||||
Errors.Add(("Ошибка восстановления", ex.Message));
|
||||
Errors.Add(("Ошибка восстановления (Stack)", ex.StackTrace));
|
||||
while (ex.InnerException != null)
|
||||
{
|
||||
ex = ex.InnerException;
|
||||
Errors.Add(("Ошибка восстановления (Inner)", ex.Message));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ namespace DepartmentBusinessLogic.BusinessLogics.GenericBusinessLogic
|
||||
}
|
||||
|
||||
if ((result.OrderStudentMoveType == OrderStudentMoveType.ЗачислитьПоПриказу ||
|
||||
result.OrderStudentMoveType == OrderStudentMoveType.Распределить ||
|
||||
result.OrderStudentMoveType == OrderStudentMoveType.ПринятьПоПереводу ||
|
||||
result.OrderStudentMoveType == OrderStudentMoveType.ПринятьПоПереводусДругогоВуза ||
|
||||
result.OrderStudentMoveType == OrderStudentMoveType.ПеревестиНаДругоеНаправлениеКафедры)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,10 @@ namespace DepartmentContract.BindingModels
|
||||
public class EnrollmentYearGetBindingModel : GetBindingModel
|
||||
{
|
||||
public Guid? AcademicPlanId { get; set; }
|
||||
|
||||
public Guid? EducationDirectionId { get; set; }
|
||||
|
||||
public int? Year { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -14,6 +14,8 @@ namespace DepartmentContract.BindingModels
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
public DateTime? OrderDate { get; set; }
|
||||
|
||||
public OrderType? OrderType { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -31,11 +31,11 @@ namespace DepartmentContract.ViewModels
|
||||
[MapConfiguration("EducationDirection.Profile")]
|
||||
public string EducationDirectionProfile { get; set; }
|
||||
|
||||
[ViewModelControlListProperty("Дата создания", ColumnWidth = 120)]
|
||||
[ViewModelControlListProperty("Дата создания", ColumnWidth = 120, DefaultCellStyleFormat = "dd.MM.yyyy")]
|
||||
[ViewModelControlElementProperty("Дата создания", ControlType.ControlDateTime, MustHaveValue = true)]
|
||||
public DateTime CreateDate { get; set; }
|
||||
|
||||
[ViewModelControlListProperty("Дата последнего изменения", ColumnWidth = 120)]
|
||||
[ViewModelControlListProperty("Дата последнего изменения", ColumnWidth = 120, DefaultCellStyleFormat = "dd.MM.yyyy")]
|
||||
[ViewModelControlElementProperty("Дата последнего изменения", ControlType.ControlDateTime, MustHaveValue = true)]
|
||||
public DateTime LastUpdateDate { get; set; }
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace DepartmentContract.ViewModels
|
||||
/// Элемент приказа
|
||||
/// </summary>
|
||||
[ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)]
|
||||
[ViewModelControlElementDependenceEntity(Title = "Записи по студентам", Order = 1, ParentPropertyName = "AcademicPlanId",
|
||||
[ViewModelControlElementDependenceEntity(Title = "Записи по студентам", Order = 1, ParentPropertyName = "OrderId",
|
||||
ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlOrderStudentRecordList, DepartmentWindowsDesktop")]
|
||||
public class OrderViewModel : ElementViewModel, IOrderModel
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
protected override AcademicPlanRecord GetUniqueEntity(AcademicPlanRecordSetBindingModel model, DbContext context) => context.Set<AcademicPlanRecord>().FirstOrDefault(x => x.AcademicPlanId == model.AcademicPlanId && x.DisciplineId == model.DisciplineId && x.Semester == model.Semester && x.Id != model.Id);
|
||||
protected override AcademicPlanRecord GetUniqueEntity(AcademicPlanRecordSetBindingModel model, IQueryable<AcademicPlanRecord> query) => query.FirstOrDefault(x => x.AcademicPlanId == model.AcademicPlanId && x.DisciplineId == model.DisciplineId && x.Semester == model.Semester && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<AcademicPlanRecord> IncludingWhenReading(IQueryable<AcademicPlanRecord> query) => query.Include(x => x.AcademicPlan).Include(x => x.Discipline);
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, AcademicPlanRecordTimeNormHour entity, AcademicPlanRecordTimeNormHourGetBindingModel model) { }
|
||||
|
||||
protected override AcademicPlanRecordTimeNormHour GetUniqueEntity(AcademicPlanRecordTimeNormHourSetBindingModel model, DbContext context) => context.Set<AcademicPlanRecordTimeNormHour>().FirstOrDefault(x => x.AcademicPlanRecordId == model.AcademicPlanRecordId && x.TimeNormId == model.TimeNormId && x.Id != model.Id);
|
||||
protected override AcademicPlanRecordTimeNormHour GetUniqueEntity(AcademicPlanRecordTimeNormHourSetBindingModel model, IQueryable<AcademicPlanRecordTimeNormHour> query) => query.FirstOrDefault(x => x.AcademicPlanRecordId == model.AcademicPlanRecordId && x.TimeNormId == model.TimeNormId && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<AcademicPlanRecordTimeNormHour> IncludingWhenReading(IQueryable<AcademicPlanRecordTimeNormHour> query) => query.Include(x => x.AcademicPlanRecord).Include(x => x.AcademicPlanRecord.Discipline).Include(x => x.TimeNorm);
|
||||
|
||||
|
@ -56,7 +56,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
protected override AcademicPlan GetUniqueEntity(AcademicPlanSetBindingModel model, DbContext context) => context.Set<AcademicPlan>().FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.CreateDate == model.CreateDate && x.Id != model.Id);
|
||||
protected override AcademicPlan GetUniqueEntity(AcademicPlanSetBindingModel model, IQueryable<AcademicPlan> query) => query.FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.CreateDate == model.CreateDate && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<AcademicPlan> IncludingWhenReading(IQueryable<AcademicPlan> query) => query.Include(x => x.EducationDirection);
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
protected override BasicDepartment GetUniqueEntity(BasicDepartmentSetBindingModel model, DbContext context) => context.Set<BasicDepartment>().FirstOrDefault(x => x.BasicDepartmentName == model.BasicDepartmentName && x.Id != model.Id);
|
||||
protected override BasicDepartment GetUniqueEntity(BasicDepartmentSetBindingModel model, IQueryable<BasicDepartment> query) => query.FirstOrDefault(x => x.BasicDepartmentName == model.BasicDepartmentName && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<BasicDepartment> IncludingWhenReading(IQueryable<BasicDepartment> query) => query.Include(x => x.Lecturer);
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, Classroom entity, ClassroomGetBindingModel model) { }
|
||||
|
||||
protected override Classroom GetUniqueEntity(ClassroomSetBindingModel model, DbContext context) => context.Set<Classroom>().FirstOrDefault(x => x.Number == model.Number && x.Id != model.Id);
|
||||
protected override Classroom GetUniqueEntity(ClassroomSetBindingModel model, IQueryable<Classroom> query) => query.FirstOrDefault(x => x.Number == model.Number && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<Classroom> IncludingWhenReading(IQueryable<Classroom> query) => query.Include(x => x.Employee);
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, DisciplineBlock entity, DisciplineBlockGetBindingModel model) { }
|
||||
|
||||
protected override DisciplineBlock GetUniqueEntity(DisciplineBlockSetBindingModel model, DbContext context) => context.Set<DisciplineBlock>().FirstOrDefault(x => x.Title == model.Title && x.Id != model.Id);
|
||||
protected override DisciplineBlock GetUniqueEntity(DisciplineBlockSetBindingModel model, IQueryable<DisciplineBlock> query) => query.FirstOrDefault(x => x.Title == model.Title && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<DisciplineBlock> IncludingWhenReading(IQueryable<DisciplineBlock> query) => query;
|
||||
|
||||
|
@ -49,7 +49,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, Discipline entity, DisciplineGetBindingModel model) { }
|
||||
|
||||
protected override Discipline GetUniqueEntity(DisciplineSetBindingModel model, DbContext context) => context.Set<Discipline>().FirstOrDefault(x => x.DisciplineName == model.DisciplineName && x.Id != model.Id);
|
||||
protected override Discipline GetUniqueEntity(DisciplineSetBindingModel model, IQueryable<Discipline> query) => query.FirstOrDefault(x => x.DisciplineName == model.DisciplineName && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<Discipline> IncludingWhenReading(IQueryable<Discipline> query) => query.Include(x => x.DisciplineBlock);
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, EducationDirection entity, EducationDirectionGetBindingModel model) { }
|
||||
|
||||
protected override EducationDirection GetUniqueEntity(EducationDirectionSetBindingModel model, DbContext context) => context.Set<EducationDirection>().FirstOrDefault(x => x.Title == model.Title && x.Profile == model.Profile && x.Id != model.Id);
|
||||
protected override EducationDirection GetUniqueEntity(EducationDirectionSetBindingModel model, IQueryable<EducationDirection> query) => query.FirstOrDefault(x => x.Title == model.Title && x.Profile == model.Profile && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<EducationDirection> IncludingWhenReading(IQueryable<EducationDirection> query) => query.Include(x => x.Lecturer);
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, EmployeePost entity, EmployeePostGetBindingModel model) { }
|
||||
|
||||
protected override EmployeePost GetUniqueEntity(EmployeePostSetBindingModel model, DbContext context) => context.Set<EmployeePost>().FirstOrDefault(x => x.EmployeeId == model.EmployeeId && x.PostId == model.PostId && x.Id != model.Id);
|
||||
protected override EmployeePost GetUniqueEntity(EmployeePostSetBindingModel model, IQueryable<EmployeePost> query) => query.FirstOrDefault(x => x.EmployeeId == model.EmployeeId && x.PostId == model.PostId && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<EmployeePost> IncludingWhenReading(IQueryable<EmployeePost> query) => query.Include(x => x.Post).Include(x => x.Employee);
|
||||
|
||||
|
@ -59,7 +59,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
protected override Employee GetUniqueEntity(EmployeeSetBindingModel model, DbContext context) => context.Set<Employee>().FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName &&
|
||||
protected override Employee GetUniqueEntity(EmployeeSetBindingModel model, IQueryable<Employee> query) => query.FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName &&
|
||||
x.Patronymic == model.Patronymic && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<Employee> IncludingWhenReading(IQueryable<Employee> query) => query
|
||||
|
@ -26,6 +26,14 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
{
|
||||
query = query.Where(x => x.AcademicPlanId == model.AcademicPlanId.Value);
|
||||
}
|
||||
if (model.EducationDirectionId.HasValue)
|
||||
{
|
||||
query = query.Where(x => x.AcademicPlan.EducationDirectionId == model.EducationDirectionId.Value);
|
||||
}
|
||||
if (model.Year.HasValue)
|
||||
{
|
||||
query = query.Where(x => x.YearEntrance == model.Year.Value);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
@ -41,10 +49,28 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
protected override EnrollmentYear GetUniqueEntity(EnrollmentYearSetBindingModel model, DbContext context) => context.Set<EnrollmentYear>().FirstOrDefault(x => x.AcademicPlanId == model.AcademicPlanId && x.YearEntrance == model.YearEntrance && x.Id != model.Id);
|
||||
protected override EnrollmentYear GetUniqueEntity(EnrollmentYearSetBindingModel model, IQueryable<EnrollmentYear> query) => query.FirstOrDefault(x => x.AcademicPlanId == model.AcademicPlanId && x.YearEntrance == model.YearEntrance && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<EnrollmentYear> IncludingWhenReading(IQueryable<EnrollmentYear> query) => query.Include(x => x.AcademicPlan).Include(x => x.AcademicPlan.EducationDirection);
|
||||
|
||||
protected override IQueryable<EnrollmentYear> OrderingWhenReading(IQueryable<EnrollmentYear> query) => query.OrderBy(x => x.AcademicPlan.EducationDirection.Cipher).ThenBy(x => x.YearEntrance);
|
||||
}
|
||||
|
||||
protected override bool AdditionalCheckForSingleGet(EnrollmentYearGetBindingModel model)
|
||||
{
|
||||
if (model.EducationDirectionId.HasValue && model.Year.HasValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return base.AdditionalCheckForSingleGet(model);
|
||||
}
|
||||
|
||||
protected override EnrollmentYear GetSingleRecord(IQueryable<EnrollmentYear> list, EnrollmentYearGetBindingModel model)
|
||||
{
|
||||
if (model.EducationDirectionId.HasValue && model.Year.HasValue)
|
||||
{
|
||||
return list.FirstOrDefault(x => x.AcademicPlan.EducationDirectionId == model.EducationDirectionId && x.YearEntrance == model.Year);
|
||||
}
|
||||
return base.GetSingleRecord(list, model);
|
||||
}
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, LecturerAcademicDegree entity, LecturerAcademicDegreeGetBindingModel model) { }
|
||||
|
||||
protected override LecturerAcademicDegree GetUniqueEntity(LecturerAcademicDegreeSetBindingModel model, DbContext context) => context.Set<LecturerAcademicDegree>().FirstOrDefault(x => x.LecturerAcademicDegreeName == model.LecturerAcademicDegreeName && x.Id != model.Id);
|
||||
protected override LecturerAcademicDegree GetUniqueEntity(LecturerAcademicDegreeSetBindingModel model, IQueryable<LecturerAcademicDegree> query) => query.FirstOrDefault(x => x.LecturerAcademicDegreeName == model.LecturerAcademicDegreeName && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<LecturerAcademicDegree> IncludingWhenReading(IQueryable<LecturerAcademicDegree> query) => query;
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, LecturerAcademicRank entity, LecturerAcademicRankGetBindingModel model) { }
|
||||
|
||||
protected override LecturerAcademicRank GetUniqueEntity(LecturerAcademicRankSetBindingModel model, DbContext context) => context.Set<LecturerAcademicRank>().FirstOrDefault(x => x.LecturerAcademicRankName == model.LecturerAcademicRankName && x.Id != model.Id);
|
||||
protected override LecturerAcademicRank GetUniqueEntity(LecturerAcademicRankSetBindingModel model, IQueryable<LecturerAcademicRank> query) => query.FirstOrDefault(x => x.LecturerAcademicRankName == model.LecturerAcademicRankName && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<LecturerAcademicRank> IncludingWhenReading(IQueryable<LecturerAcademicRank> query) => query;
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace DepartmentDatabaseImplementation.Implementations
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, LecturerPost entity, LecturerPostGetBindingModel model) { }
|
||||
|
||||
protected override LecturerPost GetUniqueEntity(LecturerPostSetBindingModel model, DbContext context) => context.Set<LecturerPost>().FirstOrDefault(x => x.LecturerId == model.LecturerId && x.PostId == model.PostId && x.Id != model.Id);
|
||||
protected override LecturerPost GetUniqueEntity(LecturerPostSetBindingModel model, IQueryable<LecturerPost> query) => query.FirstOrDefault(x => x.LecturerId == model.LecturerId && x.PostId == model.PostId && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<LecturerPost> IncludingWhenReading(IQueryable<LecturerPost> query) => query.Include(x => x.Post).Include(x => x.Lecturer);
|
||||
|
||||
|
@ -72,7 +72,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
protected override Lecturer GetUniqueEntity(LecturerSetBindingModel model, DbContext context) => context.Set<Lecturer>().FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName &&
|
||||
protected override Lecturer GetUniqueEntity(LecturerSetBindingModel model, IQueryable<Lecturer> query) => query.FirstOrDefault(x => x.LastName == model.LastName && x.FirstName == model.FirstName &&
|
||||
x.Patronymic == model.Patronymic && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<Lecturer> IncludingWhenReading(IQueryable<Lecturer> query)
|
||||
|
@ -42,7 +42,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, Order entity, OrderGetBindingModel model) { }
|
||||
|
||||
protected override Order GetUniqueEntity(OrderSetBindingModel model, DbContext context) => context.Set<Order>().FirstOrDefault(x => x.OrderNumber == model.OrderNumber && x.Id != model.Id);
|
||||
protected override Order GetUniqueEntity(OrderSetBindingModel model, IQueryable<Order> query) => query.FirstOrDefault(x => x.OrderNumber == model.OrderNumber && x.OrderDate == model.OrderDate && x.OrderType == model.OrderType && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<Order> IncludingWhenReading(IQueryable<Order> query) => query;
|
||||
|
||||
@ -50,6 +50,14 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override bool AdditionalCheckForSingleGet(OrderGetBindingModel model)
|
||||
{
|
||||
if (model.OrderNumber.IsNotEmpty() && model.OrderDate.HasValue && model.OrderType.HasValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (model.OrderNumber.IsNotEmpty() && model.OrderDate.HasValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (model.OrderNumber.IsNotEmpty())
|
||||
{
|
||||
return true;
|
||||
@ -59,6 +67,14 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override Order GetSingleRecord(IQueryable<Order> list, OrderGetBindingModel model)
|
||||
{
|
||||
if (model.OrderNumber.IsNotEmpty() && model.OrderDate.HasValue && model.OrderType.HasValue)
|
||||
{
|
||||
return list.FirstOrDefault(x => x.OrderNumber == model.OrderNumber && x.OrderDate == model.OrderDate && x.OrderType == model.OrderType);
|
||||
}
|
||||
if (model.OrderNumber.IsNotEmpty() && model.OrderDate.HasValue)
|
||||
{
|
||||
return list.FirstOrDefault(x => x.OrderNumber == model.OrderNumber && x.OrderDate == model.OrderDate);
|
||||
}
|
||||
if (model.OrderNumber.IsNotEmpty())
|
||||
{
|
||||
return list.FirstOrDefault(x => x.OrderNumber == model.OrderNumber);
|
||||
|
@ -41,7 +41,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, OrderStudentRecord entity, OrderStudentRecordGetBindingModel model) { }
|
||||
|
||||
protected override OrderStudentRecord GetUniqueEntity(OrderStudentRecordSetBindingModel model, DbContext context) => context.Set<OrderStudentRecord>().FirstOrDefault(x => x.StudentId == model.StudentId && x.OrderId == model.OrderId && x.Id != model.Id);
|
||||
protected override OrderStudentRecord GetUniqueEntity(OrderStudentRecordSetBindingModel model, IQueryable<OrderStudentRecord> query) => query.FirstOrDefault(x => x.StudentId == model.StudentId && x.OrderId == model.OrderId && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<OrderStudentRecord> IncludingWhenReading(IQueryable<OrderStudentRecord> query) => query.Include(x => x.Order).Include(x => x.Student).Include(x => x.StudentGroupFrom).Include(x => x.StudentGroupTo);
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, Post entity, PostGetBindingModel model) { }
|
||||
|
||||
protected override Post GetUniqueEntity(PostSetBindingModel model, DbContext context) => context.Set<Post>().FirstOrDefault(x => x.PostName == model.PostName && x.Id != model.Id);
|
||||
protected override Post GetUniqueEntity(PostSetBindingModel model, IQueryable<Post> query) => query.FirstOrDefault(x => x.PostName == model.PostName && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<Post> IncludingWhenReading(IQueryable<Post> query) => query;
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
protected override StudentGroup GetUniqueEntity(StudentGroupSetBindingModel model, DbContext context) => context.Set<StudentGroup>().FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.AcademicCourse == model.AcademicCourse && x.GroupNumber == model.GroupNumber && x.Id != model.Id);
|
||||
protected override StudentGroup GetUniqueEntity(StudentGroupSetBindingModel model, IQueryable<StudentGroup> query) => query.FirstOrDefault(x => x.EducationDirectionId == model.EducationDirectionId && x.AcademicCourse == model.AcademicCourse && x.GroupNumber == model.GroupNumber && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<StudentGroup> IncludingWhenReading(IQueryable<StudentGroup> query) => query.Include(x => x.EducationDirection).Include(x => x.Lecturer).Include(x => x.Students);
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
protected override Student GetUniqueEntity(StudentSetBindingModel model, DbContext context) => context.Set<Student>().FirstOrDefault(x => x.NumberOfBook == model.NumberOfBook && x.Id != model.Id);
|
||||
protected override Student GetUniqueEntity(StudentSetBindingModel model, IQueryable<Student> query) => query.FirstOrDefault(x => x.NumberOfBook == model.NumberOfBook && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<Student> IncludingWhenReading(IQueryable<Student> query) => query.Include(x => x.StudentGroup).Include(x => x.User);
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace DepartmentDatabaseImplementation.Implementations.AbstractGenerticEntit
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, TimeNorm entity, TimeNormGetBindingModel model) { }
|
||||
|
||||
protected override TimeNorm GetUniqueEntity(TimeNormSetBindingModel model, DbContext context) => context.Set<TimeNorm>().FirstOrDefault(x => x.TimeNormName == model.TimeNormName && x.TimeNormShortName == model.TimeNormShortName && x.Id != model.Id);
|
||||
protected override TimeNorm GetUniqueEntity(TimeNormSetBindingModel model, IQueryable<TimeNorm> query) => query.FirstOrDefault(x => x.TimeNormName == model.TimeNormName && x.TimeNormShortName == model.TimeNormShortName && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<TimeNorm> IncludingWhenReading(IQueryable<TimeNorm> query) => query.Include(x => x.DisciplineBlock);
|
||||
|
||||
|
@ -33,8 +33,8 @@ namespace SecurityDatabaseImplementation.Implementations.AbstractGenerticEntityS
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, Access entity, AccessGetBindingModel model) { }
|
||||
|
||||
protected override Access GetUniqueEntity(AccessSetBindingModel model, DbContext context) =>
|
||||
context.Set<Access>().FirstOrDefault(x => x.AccessOperation == model.AccessOperation && x.RoleId == model.RoleId && x.AccessType == model.AccessType && x.Id != model.Id);
|
||||
protected override Access GetUniqueEntity(AccessSetBindingModel model, IQueryable<Access> query) =>
|
||||
query.FirstOrDefault(x => x.AccessOperation == model.AccessOperation && x.RoleId == model.RoleId && x.AccessType == model.AccessType && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<Access> IncludingWhenReading(IQueryable<Access> query) => query.Include(x => x.Role);
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace SecurityDatabaseImplementation.Implementations.AbstractGenerticEntityS
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, EnviromentSetting entity, EnviromentSettingGetBindingModel model) { }
|
||||
|
||||
protected override EnviromentSetting GetUniqueEntity(EnviromentSettingSetBindingModel model, DbContext context) => context.Set<EnviromentSetting>().FirstOrDefault(x => x.Key == model.Key && x.Id != model.Id);
|
||||
protected override EnviromentSetting GetUniqueEntity(EnviromentSettingSetBindingModel model, IQueryable<EnviromentSetting> query) => query.FirstOrDefault(x => x.Key == model.Key && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<EnviromentSetting> IncludingWhenReading(IQueryable<EnviromentSetting> query) => query;
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace SecurityDatabaseImplementation.Implementations.AbstractGenerticEntityS
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
protected override Role GetUniqueEntity(RoleSetBindingModel model, DbContext context) => context.Set<Role>().FirstOrDefault(x => x.RoleName == model.RoleName && x.Id != model.Id);
|
||||
protected override Role GetUniqueEntity(RoleSetBindingModel model, IQueryable<Role> query) => query.FirstOrDefault(x => x.RoleName == model.RoleName && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<Role> IncludingWhenReading(IQueryable<Role> query) => query;
|
||||
|
||||
|
@ -37,10 +37,28 @@ namespace SecurityDatabaseImplementation.Implementations.AbstractGenerticEntityS
|
||||
|
||||
protected override void AdditionalDeleting(DbContext context, UserRole entity, UserRoleGetBindingModel model) { }
|
||||
|
||||
protected override UserRole GetUniqueEntity(UserRoleSetBindingModel model, DbContext context) => context.Set<UserRole>().FirstOrDefault(x => x.UserId == model.UserId && x.RoleId == model.RoleId && x.Id != model.Id);
|
||||
protected override UserRole GetUniqueEntity(UserRoleSetBindingModel model, IQueryable<UserRole> query) => query.FirstOrDefault(x => x.UserId == model.UserId && x.RoleId == model.RoleId && x.Id != model.Id);
|
||||
|
||||
protected override IQueryable<UserRole> IncludingWhenReading(IQueryable<UserRole> query) => query.Include(x => x.Role).Include(x => x.User);
|
||||
|
||||
protected override IQueryable<UserRole> OrderingWhenReading(IQueryable<UserRole> query) => query.OrderBy(x => x.User.UserName);
|
||||
}
|
||||
|
||||
protected override bool AdditionalCheckForSingleGet(UserRoleGetBindingModel model)
|
||||
{
|
||||
if (model.RoleId.HasValue && model.UserId.HasValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return base.AdditionalCheckForSingleGet(model);
|
||||
}
|
||||
|
||||
protected override UserRole GetSingleRecord(IQueryable<UserRole> list, UserRoleGetBindingModel model)
|
||||
{
|
||||
if (model.RoleId.HasValue && model.UserId.HasValue)
|
||||
{
|
||||
return list.FirstOrDefault(x => x.RoleId == model.RoleId && x.UserId == model.UserId);
|
||||
}
|
||||
return base.GetSingleRecord(list, model);
|
||||
}
|
||||
}
|
||||
}
|
@ -68,7 +68,7 @@ namespace SecurityDatabaseImplementation.Implementations.AbstractGenerticEntityS
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
protected override User GetUniqueEntity(UserSetBindingModel model, DbContext context) => context.Set<User>().FirstOrDefault((System.Linq.Expressions.Expression<Func<User, bool>>)(x => x.UserName == model.UserName && x.Id != model.Id));
|
||||
protected override User GetUniqueEntity(UserSetBindingModel model, IQueryable<User> query) => query.FirstOrDefault((System.Linq.Expressions.Expression<Func<User, bool>>)(x => x.UserName == model.UserName && x.Id != model.Id));
|
||||
|
||||
protected override IQueryable<User> IncludingWhenReading(IQueryable<User> query) => query;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user