/// <summary> /// Adds a new section to the forum system. /// </summary> /// <param name="name">The name.</param> /// <param name="description">The description.</param> /// <param name="orderNo">The order no for the section. Sections are sorted ascending on orderno.</param> /// <returns> /// the SectionID of the new section. Or Zero if failed /// </returns> public static int AddNewSection(string name, string description, short orderNo) { SectionEntity section = new SectionEntity(); // fill the entity fields with data section.SectionName = name; section.SectionDescription = description; section.OrderNo = orderNo; // try to save the entity bool saveResult = section.Save(); // if succeeds return the new ID, else return Zero. if(saveResult == true) { return section.SectionID; } else { return 0; } }
/// <summary> /// Modifies the given section's name and description /// </summary> /// <param name="ID">ID of section to modify</param> /// <param name="name">New name of section</param> /// <param name="description">Description of section</param> /// <param name="orderNo">The order no for the section. Sections are sorted ascending on orderno.</param> /// <returns>True if succeeded, false otherwise</returns> public static bool ModifySection(int ID, string name, string description, short orderNo) { // load the entity from the database SectionEntity section = new SectionEntity(ID); //check if the entity is new (not found in the database), then return false. if(section.IsNew == true) { return false; } // update the fields with new values section.SectionName = name; section.SectionDescription = description; section.OrderNo = orderNo; //try to save the changes return section.Save(); }