private void Save(Models.Article record, bool isNew) { // add any code to update other fields/tables here record.DateAdded = DateTime.Now; record.Save(); // delete all keyword for this article and its related urls and documents. AutocompletePhrase.AddPhrase("Article", record.ID, record.MetaKeywords, true); // save subform or related checkboxes here eg record.Lines.Save(); //ifsubform: record.example.Save(); foreach (var articleDocument in record.ArticleDocuments) { BewebCore.ThirdParty.SearchTextExtractor.CheckAttachmentsForDocOrPDFText(articleDocument); } CheckLock(record); lockobj.UnLockTable(record.GetTableName(), record.ID); ArticleCache.Rebuild(); }
protected ActionResult ProcessForm(Models.Article record) { try { record.UpdateFromRequest(); // read subform or related checkboxes here eg record.Lines.UpdateFromRequest(); record.ArticleDocuments.UpdateFromRequestSubForm(); record.ArticleURLs.UpdateFromRequestSubForm(); Validate(record); if (ModelState.IsValid) { Save(record, record.IsNewRecord); record.ArticleDocuments.Save(); record.ArticleURLs.Save(); Web.InfoMessage += "Article " + record.GetName() + " saved."; } } catch (UserErrorException e) { ModelState.AddModelError("Record", e.Message); } if (!ModelState.IsValid) { // invalid so redisplay form with validation message(s) return(View("ArticleEdit", new EditViewModel() { Article = record })); } else if (Web.Request["SaveAndRefreshButton"] != null) { return(RedirectToEdit(record.ID)); } else if (Web.Request["DuplicateButton"] != null) { var newRecord = new Models.Article(); newRecord.UpdateFrom(record); newRecord.Save(); Web.InfoMessage += "Copy of Article " + record.GetName() + " created. You are now editing the new copy."; return(RedirectToEdit(newRecord.ID)); } else { return(RedirectToReturnPage()); } }