Example #1
0
        /// <summary>
        /// Populates defaults and opens edit form to add new record
        /// GET: /Admin/DocumentCategory/Create
        /// </summary>
        public ActionResult Create()
        {
            var data = new EditViewModel();

            Breadcrumbs.Current.AddBreadcrumb(3, "Add Document Category");
            var record = new Models.DocumentCategory();

            // any default values can be set here or in partial class DocumentCategory.InitDefaults()
            record.UpdateFromRequest();              // grab any defaults from querystring
            data.DocumentCategory = record;
            return(View("DocumentCategoryEdit", data));
        }
 public ViewModel(Models.DocumentCategory documentCategory)
 {
     if (!documentCategory.GetIsActive())
     {
         throw new Beweb.BadUrlException("Document Category not available with ID of [" + documentCategory.ID + "]");
     }
     _documentCategory = documentCategory;
     SetCategoryPage(_documentCategory.ID);
     _categoryBreadCrumb = CreateCategoryBreadCrumb(_documentCategory.ID, "");
     // add the page
     ContentPage = _categoryPage;
     TrackingBreadcrumb.Current.AddBreadcrumb(1, _documentCategory.Title);
 }
Example #3
0
 private static void AddChildren(DocumentCategoryList hierarchy, DocumentCategory parentDocumentCategory, int depth, DocumentCategoryList allDocumentCategories)
 {
     foreach (var checkDocumentCategory in allDocumentCategories)
     {
         if (checkDocumentCategory.ParentDocumentCategoryID == parentDocumentCategory.ID)
         {
             var childDocumentCategory = checkDocumentCategory;
             childDocumentCategory["Depth"].ValueObject = depth;
             hierarchy.Add(childDocumentCategory);
             AddChildren(hierarchy, childDocumentCategory, depth + 1, allDocumentCategories);
         }
     }
 }
Example #4
0
 private void Save(Models.DocumentCategory record, bool isNew)
 {
     // add any code to update other fields/tables here
     record.Save();
     if (record.ParentDocumentCategoryID.HasValue && record.PageID.HasValue)
     {
         record.PageID = null;
         record.Save();
     }
     // save subform or related checkboxes here eg record.Lines.Save();
     //ifsubform: record.example.Save();
     //CheckLock(record);
     //lockobj.UnLockTable(record.GetTableName(),record.ID);
     ActiveRecordLoader.ClearCache("DocumentCategory");
 }
Example #5
0
        protected ActionResult ProcessForm(Models.DocumentCategory record)
        {
            try {
                record.UpdateFromRequest();
                // read subform or related checkboxes here eg record.Lines.UpdateFromRequest();
                //ifsubform: record.example.UpdateFromRequest();

                Validate(record);
                if (ModelState.IsValid)
                {
                    Save(record, record.IsNewRecord);
                    Web.InfoMessage += "Document Category " + record.GetName() + " saved.";
                }
            } catch (UserErrorException e) {
                ModelState.AddModelError("Record", e.Message);
            }

            if (!ModelState.IsValid)
            {
                // invalid so redisplay form with validation message(s)
                return(View("DocumentCategoryEdit", new EditViewModel()
                {
                    DocumentCategory = record
                }));
            }
            else if (Web.Request["SaveAndRefreshButton"] != null)
            {
                return(RedirectToEdit(record.ID));
            }
            else if (Web.Request["DuplicateButton"] != null)
            {
                var newRecord = new Models.DocumentCategory();
                newRecord.UpdateFrom(record);
                newRecord.Save();
                Web.InfoMessage += "Copy of Document Category " + record.GetName() + " created. You are now editing the new copy.";
                return(RedirectToEdit(newRecord.ID));
            }
            else
            {
                return(RedirectToReturnPage());
            }
        }
Example #6
0
 private void Validate(Models.DocumentCategory record)
 {
     // add any code to check for validity
     //ModelState.AddModelError("Record", "Suchandsuch cannot be whatever.");
 }