예제 #1
0
        public override IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (FormValues == null || !FormValues.Any())
            {
                return(new List <ValidationResult>());
            }

            if (FormTemplate == null)
            {
                var context = new LightMethods.Survey.Models.DAL.SurveyContext();
                using (var uow = new UnitOfWork(context))
                {
                    FormTemplate = uow.FormTemplatesRepository.GetNotTrackedFullTemplate(FormTemplateId);
                }
            }

            foreach (var value in FormValues)
            {
                if (value.MetricId != Guid.Empty && value.Metric == null)
                {
                    value.Metric = FormTemplate.MetricGroups.SelectMany(g => g.Metrics).Where(m => m.Id == value.MetricId).Single();
                }
            }

            return(FormValues.SelectMany(v => v.Validate(validationContext)));
        }
예제 #2
0
 internal Repository(UnitOfWork uow)
 {
     this.CurrentUOW = uow;
     this.Context    = uow.Context;
     this.Entities   = Context.Set <T>();
 }
예제 #3
0
 public UnitOfWork(SurveyContext context)
 {
     Context = context;
 }