Beispiel #1
0
 private void Save(Models.FAQSection record, bool isNew)
 {
     // add any code to update other fields/tables here
     record.Save();
     // save subform or related checkboxes here eg record.Lines.Save();
     record.FAQItems.Save();
     CheckLock(record);
     lockobj.UnLockTable(record.GetTableName(), record.ID);
     ActiveRecordLoader.ClearCache("FAQSection");
 }
Beispiel #2
0
        protected ActionResult ProcessForm(Models.FAQSection record)
        {
            try {
                if (record == null)
                {
                    record = new FAQSection();                           //check for deleted, or null, create a new one
                }
                record.UpdateFromRequest();
                // read subform or related checkboxes here eg record.Lines.UpdateFromRequest();
                record.FAQItems.UpdateFromRequest();

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

            if (!ModelState.IsValid)
            {
                // invalid so redisplay form with validation message(s)
                return(View("FAQSectionEdit", record));
            }
            else if (Web.Request["SaveAndRefreshButton"] != null)
            {
                return(RedirectToEdit(record.ID));
            }
            else if (Web.Request["DuplicateButton"] != null)
            {
                var newRecord = new Models.FAQSection();
                newRecord.UpdateFrom(record);
                newRecord.Save();
                Web.InfoMessage += "Copy of FAQ Section " + record.GetName() + " created. You are now editing the new copy.";
                return(RedirectToEdit(newRecord.ID));
            }
            else
            {
                return(RedirectToReturnPage());
            }
        }