コード例 #1
0
        public void PopulateFields(SectionEdit section)
        {
            foreach (var field in section.FieldList.OrderBy(f => f.Position))
            {
                if (field == null) continue;
                var fieldVM = FieldFactory.CreateFieldVM(field, this);
                FieldList.Add(fieldVM);

                foreach (var step in field.StepList)
                    step.AddProps();

                var expandableObj = new ExpandableStepPropBag(TheProcessFieldsViewModel.Model) { FieldSecurityManager = TheProcessFieldsViewModel, Model = field, PreviewMode = true };

                foreach (var step in field.StepList)
                    step.UpdateProps(expandableObj);

                expandableObj.PreviewMode = true;

                if (!TheProcessFieldsViewModel.FieldList.Keys.Contains(field.Guid))
                    TheProcessFieldsViewModel.FieldList.Add(field.Guid, new Tuple<ProcessFieldViewModel, ExpandableStepPropBag>(fieldVM, expandableObj));

                Fields.Add(expandableObj);
            }

            SortFields();
        }
コード例 #2
0
        public bool UpdateSection(SectionEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Sections
                    .Single(e => e.SectionID == model.SectionID);

                entity.Title = model.Title;
                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #3
0
        public ActionResult Edit(int id)
        {
            var service = CreateSectionService();
            var detail  = service.GetSectionById(id);
            var model   =
                new SectionEdit
            {
                SectionID = detail.SectionId,
                Title     = detail.Title
            };

            return(View(model));
        }
コード例 #4
0
ファイル: SectionViewModel.cs プロジェクト: mparsin/Elements
        /// <summary>
        /// Initializes a new instance of the <see cref="SectionViewModel"/> class.
        /// </summary>
        /// <param name="selectedSection">The selected section.</param>
        /// <param name="parentModel">The parent model.</param>
        /// <param name="screenSecurity">The screen security.</param>
        public SectionViewModel(SectionEdit selectedSection, ProcessEdit parentModel, IFieldSecurityManager screenSecurity)
        {
            ProcessScreenSecuritySettings = screenSecurity;
            Fields = new ObservableCollection<ExpandableStepPropBag>();
            if (FieldList == null) 
                FieldList = new ObservableCollection<FieldEdit>();
            FieldList.Clear();

            _selectedSection = selectedSection;
            Id = selectedSection.Id;
            Name = selectedSection.Name;
            if (_selectedSection.FieldList != null)
            {
                foreach (var f in selectedSection.FieldList)
                {
                    AddField(selectedSection.Id, parentModel, f);
                }
            }
        }
コード例 #5
0
        public ActionResult Edit(int id, SectionEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.SectionID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateSectionService();

            if (service.UpdateSection(model))
            {
                TempData["ResultSaved"] = "Section was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Section could not be updated.");
            return(View(model));
        }