Ejemplo n.º 1
0
        /// <summary>
        /// Populates defaults and opens edit form to add new record
        /// GET: /Admin/SavvyAdmin/Create
        /// </summary>
        public ActionResult Create()
        {
            Breadcrumbs.Current.AddBreadcrumb(3, "Add Savvy Admin");
            var record = new Models.SavvyAdmin();

            // any default values can be set here or in partial class SavvyAdmin.InitDefaults()
            return(View("SavvyAdminEdit", record));
        }
Ejemplo n.º 2
0
        protected ActionResult ProcessForm(Models.SavvyAdmin record)
        {
            try {
                record.UpdateFromRequest();
                Validate(record);
                if (ModelState.IsValid)
                {
                    Save(record, record.IsNewRecord);
                    Web.InfoMessage = "Savvy Admin " + record.GetName() + " saved.";
                }
            } catch (Exception e) {
                ModelState.AddModelError("Record", e.Message);
            }

            if (!ModelState.IsValid)
            {
                // invalid so redisplay form with validation message(s)
                return(View("SavvyAdminEdit", record));
            }
            else if (Web.Request["SaveAndRefreshButton"] != null)
            {
                return(RedirectToEdit(record.ID));
            }
            else if (Web.Request["DuplicateButton"] != null)
            {
                var newRecord = new Models.SavvyAdmin();
                newRecord.UpdateFrom(record);
                newRecord.Save();
                Web.InfoMessage = "Copy of Savvy Admin " + record.GetName() + " created. You are now editing the new copy.";
                return(RedirectToEdit(newRecord.ID));
            }
            else
            {
                return(RedirectToReturnPage());
            }
        }
Ejemplo n.º 3
0
 private void Save(Models.SavvyAdmin record, bool isNew)
 {
     // add any code to update other fields/tables here
     record.Save();
 }
Ejemplo n.º 4
0
 private void Validate(Models.SavvyAdmin record)
 {
     // add any code to check for validity
     //ModelState.AddModelError("Record", "Suchandsuch cannot be whatever.");
 }