Пример #1
0
        protected ActionResult ProcessForm(Models.FAQItem record)
        {
            try {
                record.UpdateFromRequest();
                // read subform or related checkboxes here eg record.Lines.UpdateFromRequest();
                Validate(record);
                if (BewebModelState.IsValid())
                {
                    Save(record, record.IsNewRecord);
                    Web.InfoMessage = "Faqitem " + record.GetName() + " saved.";
                }
            } catch (UserErrorException e) {
                BewebModelState.AddModelError("Record", e.Message);
            }

            if (!BewebModelState.IsValid())
            {
                // invalid so redisplay form with validation message(s)
                return(View("FAQItemEdit", record));
            }
            else if (Web.Request["SaveAndRefreshButton"] != null)
            {
                return(RedirectToEdit(record.ID));
            }
            else if (Web.Request["DuplicateButton"] != null)
            {
                var newRecord = new Models.FAQItem();
                newRecord.UpdateFrom(record);
                newRecord.Save();
                Web.InfoMessage = "Copy of Faqitem " + record.GetName() + " created. You are now editing the new copy.";
                return(RedirectToEdit(newRecord.ID));
            }
            else
            {
                return(RedirectToReturnPage());
            }
        }
Пример #2
0
 private void Save(Models.FAQItem record, bool isNew)
 {
     // add any code to update other fields/tables here
     record.Save();
     // save subform or related checkboxes here eg record.Lines.Save();
 }