private void Save(Models.TextBlock record, bool isNew)
        {
            // add any code to update other fields/tables here
            record.DateModified = DateTime.Now;
            record.Save();
            CheckLock(record);
            lockobj.UnLockTable(record.GetTableName(), record.ID);

            TextBlockCache.Rebuild();
        }
        /// <summary>
        /// Populates defaults and opens edit form to add new record
        /// GET: /Admin/TextBlock/Create
        /// </summary>
        public ActionResult Create()
        {
            Breadcrumbs.Current.AddBreadcrumb(Request["TextBlockGroupID"].IsNotBlank() ? 4 : 3, "Add Text Block");
            var record = new Models.TextBlock();

            if (Request["TextBlockPageID"].IsNotBlank())
            {
                record.TextBlockGroupID = Request["TextBlockGroupID"].ToString().ConvertToInt();
            }
            // any default values can be set here or in partial class TextBlock.InitDefaults()
            return(View("TextBlockEdit", record));
        }
        protected ActionResult ProcessForm(Models.TextBlock record)
        {
            try {
                record.UpdateFromRequest();
                Validate(record);
                if (ModelState.IsValid)
                {
                    Save(record, record.IsNewRecord);
                    Web.InfoMessage += "Text Block " + record.GetName() + " saved.";
                }
            } catch (UserErrorException e) {
                ModelState.AddModelError("Record", e.Message);
            }

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