protected override Action <AbstractLabSchedule> GetEntityInitializer(EditLabScheduleModelBase model, IEntityQuery query) { return(sch => { sch.DateFrom = model.DateFrom; sch.DateTill = model.DateTill; sch.Mode = model.Mode; sch.LabWork = query.Get <LabWork>(model.GetLabWorkId()); var groupSch = sch as GroupLabSchedule; if (groupSch != null) { Contract.Assert(model.ScheduleKind == EditLabScheduleModelBase.Kind.Group); groupSch.Group = query.Get <Group>(model.GetDoerId()); return; } var studentSch = sch as IndividualLabSchedule; if (studentSch != null) { Contract.Assert(model.ScheduleKind == EditLabScheduleModelBase.Kind.Individual); studentSch.Student = query.Get <Student>(model.GetDoerId()); return; } throw new ArgumentOutOfRangeException($"Сущность типа {sch.GetType()} не поддерживается."); }); }
protected override Action <DomainModel.TestPoolEntry> GetEntityInitializer(SaveTestPoolEntryModel model, IEntityQuery query) { var entityPool = query.Get <DomainModel.TestPool>(model.TestPool); var entityQuestion = query.Get <TestQuestion>(model.TestQuestion); return(g => { g.Id = model.Id; g.Score = model.Score; g.ScoringStrategy = model.ScoringStrategy; g.TestQuestion = entityQuestion; g.TestPool = entityPool; }); }
protected override Action <DomainModel.StudentAnswer> GetEntityInitializer(StudentAnswerModel model, IEntityQuery query) { var result = query.Get <TestResult>(model.TestResultId); var answer = query.Get <AnswerVariant>(model.ChosenAnswerId); var operation = _operationContextFactory.Create(); var testResult = operation.DataContext.Query.OfEntities <TestResult>().FirstOrDefault(e => e.Id == result.Id); if (testResult != null) { testResult.Status = ExecutionStatus.Complete; } operation.Complete(); return(g => { g.TestResult = result; g.AnswerVariant = answer; g.Time = DateTime.Now; }); }
protected override Action <DomainModel.TestPool> GetEntityInitializer(TestPoolModel model, IEntityQuery query) { var entity = query.Get <DomainModel.TestPool>(model.Id); return(g => { g.Id = model.Id; g.Name = model.Name; g.TestPoolEntries = entity.TestPoolEntries; }); }
private Session GetSessionWithChecks(IEntityQuery query, Guid sessionGuid) { var session = query.Get <Session>(sessionGuid); //TODO +проверка контрольной суммы и тп - всё надо куда-то в Security вытащить if (session.IP != HttpContext.Current.Request.UserHostAddress) { throw new EntityNotFoundException(typeof(Session), new object[] { sessionGuid }); } return(session); }
public TModel Load(object key) { var entity = _query.Get <TEntity>(key); return(Load(entity)); }