Пример #1
0
 private void Save(Models.GenTest record, bool isNew)
 {
     // add any code to update other fields/tables here
     record.Save();
     // save subform or related checkboxes here eg record.Lines.Save();
     //ifsubform: record.example.Save();
     CheckLock(record);
     //BewebCore.ThirdParty.SearchTextExtractor.CheckAttachmentsForDocOrPDFText(record);
     lockobj.UnLockTable(record.GetTableName(), record.ID);
     ActiveRecordLoader.ClearCache("GenTest");
 }
        //
        // GET: /Admin/GenTest/

        public ActionResult GenTestEditAutocomplete()
        {
            var data = new EditViewModel();

            Breadcrumbs.Current.AddBreadcrumb(3, "Add Gen Test - Autocomplete");
            var record = new Models.GenTest();

            // any default values can be set here or in partial class GenTest.InitDefaults()
            data.GenTest = record;
            return(View("GenTestEditAutocomplete", data));
        }
Пример #3
0
        /// <summary>
        /// Populates defaults and opens edit form to add new record
        /// GET: /Admin/GenTest/Create
        /// </summary>
        public ActionResult Create()
        {
            var data = new EditViewModel();

            Breadcrumbs.Current.AddBreadcrumb(3, "Add Gen Test");
            var record = new Models.GenTest();

            // any default values can be set here or in partial class GenTest.InitDefaults()
            record.UpdateFromRequest();              // grab any defaults from querystring
            data.GenTest = record;
            return(View("GenTestEdit", data));
        }
Пример #4
0
        protected ActionResult ProcessForm(Models.GenTest record)
        {
            try {
                if (record == null)
                {
                    record = new GenTest();                           //check for deleted, or null, create a new one
                }
                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 += "Gen Test " + record.GetName() + " saved.";
                }
            } catch (UserErrorException e) {
                ModelState.AddModelError("Record", e.Message);
            }

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