public IActionResult Index() { CreateDependencyDTO createDependency = new CreateDependencyDTO(); createDependency.UpdateIndependentFieldsList(_fieldDependenciesRepo, _context); return(View(createDependency)); }
public IActionResult AddFieldToRelatedListPOST(CreateDependencyDTO createDependency) { ViewBag.Error = createDependency.Valid(_context); if (ViewBag.Error != null) { return(View("Index", createDependency)); } createDependency.AddRelatedField(_context.Field.AsNoTracking().FirstOrDefault <Field>(f => f.Name == createDependency.CurrentFieldName)); createDependency.UpdateIndependentFieldsList(_fieldDependenciesRepo, _context); TempData.Put <CreateDependencyDTO>("CreateDependencyFromPostToGet", createDependency); return(RedirectToAction(nameof(AddFieldToRelatedListGet))); }
public IActionResult CreateDependency(CreateDependencyDTO createDependency) { ViewBag.Error = createDependency.Valid(_context); if (ViewBag.Error != null) { return(View("Index", createDependency)); } var dependency = _mapper.Map <FieldFieldDependency>(createDependency); dependency.Build(createDependency, _context); _fieldDependenciesRepo.SaveDependency(dependency); return(View()); }
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(); } }