public FieldAPIController(FormGeneratorContext context , UserManager <MyUser> userManager , IFieldDependenciesRepository depRepo) { _dependenciesRepository = depRepo; _context = context; _userManager = userManager; }
public static void SeedDependencies(IFieldDependenciesRepository repository, FormGeneratorContext context) { Field korzen = context.Field.FirstOrDefault(f => f.Id == 1); var fields = context.Field.Where(f => f.Id != 1).ToList(); FieldFieldDependency dep1 = new FieldFieldDependency(korzen, FieldFieldDependencyType.FieldDuplication, "22"); fields.ForEach(f => dep1.RelatedFields.Add(f)); var test = repository.GetAllDependFields(); repository.SaveDependency(dep1); }
public string Valid(FormGeneratorContext _context) { if (DependencyType == "FieldDuplication" && !int.TryParse(ActivationValue, out _)) { return("Maksymalna wartość musi być liczbą! Popraw błędy"); } if (RelatedFields.FirstOrDefault(f => f.Name == SuperiorFieldName) != null) { return("Pole nadrzędne nie może być polem podrzędnym w jednej relacji!"); } if (_context.Field.AsNoTracking().FirstOrDefault(f => f.Name == this.CurrentFieldName) == null && this.DependencyType == "FieldVisibly") { return("Wpisane pole zależne nie istnieje w systemie!"); } if (_context.Field.AsNoTracking().FirstOrDefault(f => f.Name == this.SuperiorFieldName) == null) { return("Wpisane pole nadrzędne nie istnieje"); } if (this.RelatedFields?.Count != 0 && this.DependencyType == "FieldDuplication") { return("Niezany błąd. Spróbuj jeszcze raz"); } //nie można edytować zależności ilościowej string test = FieldFieldDependencyType.FieldDuplication.ToString(); var dependencyExist = _context.Dependencies .AsNoTracking() .FirstOrDefault(dep => (dep.DependencyType.ToString() == this.DependencyType) && (dep.ThisField.Name == this.CurrentFieldName)); if (dependencyExist != null) { return("Zależność ilościowa już została zdefiniowana na tym polu."); } if (_context.Field.FirstOrDefault(f => f.Name == this.SuperiorFieldName).Type != "number" && this.DependencyType == "FieldDuplication") { return("Tylko pole typu 'number' może być polem nadrzędnym w relacji ilościowej"); } return(null); }
public void Build(CreateDependencyDTO createDependency, FormGeneratorContext _context) { this.ThisField = _context.Field.AsNoTracking().FirstOrDefault(f => f.Name == this.ThisField.Name); this.Id = this.ThisField.Id; if (createDependency.DependencyType == "FieldDuplication") { for (int i = 0; i < Convert.ToInt32(createDependency.ActivationValue); i++) //utworzenie pól zależnych(Pole 1, Pole 2...) { Field field = new Field { Name = createDependency.CurrentFieldName + $" {i + 1}", Type = "text" }; this.RelatedFields.Add(field); } //utworzenie ograniczenia na max(na tym polega ta zależność) Validation valueConstraint = new Validation { idField = this.Id, value = Convert.ToDecimal(this.ActivationValue), type = "max" }; _context.Validations.Add(valueConstraint); _context.SaveChanges(); } }
public EFFieldDependenciesRepository(FormGeneratorContext ctx) { _context = ctx; }
public FormsController(FormGeneratorContext context) { _context = context; }
public ValidationsController(FormGeneratorContext context) { _context = context; }
public FieldDependencyController(IFieldDependenciesRepository repo, FormGeneratorContext ctx, IMapper mapper) { _fieldDependenciesRepo = repo; _context = ctx; _mapper = mapper; }
public UserAnswerListsController(FormGeneratorContext context) { _context = context; }
public PatientController(FormGeneratorContext context) { _context = context; }
public EntranceFormFieldsController(FormGeneratorContext context) { _context = context; }
public CategoryController(FormGeneratorContext context) { _context = context; }
public void UpdateIndependentFieldsList(IFieldDependenciesRepository repository, FormGeneratorContext context) { var allDependFields = repository.GetAllDependFields(); var allIndependedFields = context.Field.AsNoTracking() .ToList() .Where(f => { return((!allDependFields.Contains(f)) && (f.Name != SuperiorFieldName) && (!RelatedFields.Contains(f))); }); AllIndependentFieldsName = JsonConvert.SerializeObject(allIndependedFields.Select(f => f.Name).ToList()); }
public FormsController(FormGeneratorContext context, UserManager <MyUser> userManager, IFieldDependenciesRepository repository) { _context = context; _userManager = userManager; pomik = repository; }