private void Save(Models.FAQSection record, bool isNew) { // add any code to update other fields/tables here record.Save(); // save subform or related checkboxes here eg record.Lines.Save(); record.FAQItems.Save(); CheckLock(record); lockobj.UnLockTable(record.GetTableName(), record.ID); ActiveRecordLoader.ClearCache("FAQSection"); }
/// <summary> /// This is a quick way of loading a record by ID and returning its title/name. /// You can pass it a string, int or any type that the primary key is. /// You can override GetNameField() if you want to change which field is defined as the title/name, or override GetName() to completely customise what is returned as the name or title. /// </summary> /// <returns>The name/title of the item with the given ID</returns> public static string FetchName(object id) { if (id!=null) { var rec = ActiveRecordLoader.LoadID<FAQItem>(id, "FAQItem", Otherwise.Null); if (rec!=null) { return rec.GetName(); } } return null; }
public ActiveRecordList <TActiveRecord> GetResults(bool useDefaultOrderBy) { var sql = GetSql(); sql.Paging(ItemsPerPage, PageNum); var list = new ActiveRecordList <TActiveRecord>(); ActiveRecordLoader.LoadRecords <TActiveRecord>(list, sql); return(list); }
private void Save(Models.Event 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); //lockobj.UnLockTable(record.GetTableName(),record.ID); ActiveRecordLoader.ClearCache("Event"); }
private void Save(Models.ArticleDocument 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(); //BewebCore.ThirdParty.SearchTextExtractor.CheckAttachmentsForDocOrPDFText(record); //CheckLock(record); //lockobj.UnLockTable(record.GetTableName(),record.ID); ActiveRecordLoader.ClearCache("ArticleDocument"); }
/// <summary> /// This is a quick way of loading a record by ID and returning its title/name. /// You can pass it a string, int or any type that the primary key is. /// You can override GetNameField() if you want to change which field is defined as the title/name, or override GetName() to completely customise what is returned as the name or title. /// </summary> /// <returns>The name/title of the item with the given ID</returns> public static string FetchName(object id) { if (id != null) { var rec = ActiveRecordLoader.LoadID <GenTestHasCat>(id, "GenTestHasCat", Otherwise.Null); if (rec != null) { return(rec.GetName()); } } return(null); }
/// <summary> /// This is a quick way of loading a record by ID and returning its title/name. /// You can pass it a string, int or any type that the primary key is. /// You can override GetNameField() if you want to change which field is defined as the title/name, or override GetName() to completely customise what is returned as the name or title. /// </summary> /// <returns>The name/title of the item with the given ID</returns> public static string FetchName(object id) { if (id != null) { var rec = ActiveRecordLoader.LoadID <AutocompletePhrase>(id, "AutocompletePhrase", Otherwise.Null); if (rec != null) { return(rec.GetName()); } } return(null); }
/// <summary> /// This is a quick way of loading a record by ID and returning its title/name. /// You can pass it a string, int or any type that the primary key is. /// You can override GetNameField() if you want to change which field is defined as the title/name, or override GetName() to completely customise what is returned as the name or title. /// </summary> /// <returns>The name/title of the item with the given ID</returns> public static string FetchName(object id) { if (id != null) { var rec = ActiveRecordLoader.LoadID <ClientContactUsPerson>(id, "ClientContactUsPerson", Otherwise.Null); if (rec != null) { return(rec.GetName()); } } return(null); }
/// <summary> /// This is a quick way of loading a record by ID and returning its title/name. /// You can pass it a string, int or any type that the primary key is. /// You can override GetNameField() if you want to change which field is defined as the title/name, or override GetName() to completely customise what is returned as the name or title. /// </summary> /// <returns>The name/title of the item with the given ID</returns> public static string FetchName(object id) { if (id != null) { var rec = ActiveRecordLoader.LoadID <CompanyDetail>(id, "CompanyDetail", Otherwise.Null); if (rec != null) { return(rec.GetName()); } } return(null); }
/// <summary> /// This is a quick way of loading a record by ID and returning its title/name. /// You can pass it a string, int or any type that the primary key is. /// You can override GetNameField() if you want to change which field is defined as the title/name, or override GetName() to completely customise what is returned as the name or title. /// </summary> /// <returns>The name/title of the item with the given ID</returns> public static string FetchName(object id) { if (id != null) { var rec = ActiveRecordLoader.LoadID <ArticleDocument>(id, "ArticleDocument", Otherwise.Null); if (rec != null) { return(rec.GetName()); } } return(null); }
/// <summary> /// This is a quick way of loading a record by ID and returning its title/name. /// You can pass it a string, int or any type that the primary key is. /// You can override GetNameField() if you want to change which field is defined as the title/name, or override GetName() to completely customise what is returned as the name or title. /// </summary> /// <returns>The name/title of the item with the given ID</returns> public static string FetchName(object id) { if (id != null) { var rec = ActiveRecordLoader.LoadID <Testimonial>(id, "Testimonial", Otherwise.Null); if (rec != null) { return(rec.GetName()); } } return(null); }
/// <summary> /// This is a quick way of loading a record by ID and returning its title/name. /// You can pass it a string, int or any type that the primary key is. /// You can override GetNameField() if you want to change which field is defined as the title/name, or override GetName() to completely customise what is returned as the name or title. /// </summary> /// <returns>The name/title of the item with the given ID</returns> public static string FetchName(object id) { if (id != null) { var rec = ActiveRecordLoader.LoadID <ShoppingCart>(id, "ShoppingCart", Otherwise.Null); if (rec != null) { return(rec.GetName()); } } return(null); }
/// <summary> /// This is a quick way of loading a record by ID and returning its title/name. /// You can pass it a string, int or any type that the primary key is. /// You can override GetNameField() if you want to change which field is defined as the title/name, or override GetName() to completely customise what is returned as the name or title. /// </summary> /// <returns>The name/title of the item with the given ID</returns> public static string FetchName(object id) { if (id != null) { var rec = ActiveRecordLoader.LoadID <MapRegion>(id, "MapRegion", Otherwise.Null); if (rec != null) { return(rec.GetName()); } } return(null); }
/// <summary> /// This is a quick way of loading a record by ID and returning its title/name. /// You can pass it a string, int or any type that the primary key is. /// You can override GetNameField() if you want to change which field is defined as the title/name, or override GetName() to completely customise what is returned as the name or title. /// </summary> /// <returns>The name/title of the item with the given ID</returns> public static string FetchName(object id) { if (id != null) { var rec = ActiveRecordLoader.LoadID <GalleryCategory>(id, "GalleryCategory", Otherwise.Null); if (rec != null) { return(rec.GetName()); } } return(null); }
/// <summary> /// This is a quick way of loading a record by ID and returning its title/name. /// You can pass it a string, int or any type that the primary key is. /// You can override GetNameField() if you want to change which field is defined as the title/name, or override GetName() to completely customise what is returned as the name or title. /// </summary> /// <returns>The name/title of the item with the given ID</returns> public static string FetchName(object id) { if (id != null) { var rec = ActiveRecordLoader.LoadID <HomepageSlide>(id, "HomepageSlide", Otherwise.Null); if (rec != null) { return(rec.GetName()); } } return(null); }
public ActionResult SaveSortOrder(string sortOrder) { int pos = 1; List <int> ids = sortOrder.Split(",").ToList(s => s.ToInt(0)); foreach (var id in ids) { Sql sql = new Sql("update Product set SortPosition=", pos * 10, "where ProductID=", id); sql.Execute(); pos++; } ActiveRecordLoader.ClearCache("Product"); return(Content("Sort order saved.")); }
/// <summary> /// Loads a record from the GalleryCategory table in the database given the supplied primary key value. /// If found in the cache, record will be loaded from the cache. /// If NOT FOUND, you can specify the behaviour with Beweb.Otherwise - eg GalleryCategory.LoadID(55, Otherwise.Null) will return null if not found. /// </summary> /// <example>var g = GalleryCategory.LoadID(55);</example> /// <param name="id">Primary key of GalleryCategory</param> /// <returns>An instance of GalleryCategory containing the data in the record</returns> public static GalleryCategory LoadID(int id, Otherwise otherwise) { // see if already in cache, else create sql and load // GalleryCategory record = null; // record = GalleryCategory.GetFromCache(id); //comment out if not int pk type // if (record == null) // { // var sql = new Sql("where GalleryCategoryID=", Sql.Sqlize(id)); // record = new GalleryCategory(); // if (!record.LoadData(sql)) return otherwise.Execute<GalleryCategory>(); // record.StoreInCache(); // } // return record; return(ActiveRecordLoader.LoadID <GalleryCategory>(id, "GalleryCategory", otherwise)); }
/// <summary> /// Loads a record from the MapRegion table in the database given the supplied primary key value. /// If found in the cache, record will be loaded from the cache. /// If NOT FOUND, you can specify the behaviour with Beweb.Otherwise - eg MapRegion.LoadID(55, Otherwise.Null) will return null if not found. /// </summary> /// <example>var g = MapRegion.LoadID(55);</example> /// <param name="id">Primary key of MapRegion</param> /// <returns>An instance of MapRegion containing the data in the record</returns> public static MapRegion LoadID(int id, Otherwise otherwise) { // see if already in cache, else create sql and load // MapRegion record = null; // record = MapRegion.GetFromCache(id); //comment out if not int pk type // if (record == null) // { // var sql = new Sql("where MapRegionID=", Sql.Sqlize(id)); // record = new MapRegion(); // if (!record.LoadData(sql)) return otherwise.Execute<MapRegion>(); // record.StoreInCache(); // } // return record; return(ActiveRecordLoader.LoadID <MapRegion>(id, "MapRegion", otherwise)); }
/// <summary> /// Loads a record from the NewsRSS table in the database given the supplied primary key value. /// If found in the cache, record will be loaded from the cache. /// If NOT FOUND, you can specify the behaviour with Beweb.Otherwise - eg NewsRSS.LoadID(55, Otherwise.Null) will return null if not found. /// </summary> /// <example>var g = NewsRSS.LoadID(55);</example> /// <param name="id">Primary key of NewsRSS</param> /// <returns>An instance of NewsRSS containing the data in the record</returns> public static NewsRSS LoadID(int id, Otherwise otherwise) { // see if already in cache, else create sql and load // NewsRSS record = null; // record = NewsRSS.GetFromCache(id); //comment out if not int pk type // if (record == null) // { // var sql = new Sql("where NewsRSSID=", Sql.Sqlize(id)); // record = new NewsRSS(); // if (!record.LoadData(sql)) return otherwise.Execute<NewsRSS>(); // record.StoreInCache(); // } // return record; return(ActiveRecordLoader.LoadID <NewsRSS>(id, "NewsRSS", otherwise)); }
/// <summary> /// Loads a record from the Event table in the database given the supplied primary key value. /// If found in the cache, record will be loaded from the cache. /// If NOT FOUND, you can specify the behaviour with Beweb.Otherwise - eg Event.LoadID(55, Otherwise.Null) will return null if not found. /// </summary> /// <example>var g = Event.LoadID(55);</example> /// <param name="id">Primary key of Event</param> /// <returns>An instance of Event containing the data in the record</returns> public static Event LoadID(int id, Otherwise otherwise) { // see if already in cache, else create sql and load // Event record = null; // record = Event.GetFromCache(id); //comment out if not int pk type // if (record == null) // { // var sql = new Sql("where EventID=", Sql.Sqlize(id)); // record = new Event(); // if (!record.LoadData(sql)) return otherwise.Execute<Event>(); // record.StoreInCache(); // } // return record; return(ActiveRecordLoader.LoadID <Event>(id, "Event", otherwise)); }
/// <summary> /// Loads a record from the FAQItem table in the database given the supplied primary key value. /// If found in the cache, record will be loaded from the cache. /// If NOT FOUND, you can specify the behaviour with Beweb.Otherwise - eg FAQItem.LoadID(55, Otherwise.Null) will return null if not found. /// </summary> /// <example>var g = FAQItem.LoadID(55);</example> /// <param name="id">Primary key of FAQItem</param> /// <returns>An instance of FAQItem containing the data in the record</returns> public static FAQItem LoadID(int id, Otherwise otherwise) { // see if already in cache, else create sql and load // FAQItem record = null; // record = FAQItem.GetFromCache(id); //comment out if not int pk type // if (record == null) // { // var sql = new Sql("where FAQItemID=", Sql.Sqlize(id)); // record = new FAQItem(); // if (!record.LoadData(sql)) return otherwise.Execute<FAQItem>(); // record.StoreInCache(); // } // return record; return ActiveRecordLoader.LoadID<FAQItem>(id, "FAQItem", otherwise); }
/// <summary> /// Loads a record from the HomepageSlide table in the database given the supplied primary key value. /// If found in the cache, record will be loaded from the cache. /// If NOT FOUND, you can specify the behaviour with Beweb.Otherwise - eg HomepageSlide.LoadID(55, Otherwise.Null) will return null if not found. /// </summary> /// <example>var g = HomepageSlide.LoadID(55);</example> /// <param name="id">Primary key of HomepageSlide</param> /// <returns>An instance of HomepageSlide containing the data in the record</returns> public static HomepageSlide LoadID(int id, Otherwise otherwise) { // see if already in cache, else create sql and load // HomepageSlide record = null; // record = HomepageSlide.GetFromCache(id); //comment out if not int pk type // if (record == null) // { // var sql = new Sql("where HomepageSlideID=", Sql.Sqlize(id)); // record = new HomepageSlide(); // if (!record.LoadData(sql)) return otherwise.Execute<HomepageSlide>(); // record.StoreInCache(); // } // return record; return(ActiveRecordLoader.LoadID <HomepageSlide>(id, "HomepageSlide", otherwise)); }
/// <summary> /// Loads a record from the DocumentDownload table in the database given the supplied primary key value. /// If found in the cache, record will be loaded from the cache. /// If NOT FOUND, you can specify the behaviour with Beweb.Otherwise - eg DocumentDownload.LoadID(55, Otherwise.Null) will return null if not found. /// </summary> /// <example>var g = DocumentDownload.LoadID(55);</example> /// <param name="id">Primary key of DocumentDownload</param> /// <returns>An instance of DocumentDownload containing the data in the record</returns> public static DocumentDownload LoadID(int id, Otherwise otherwise) { // see if already in cache, else create sql and load // DocumentDownload record = null; // record = DocumentDownload.GetFromCache(id); //comment out if not int pk type // if (record == null) // { // var sql = new Sql("where DocumentDownloadID=", Sql.Sqlize(id)); // record = new DocumentDownload(); // if (!record.LoadData(sql)) return otherwise.Execute<DocumentDownload>(); // record.StoreInCache(); // } // return record; return(ActiveRecordLoader.LoadID <DocumentDownload>(id, "DocumentDownload", otherwise)); }
private void Save(Models.DocumentCategory record, bool isNew) { // add any code to update other fields/tables here record.Save(); if (record.ParentDocumentCategoryID.HasValue && record.PageID.HasValue) { record.PageID = null; record.Save(); } // save subform or related checkboxes here eg record.Lines.Save(); //ifsubform: record.example.Save(); //CheckLock(record); //lockobj.UnLockTable(record.GetTableName(),record.ID); ActiveRecordLoader.ClearCache("DocumentCategory"); }
/// <summary> /// Loads a record from the Banner table in the database given the supplied primary key value. /// If found in the cache, record will be loaded from the cache. /// If NOT FOUND, you can specify the behaviour with Beweb.Otherwise - eg Banner.LoadID(55, Otherwise.Null) will return null if not found. /// </summary> /// <example>var g = Banner.LoadID(55);</example> /// <param name="id">Primary key of Banner</param> /// <returns>An instance of Banner containing the data in the record</returns> public static Banner LoadID(int id, Otherwise otherwise) { // see if already in cache, else create sql and load // Banner record = null; // record = Banner.GetFromCache(id); //comment out if not int pk type // if (record == null) // { // var sql = new Sql("where BannerID=", Sql.Sqlize(id)); // record = new Banner(); // if (!record.LoadData(sql)) return otherwise.Execute<Banner>(); // record.StoreInCache(); // } // return record; return(ActiveRecordLoader.LoadID <Banner>(id, "Banner", otherwise)); }
/// <summary> /// Loads a record from the Testimonial table in the database given the supplied primary key value. /// If found in the cache, record will be loaded from the cache. /// If NOT FOUND, you can specify the behaviour with Beweb.Otherwise - eg Testimonial.LoadID(55, Otherwise.Null) will return null if not found. /// </summary> /// <example>var g = Testimonial.LoadID(55);</example> /// <param name="id">Primary key of Testimonial</param> /// <returns>An instance of Testimonial containing the data in the record</returns> public static Testimonial LoadID(int id, Otherwise otherwise) { // see if already in cache, else create sql and load // Testimonial record = null; // record = Testimonial.GetFromCache(id); //comment out if not int pk type // if (record == null) // { // var sql = new Sql("where TestimonialID=", Sql.Sqlize(id)); // record = new Testimonial(); // if (!record.LoadData(sql)) return otherwise.Execute<Testimonial>(); // record.StoreInCache(); // } // return record; return(ActiveRecordLoader.LoadID <Testimonial>(id, "Testimonial", otherwise)); }
/// <summary> /// Loads a record from the Settings table in the database given the supplied primary key value. /// If found in the cache, record will be loaded from the cache. /// If NOT FOUND, you can specify the behaviour with Beweb.Otherwise - eg Settings.LoadID(55, Otherwise.Null) will return null if not found. /// </summary> /// <example>var g = Settings.LoadID(55);</example> /// <param name="id">Primary key of Settings</param> /// <returns>An instance of Settings containing the data in the record</returns> public static Settings LoadID(int id, Otherwise otherwise) { // see if already in cache, else create sql and load // Settings record = null; // record = Settings.GetFromCache(id); //comment out if not int pk type // if (record == null) // { // var sql = new Sql("where SettingsID=", Sql.Sqlize(id)); // record = new Settings(); // if (!record.LoadData(sql)) return otherwise.Execute<Settings>(); // record.StoreInCache(); // } // return record; return(ActiveRecordLoader.LoadID <Settings>(id, "Settings", otherwise)); }
/// <summary> /// Loads a record from the AutocompletePhrase table in the database given the supplied primary key value. /// If found in the cache, record will be loaded from the cache. /// If NOT FOUND, you can specify the behaviour with Beweb.Otherwise - eg AutocompletePhrase.LoadID(55, Otherwise.Null) will return null if not found. /// </summary> /// <example>var g = AutocompletePhrase.LoadID(55);</example> /// <param name="id">Primary key of AutocompletePhrase</param> /// <returns>An instance of AutocompletePhrase containing the data in the record</returns> public static AutocompletePhrase LoadID(int id, Otherwise otherwise) { // see if already in cache, else create sql and load // AutocompletePhrase record = null; // record = AutocompletePhrase.GetFromCache(id); //comment out if not int pk type // if (record == null) // { // var sql = new Sql("where AutocompletePhraseID=", Sql.Sqlize(id)); // record = new AutocompletePhrase(); // if (!record.LoadData(sql)) return otherwise.Execute<AutocompletePhrase>(); // record.StoreInCache(); // } // return record; return(ActiveRecordLoader.LoadID <AutocompletePhrase>(id, "AutocompletePhrase", otherwise)); }
public ActionResult SaveSortOrder(string sortOrder) { int pos = 1; List <int> ids = sortOrder.Split(",").ToList(s => s.ToInt(0)); if (Crypto.Decrypt(Web.Request["t"]) == "RelatedPage") { return(Content("skip")); } foreach (var id in ids) { Sql sql = new Sql("update " + Crypto.Decrypt(Web.Request["t"]) + " set SortPosition=", pos * 10, "where " + Crypto.Decrypt(Web.Request["p"]) + "=", id); sql.Execute(); pos++; } ActiveRecordLoader.ClearCache("Page"); return(Content("reload")); }
/// <summary> /// Deletes the given record or displays validation errors if cannot delete /// GET: /Admin/Competition/Delete/5 /// </summary> public ActionResult Delete(int id, string returnPage) { var record = Models.Competition.LoadID(id); // first delete any child records that are OK to delete //ifsubform: record.example.DeleteAll(); // then prevent deletion if any other related records exist string issues = record.CheckForDependentRecords(); if (issues.IsNotBlank()) { Web.ErrorMessage = "Cannot delete this record. " + issues; return(RedirectToEdit(record.ID)); } //ifsubform: record.example.Save(); // is this needed? record.Delete(); ActiveRecordLoader.ClearCache("Competition"); Web.InfoMessage = "Record deleted."; return(Redirect(returnPage)); }