コード例 #1
0
        public IActionResult Index()
        {
            CreateDependencyDTO createDependency = new CreateDependencyDTO();

            createDependency.UpdateIndependentFieldsList(_fieldDependenciesRepo, _context);
            return(View(createDependency));
        }
コード例 #2
0
 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)));
 }
コード例 #3
0
        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());
        }
コード例 #4
0
        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();
            }
        }