PageRenderTime 55ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/Core/Core.cs

https://github.com/sixtythreebits/ddb
C# | 1000 lines | 561 code | 40 blank | 399 comment | 0 complexity | 887b8847d92248bcf3a006897c69096a MD5 | raw file
Possible License(s): LGPL-2.1
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Data.Linq;
  7. using DB;
  8. using Lib;
  9. using SystemBase;
  10. using System.Runtime.Serialization;
  11. using System.ComponentModel.DataAnnotations;
  12. using System.Web;
  13. using System.Xml.Linq;
  14. namespace Core
  15. {
  16. /// <summary>
  17. /// Project Class
  18. /// </summary>
  19. public class Project : ObjectBase
  20. {
  21. #region Properties
  22. /// <summary>
  23. /// ID of Projects table
  24. /// </summary>
  25. public int? ID { get; set; }
  26. /// <summary>
  27. /// Slug (URL) field of Projects table
  28. /// </summary>
  29. [Required(ErrorMessage = "Slug is required")]
  30. public string Slug { get; set; }
  31. /// <summary>
  32. /// Title field of Projects table
  33. /// </summary>
  34. [Required(ErrorMessage = "Name of project is required")]
  35. public string Title { get; set; }
  36. /// <summary>
  37. /// Summary field of Projects table
  38. /// </summary>
  39. [DisplayFormat(ConvertEmptyStringToNull = false)]
  40. public string Summary { get; set; }
  41. /// <summary>
  42. /// Credits field of Projects table
  43. /// </summary>
  44. [DisplayFormat(ConvertEmptyStringToNull = false)]
  45. public string Credits { get; set; }
  46. /// <summary>
  47. /// SmallText field of Projects table
  48. /// </summary>
  49. [DisplayFormat(ConvertEmptyStringToNull = false)]
  50. public string SmallText { get; set; }
  51. /// <summary>
  52. /// SmallImg image file that is posted from form
  53. /// </summary>
  54. public HttpPostedFileWrapper SmallImg { get; set; }
  55. /// <summary>
  56. /// SmallImgName field of Projects table
  57. /// </summary>
  58. public string SmallImgName { get; set; }
  59. /// <summary>
  60. /// BackgroundColor field of Projects table
  61. /// </summary>
  62. public string BackgroundColor { get; set; }
  63. /// <summary>
  64. /// List of categories in project
  65. /// </summary>
  66. public List<int> ProjectCategories { get; set; }
  67. /// <summary>
  68. /// String of all category names
  69. /// </summary>
  70. public string CategoryNames { get; set; }
  71. /// <summary>
  72. /// IsPublished field of Projects table
  73. /// </summary>
  74. public bool? IsPublished { get; set; }
  75. /// <summary>
  76. /// SortIndex field of Projects table
  77. /// </summary>
  78. public int? SortIndex { get; set; }
  79. /// <summary>
  80. /// Keywords for meta tag
  81. /// </summary>
  82. public string Keywords { get; set; }
  83. /// <summary>
  84. /// Description for meta tag
  85. /// </summary>
  86. public string Description { get; set; }
  87. #endregion
  88. #region Methods
  89. /// <summary>
  90. /// CRUD Operation on Projects table
  91. /// </summary>
  92. /// <param name="Iud"></param>
  93. /// <param name="ProjectID"></param>
  94. /// <param name="Slug"></param>
  95. /// <param name="SmallImg"></param>
  96. /// <param name="Title"></param>
  97. /// <param name="SmallText"></param>
  98. /// <param name="Summary"></param>
  99. /// <param name="Credits"></param>
  100. /// <param name="BackgroundColor"></param>
  101. /// <param name="IsPiblished"></param>
  102. /// <param name="SortIndex"></param>
  103. ///
  104. public void TSP_Projects(byte Iud, int? ProjectID, string Slug, string SmallImg, string Title, string SmallText, string Summary, string Credits, string BackgroundColor, bool? IsPiblished, int? SortIndex,string Keywords,string Description )
  105. {
  106. TryExecute(string.Format("Core.Project.TSP_Projects:" +
  107. "Iud {0}, ProjectID {1}, Slug {2}, SmallImg {3}, Title {4}, SmallText {5}, Summary {6}, Credits {7}, BackgroundColor {8}, IsPiblished {9}, SortIndex {10}"
  108. , Iud, ProjectID, Slug, SmallImg, Title, SmallText, Summary, Credits, BackgroundColor, IsPiblished, SortIndex), () =>
  109. {
  110. using (var db = ConnectionFactory.GetDBCoreDataContext())
  111. {
  112. db.tsp_Projects(Iud, ref ProjectID, Slug, SmallImg, Title, SmallText, Summary, Credits, BackgroundColor, IsPiblished, SortIndex, Keywords, Description);
  113. ID = ProjectID;
  114. }
  115. });
  116. }
  117. /// <summary>
  118. /// If Iud = 0 - Update Project Table and delete/insert values in ProjectCategories table via ProjectID
  119. /// </summary>
  120. /// <param name="Iud"></param>
  121. /// <param name="Xml"></param>
  122. public void TX_Projects(byte Iud, XElement Xml)
  123. {
  124. TryExecute(string.Format("Core.Project.TX_Projects"), () =>
  125. {
  126. using (var db = ConnectionFactory.GetDBCoreDataContext())
  127. {
  128. db.tx_Projects(Iud, Xml);
  129. }
  130. });
  131. }
  132. /// <summary>
  133. /// Get Projects List
  134. /// </summary>
  135. /// <param name="Published">true - published; false - not published; null both</param>
  136. public List<Project> ListProjects(bool? Published)
  137. {
  138. return TryToGetList<Project>(string.Format("Core.Project.ListProjects: Published {0}", Published), () =>
  139. {
  140. using (var db = ConnectionFactory.GetDBCoreDataContext())
  141. {
  142. return db.List_Pojects(Published).OrderBy(pro => pro.SortIndex).OrderByDescending(pro => pro.CRTime).Select(pro => new Project()
  143. {
  144. ID = pro.ProjectID
  145. , Slug = pro.Slug
  146. , Title = pro.Title
  147. , SmallText = pro.SmallText
  148. , SmallImgName = pro.SmallImg
  149. , BackgroundColor = pro.BackgroundColor
  150. , Summary = pro.Summary
  151. , Credits = pro.Credits
  152. , IsPublished = pro.IsPublished
  153. , SortIndex = pro.SortIndex
  154. , CategoryNames = pro.Categories
  155. ,Keywords = pro.KeyWords
  156. ,Description = pro.Description
  157. }).ToList();
  158. }
  159. });
  160. }
  161. /// <summary>
  162. /// Get project raw by project ID
  163. /// </summary>
  164. /// <param name="ID"></param>
  165. /// <returns></returns>
  166. public Project GetProjectByID(int ID)
  167. {
  168. return TryToReturn<Project>(string.Format("Core.Project.GetProjectByID: ID {0}", ID), () =>
  169. {
  170. using (var db = ConnectionFactory.GetDBCoreDataContext())
  171. {
  172. return db.Get_Project_By_ID(ID).Select(pro => new Project()
  173. {
  174. ID = pro.ProjectID
  175. ,Slug = pro.Slug
  176. ,Title = pro.Title
  177. ,SmallText = pro.SmallText
  178. ,SmallImgName = pro.SmallImg
  179. ,BackgroundColor = pro.BackgroundColor
  180. ,Summary = pro.Summary
  181. ,Credits = pro.Credits
  182. ,IsPublished = pro.IsPublished
  183. ,SortIndex = pro.SortIndex
  184. ,Keywords = pro.KeyWords
  185. ,Description = pro.Description
  186. }).SingleOrDefault();
  187. }
  188. });
  189. }
  190. /// <summary>
  191. /// Get project raw by Slug
  192. /// </summary>
  193. /// <param name="Slug"></param>
  194. public void GetProjectBySlug(string Slug)
  195. {
  196. TryExecute(string.Format("Core.Project.GetProjectBySlug: Slug {0}", Slug), () =>
  197. {
  198. using (var db = ConnectionFactory.GetDBCoreDataContext())
  199. {
  200. XElement X = db.GetSingleProjectBySlug(Slug);
  201. ID = X.IntValueOf("project_id");
  202. Slug = X.ValueOf("slug");
  203. Title = X.ValueOf("title");
  204. SmallText = X.ValueOf("small_text");
  205. SmallImgName = X.ValueOf("small_img");
  206. BackgroundColor = X.ValueOf("background_color");
  207. Summary = X.ValueOf("summary");
  208. Credits = X.ValueOf("credits");
  209. IsPublished = X.BooleanValueOf("is_published");
  210. SortIndex = X.IntValueOf("sort_index");
  211. Keywords = X.ValueOf("keywords");
  212. Description = X.ValueOf("description");
  213. }
  214. });
  215. }
  216. /// <summary>
  217. /// Check if Slug is unique. (true unique, false not unique)
  218. /// </summary>
  219. /// <param name="_Slug"></param>
  220. public bool? IsSlugUnique(string _Slug)
  221. {
  222. return TryToReturn<bool?>(string.Format("Core.Project.IsSlugUnique: Slug {0}", _Slug), () =>
  223. {
  224. using (var db = ConnectionFactory.GetDBCoreDataContext())
  225. {
  226. return db.Is_Slug_Unique(_Slug);
  227. }
  228. });
  229. }
  230. #endregion
  231. }
  232. /// <summary>
  233. /// ProjectCategory Class
  234. /// </summary>
  235. public class ProjectCategory : ObjectBase
  236. {
  237. #region Properties
  238. /// <summary>
  239. /// ID field of ProjectCategory table
  240. /// </summary>
  241. public int ID { get; set; }
  242. /// <summary>
  243. /// ProjectID field of ProjectCategory table
  244. /// </summary>
  245. public int? ProjectID { get; set; }
  246. /// <summary>
  247. /// CategoryID field of ProjectCategory table
  248. /// </summary>
  249. public int? CategoryID { get; set; }
  250. #endregion
  251. #region Methods
  252. /// <summary>
  253. /// Get list of ProjectCategory by ProjectID
  254. /// </summary>
  255. /// <param name="ProjectID"></param>
  256. /// <returns></returns>
  257. public List<ProjectCategory> ListProjectCategories(int ProjectID)
  258. {
  259. return TryToGetList<ProjectCategory>(string.Format("Core.Project.ListProjectCategories: ProjectID {0}", ProjectID), () =>
  260. {
  261. using (var db = ConnectionFactory.GetDBCoreDataContext())
  262. {
  263. return db.List_PojectCategories(ProjectID).Select(pro => new ProjectCategory()
  264. {
  265. ID = pro.RawID
  266. ,ProjectID = pro.ProjectID
  267. ,CategoryID = pro.CategoryID
  268. }).ToList();
  269. }
  270. });
  271. }
  272. #endregion
  273. }
  274. /// <summary>
  275. /// Dictionary Class
  276. /// </summary>
  277. public class Dictionary : ObjectBase
  278. {
  279. #region Properties
  280. /// <summary>
  281. /// ID field of Dictionary table
  282. /// </summary>
  283. public int ID { get; set; }
  284. /// <summary>
  285. /// Caption field of Dictionary table
  286. /// </summary>
  287. public string Caption { get; set; }
  288. /// <summary>
  289. /// Caption1 field of Dictionary table
  290. /// </summary>
  291. public string Caption1 { get; set; }
  292. /// <summary>
  293. /// CodeVal field of Dictionary table
  294. /// </summary>
  295. public int CodeVal { get; set; }
  296. /// <summary>
  297. /// ParentID field of Dictionary table
  298. /// </summary>
  299. public int ParentID { get; set; }
  300. /// <summary>
  301. /// DictionaryCode field of Dictionary table
  302. /// </summary>
  303. public int DictionaryCode { get; set; }
  304. /// <summary>
  305. /// SortValue field of Dictionary table
  306. /// </summary>
  307. public int SortValue { get; set; }
  308. /// <summary>
  309. /// Level field of Dictionary table
  310. /// </summary>
  311. public int Level { get; set; }
  312. #endregion
  313. /// <summary>
  314. /// Get List of Dictionary objects
  315. /// </summary>
  316. /// <param name="Level"></param>
  317. /// <param name="DictionaryCode"></param>
  318. /// <param name="ShowInvisibleItems"></param>
  319. /// <returns></returns>
  320. public List<Dictionary> ListDictionary(int? Level = null, int? DictionaryCode = null, bool? ShowInvisibleItems = null)
  321. {
  322. return TryToGetList<Dictionary>(string.Format("Core.Project.ListCategories: " +
  323. "Level {0}, DictionaryCode {1}, ShowInvisibleItems {2}", Level, DictionaryCode, ShowInvisibleItems), () =>
  324. {
  325. using (var db = ConnectionFactory.GetDBCoreDataContext())
  326. {
  327. return db.List_Dictionaries(Level, DictionaryCode, ShowInvisibleItems).Select(d => new Dictionary()
  328. {
  329. ID = d.DictionaryID
  330. ,Caption = d.Caption
  331. }).ToList();
  332. }
  333. });
  334. }
  335. /// <summary>
  336. /// Get DictionaryID by CodeVal
  337. /// </summary>
  338. /// <param name="DictionaryCode"></param>
  339. /// <param name="CodeVal"></param>
  340. /// <returns></returns>
  341. public int? GetDictionaryIDByCodeVal(int? DictionaryCode, int? CodeVal)
  342. {
  343. return TryToReturn<int?>(string.Format("Core.Dictionary.GetDictionaryIDByCodeVal: DictionaryCode {0}, CodeVal {1}", DictionaryCode, CodeVal), () =>
  344. {
  345. using (var db = ConnectionFactory.GetDBCoreDataContext())
  346. {
  347. return db.Get_DictionaryID_ByCodeVal(DictionaryCode, CodeVal);
  348. }
  349. });
  350. }
  351. }
  352. /// <summary>
  353. /// ProjectAssets Class
  354. /// </summary>
  355. public class ProjectAssets : ObjectBase
  356. {
  357. #region Properties
  358. /// <summary>
  359. /// ID field of ProjectAssets table
  360. /// </summary>
  361. public int? ID { get; set; }
  362. /// <summary>
  363. /// ProjectID field of ProjectAssets table
  364. /// </summary>
  365. public int ProjectID { get; set; }
  366. /// <summary>
  367. /// TypeID field of ProjectAssets table
  368. /// </summary>
  369. public int? TypeID { get; set; }
  370. /// <summary>
  371. /// CodeVal field of ProjectAssets table
  372. /// </summary>
  373. public int? CodeVal { get; set; }
  374. /// <summary>
  375. /// Position field of ProjectAssets table
  376. /// </summary>
  377. public int? Position { get; set; }
  378. /// <summary>
  379. /// Text field of ProjectAssets table
  380. /// </summary>
  381. public string Text { get; set; }
  382. /// <summary>
  383. /// Title field of ProjectAssets table
  384. /// </summary>
  385. public string Title { get; set; }
  386. /// <summary>
  387. /// Media field of ProjectAssets table
  388. /// </summary>
  389. public string Media { get; set; }
  390. /// <summary>
  391. /// Image file that is posted from form
  392. /// </summary>
  393. public HttpPostedFileBase imgFile { get; set; }
  394. #endregion
  395. #region Methods
  396. /// <summary>
  397. /// CRUD operation on ProjectAssets table
  398. /// </summary>
  399. /// <param name="Iud"></param>
  400. /// <param name="ProjectAssetsID"></param>
  401. /// <param name="ProjectID"></param>
  402. /// <param name="TypeID"></param>
  403. /// <param name="Position"></param>
  404. /// <param name="Text"></param>
  405. /// <param name="Title"></param>
  406. /// <param name="Media"></param>
  407. public void TSP_ProjectAssets(byte Iud, int? ProjectAssetsID, int? ProjectID, int? TypeID, int? Position, string Text, string Title, string Media)
  408. {
  409. TryExecute(string.Format("Core.Project.TSP_ProjectAssets: Iud {0}, ProjectAssetsID {1}, ProjectID {2}, TypeID {3}, Position {4}, Text {5}, Title {6}, Media {7} "
  410. , Iud, ProjectAssetsID, ProjectID, TypeID, Position, Text, Title, Media), () =>
  411. {
  412. using (var db = ConnectionFactory.GetDBCoreDataContext())
  413. {
  414. db.tsp_ProjectAssets(Iud, ref ProjectAssetsID, ProjectID, TypeID, Position, Text, Title, Media);
  415. ID = ProjectAssetsID;
  416. }
  417. });
  418. }
  419. /// <summary>
  420. /// Get list of ProjectAssets objects by ProjectID
  421. /// </summary>
  422. /// <param name="ProjectID"></param>
  423. /// <returns></returns>
  424. public List<ProjectAssets> ListProjectAssets(int? ProjectID)
  425. {
  426. return TryToGetList<ProjectAssets>(string.Format("Core.Project.ListProjectAssets: ProjectID {0}", ProjectID), () =>
  427. {
  428. using (var db = ConnectionFactory.GetDBCoreDataContext())
  429. {
  430. return db.List_PojectAssets(ProjectID).OrderBy(d => d.Position).Select(d => new ProjectAssets()
  431. {
  432. ID = d.ProjectAssetID
  433. ,ProjectID = d.ProjectID
  434. ,TypeID = d.TypeID
  435. ,Position = d.Position
  436. ,Text = d.Text
  437. ,Title = d.Title
  438. ,Media = d.Media
  439. ,CodeVal = d.CodeVal
  440. }).ToList();
  441. }
  442. });
  443. }
  444. /// <summary>
  445. /// Get new position for ProjectAssets
  446. /// </summary>
  447. /// <param name="ProjectID"></param>
  448. /// <returns></returns>
  449. public int? GetNewPosition(int ProjectID)
  450. {
  451. return TryToReturn<int?>(string.Format("Core.ProjectAssets.GetNewPosition: ProjectID {0}", ProjectID), () =>
  452. {
  453. using (var db = ConnectionFactory.GetDBCoreDataContext())
  454. {
  455. return db.Get_New_Position(ProjectID);
  456. }
  457. });
  458. }
  459. #endregion
  460. }
  461. /// <summary>
  462. /// People Class
  463. /// </summary>
  464. public class People : ObjectBase
  465. {
  466. #region Properties
  467. /// <summary>
  468. /// ID field of People table
  469. /// </summary>
  470. public int? ID { get; set; }
  471. /// <summary>
  472. /// PeopleName field of People table
  473. /// </summary>
  474. [Required(ErrorMessage = "Full Name is required")]
  475. public string PeopleName { get; set; }
  476. /// <summary>
  477. /// Position field of People table
  478. /// </summary>
  479. [DisplayFormat(ConvertEmptyStringToNull = false)]
  480. public string Position { get; set; }
  481. /// <summary>
  482. /// ImgName field of People table
  483. /// </summary>
  484. public string ImgName { get; set; }
  485. /// <summary>
  486. /// Image file that is posted from form
  487. /// </summary>
  488. public HttpPostedFileWrapper ImgFile { get; set; }
  489. /// <summary>
  490. /// MusicName field of People table
  491. /// </summary>
  492. public string MusicName { get; set; }
  493. /// <summary>
  494. /// Music file that is posted from form
  495. /// </summary>
  496. public HttpPostedFileWrapper MusicFile { get; set; }
  497. /// <summary>
  498. /// SortIndex field of People table
  499. /// </summary>
  500. public int? SortIndex { get; set; }
  501. /// <summary>
  502. /// Theme field of People table
  503. /// </summary>
  504. public string Theme { get; set; }
  505. /// <summary>
  506. /// IsPublished field of People table
  507. /// </summary>
  508. public bool? IsPublished { get; set; }
  509. /// <summary>
  510. /// Slug field of People table
  511. /// </summary>
  512. public string Slug { get; set; }
  513. /// <summary>
  514. /// List of People categories
  515. /// </summary>
  516. public List<int> PeopleCategories { get; set; }
  517. /// <summary>
  518. /// String of all Categories names
  519. /// </summary>
  520. public string CategoryNames { get; set; }
  521. #endregion
  522. #region Methods
  523. /// <summary>
  524. /// Get list of People objects
  525. /// </summary>
  526. /// <param name="Published"></param>
  527. /// <returns></returns>
  528. public List<People> ListPeoples(bool? Published)
  529. {
  530. return TryToGetList<People>(string.Format("Core.People.ListPeoples: Published {0}", Published), () =>
  531. {
  532. using (var db = ConnectionFactory.GetDBCoreDataContext())
  533. {
  534. return db.List_Peoples(Published).OrderBy(p => p.SortIndex).OrderByDescending(p => p.CRTime).Select(p => new People()
  535. {
  536. ID = p.PeopleID
  537. ,PeopleName = p.PeopleName
  538. ,Position = p.Position
  539. ,ImgName = p.ImgName
  540. ,MusicName = p.MusicName
  541. ,SortIndex = p.SortIndex
  542. ,Theme = p.Theme
  543. ,IsPublished = p.IsPublished
  544. ,Slug = p.Slug
  545. ,CategoryNames = p.Categories
  546. }).ToList();
  547. }
  548. });
  549. }
  550. /// <summary>
  551. /// CRUD opertion on Peoples table
  552. /// </summary>
  553. /// <param name="Iud"></param>
  554. /// <param name="_PeopleID"></param>
  555. /// <param name="_PeopleName"></param>
  556. /// <param name="_Position"></param>
  557. /// <param name="_ImgName"></param>
  558. /// <param name="_MusicName"></param>
  559. /// <param name="_SortIndex"></param>
  560. /// <param name="_Theme"></param>
  561. /// <param name="_IsPublished"></param>
  562. /// <param name="_Slug"></param>
  563. public void TSP_Peoples(byte Iud, int? _PeopleID, string _PeopleName, string _Position, string _ImgName, string _MusicName, int? _SortIndex, string _Theme, bool ? _IsPublished, string _Slug)
  564. {
  565. TryExecute(string.Format("Core.Project.TSP_ProjectAssets: " +
  566. "Iud {0}, PeopleID {1}, PeopleName {2}, Position {3}, ImgName {4}, MusicName {5}, SortIndex {6}, Theme {7}, IsPublished {8}, Slug {9}",
  567. Iud, _PeopleID, _PeopleName, _Position, _ImgName, _MusicName, _SortIndex, _Theme, _IsPublished, _Slug), () =>
  568. {
  569. using (var db = ConnectionFactory.GetDBCoreDataContext())
  570. {
  571. db.tsp_Peoples(Iud, ref _PeopleID, _PeopleName, _Position, _ImgName, _MusicName, _SortIndex, _Theme, _IsPublished, _Slug);
  572. }
  573. });
  574. }
  575. /// <summary>
  576. /// If Iud = 0 - Update People Table and delete/insert values in PeopleCategories table via PeopleID
  577. /// </summary>
  578. /// <param name="Iud"></param>
  579. /// <param name="Xml"></param>
  580. public void TX_Peoples(byte Iud, XElement Xml)
  581. {
  582. TryExecute(string.Format("Core.People.TX_Peoples"), () =>
  583. {
  584. using (var db = ConnectionFactory.GetDBCoreDataContext())
  585. {
  586. db.tx_Peoples(Iud, Xml);
  587. }
  588. });
  589. }
  590. /// <summary>
  591. /// Check if Slug is unique in Peoples table
  592. /// </summary>
  593. /// <param name="_Slug"></param>
  594. /// <returns></returns>
  595. public bool? IsSlugUniqueInPeoples(string _Slug)
  596. {
  597. return TryToReturn<bool?>(string.Format("Core.People.IsSlugUniqueInPeoples: Slug {0}", _Slug), () =>
  598. {
  599. using (var db = ConnectionFactory.GetDBCoreDataContext())
  600. {
  601. return db.IsSlugUniqueInPeoples(_Slug);
  602. }
  603. });
  604. }
  605. /// <summary>
  606. /// Get People object by Slug
  607. /// </summary>
  608. /// <param name="Slug"></param>
  609. public void GetPeopleBySlug(string Slug)
  610. {
  611. TryExecute(string.Format("Core.People.GetPeopleBySlug: Slug {0}", Slug), () =>
  612. {
  613. using (var db = ConnectionFactory.GetDBCoreDataContext())
  614. {
  615. XElement X = db.GetSinglePeopleBySlug(Slug);
  616. this.ID = X.IntValueOf("people_id");
  617. this.Position = X.ValueOf("position");
  618. this.ImgName = X.ValueOf("img_name");
  619. this.MusicName = X.ValueOf("music_name");
  620. this.SortIndex = X.IntValueOf("sort_index");
  621. this.Theme = X.ValueOf("theme");
  622. this.IsPublished = X.BooleanValueOf("is_published");
  623. this.Slug = X.ValueOf("slug");
  624. }
  625. });
  626. }
  627. #endregion
  628. }
  629. /// <summary>
  630. /// PeopleCategory Class
  631. /// </summary>
  632. public class PeopleCategory : ObjectBase
  633. {
  634. #region Properties
  635. /// <summary>
  636. /// ID field of PeopleCategory table
  637. /// </summary>
  638. public int ID { get; set; }
  639. /// <summary>
  640. /// PeopleID field of PeopleCategory table
  641. /// </summary>
  642. public int? PeopleID { get; set; }
  643. /// <summary>
  644. /// CategoryID field of PeopleCategory table
  645. /// </summary>
  646. public int? CategoryID { get; set; }
  647. #endregion
  648. #region Methods
  649. /// <summary>
  650. /// Get list of PeopleCategory objects
  651. /// </summary>
  652. /// <param name="PeopleID"></param>
  653. /// <returns></returns>
  654. public List<PeopleCategory> ListPeopleCategories(int PeopleID)
  655. {
  656. return TryToGetList<PeopleCategory>(string.Format("Core.PeopleCategory.ListPeopleCategories: PeopleID {0}", PeopleID), () =>
  657. {
  658. using (var db = ConnectionFactory.GetDBCoreDataContext())
  659. {
  660. return db.List_PeopleCategories(PeopleID).Select(pro => new PeopleCategory()
  661. {
  662. ID = pro.RawID
  663. ,
  664. PeopleID = pro.PeopleID
  665. ,
  666. CategoryID = pro.CategoryID
  667. }).ToList();
  668. }
  669. });
  670. }
  671. #endregion
  672. }
  673. /// <summary>
  674. /// FrontPage Class
  675. /// </summary>
  676. public class FrontPage : ObjectBase
  677. {
  678. #region Properties
  679. /// <summary>
  680. /// ID field of FrontPage table
  681. /// </summary>
  682. public int ID { get; set; }
  683. /// <summary>
  684. /// Name field of FrontPage table
  685. /// </summary>
  686. [Required(ErrorMessage = "Name is required")]
  687. public string Name { get; set; }
  688. /// <summary>
  689. /// Text field of FrontPage table
  690. /// </summary>
  691. [DisplayFormat(ConvertEmptyStringToNull = false)]
  692. public string Text { get; set; }
  693. /// <summary>
  694. /// ImageName field of FrontPage table
  695. /// </summary>
  696. public string ImageName { get; set; }
  697. /// <summary>
  698. /// Posted Image file
  699. /// </summary>
  700. public HttpPostedFileWrapper ImageFile { get; set; }
  701. /// <summary>
  702. /// Link field of FrontPage table
  703. /// </summary>
  704. [DisplayFormat(ConvertEmptyStringToNull = false)]
  705. public string Link { get; set; }
  706. /// <summary>
  707. /// SortIndex field of FrontPage table
  708. /// </summary>
  709. public int? SortIndex { get; set; }
  710. /// <summary>
  711. /// Theme field of FrontPage table
  712. /// </summary>
  713. [Required(ErrorMessage = "Theme is required")]
  714. public string Theme { get; set; }
  715. #endregion
  716. #region Methods
  717. /// <summary>
  718. /// Get list of FrontPage objects
  719. /// </summary>
  720. /// <returns></returns>
  721. public List<FrontPage> ListFrontPage()
  722. {
  723. return TryToGetList<FrontPage>(string.Format("Core.FrontPage.ListFrontPage"), () =>
  724. {
  725. using (var db = ConnectionFactory.GetDBCoreDataContext())
  726. {
  727. return db.List_FrontPage().OrderByDescending(f => f.CRTime).Select(f => new FrontPage()
  728. {
  729. ID = f.FrontPageID
  730. ,Name = f.Name
  731. ,Text = f.Text
  732. ,ImageName = f.ImageName
  733. ,Link = f.Link
  734. ,Theme = f.Theme
  735. }).ToList();
  736. }
  737. });
  738. }
  739. /// <summary>
  740. /// CRUD operation on FrontPage table
  741. /// </summary>
  742. /// <param name="Iud"></param>
  743. /// <param name="_FrontPageID"></param>
  744. /// <param name="_Name"></param>
  745. /// <param name="_Text"></param>
  746. /// <param name="_ImageName"></param>
  747. /// <param name="_Link"></param>
  748. /// <param name="_SortIndex"></param>
  749. /// <param name="_Theme"></param>
  750. public void TSP_FrontPage(byte Iud, int? _FrontPageID, string _Name, string _Text, string _ImageName, string _Link, int? _SortIndex, string _Theme)
  751. {
  752. TryExecute(string.Format("Core.FrontPage.TSP_FrontPage: " +
  753. "Iud {0}, FrontPageID {1}, Name {2}, Text {3}, ImageName {4}, Link {5}, SortIndex {6}, Theme {7}",
  754. Iud, _FrontPageID, _Name, _Text, _ImageName, _Link, _SortIndex, _Theme), () =>
  755. {
  756. using (var db = ConnectionFactory.GetDBCoreDataContext())
  757. {
  758. db.tsp_FrontPage(Iud, ref _FrontPageID, _Name, _Text, _ImageName, _Link, _SortIndex, _Theme);
  759. }
  760. });
  761. }
  762. #endregion
  763. }
  764. /// <summary>
  765. /// Client Class
  766. /// </summary>
  767. public class Client : ObjectBase
  768. {
  769. #region Properties
  770. /// <summary>
  771. /// ClientsID field of Clients table
  772. /// </summary>
  773. public int ID { get; set; }
  774. /// <summary>
  775. /// LogoName field of Clients table
  776. /// </summary>
  777. public string LogoName { get; set; }
  778. /// <summary>
  779. /// Posted Logo file
  780. /// </summary>
  781. public HttpPostedFileWrapper LogoFile { get; set; }
  782. /// <summary>
  783. /// SortIndex field of Clients table
  784. /// </summary>
  785. public int? SortIndex { get; set; }
  786. /// <summary>
  787. /// Link field of Clients table
  788. /// </summary>
  789. [DisplayFormat(ConvertEmptyStringToNull = false)]
  790. public string Link { get; set; }
  791. #endregion
  792. #region Methods
  793. /// <summary>
  794. /// Get list of Client objects
  795. /// </summary>
  796. /// <returns></returns>
  797. public List<Client> ListClients()
  798. {
  799. return TryToGetList<Client>(string.Format("Core.Client.ListClients"), () =>
  800. {
  801. using (var db = ConnectionFactory.GetDBCoreDataContext())
  802. {
  803. return db.List_Clients().OrderByDescending(f => f.CRTime).Select(c => new Client()
  804. {
  805. ID = c.ClientsID,
  806. LogoName = c.LogoName,
  807. SortIndex = c.SortIndex ,
  808. Link = c.Link
  809. }).ToList();
  810. }
  811. });
  812. }
  813. /// <summary>
  814. /// CRUD operations on Clients table
  815. /// </summary>
  816. /// <param name="Iud"></param>
  817. /// <param name="ClientsID"></param>
  818. /// <param name="LogoName"></param>
  819. /// <param name="SortIndex"></param>
  820. public void TSP_Clients(byte Iud, int? ClientsID, string LogoName, int? SortIndex, string Link)
  821. {
  822. TryExecute(string.Format("Core.Clients.TSP_Clients: " +
  823. "Iud {0}, ClientsID {1}, LogoName {2}, SortIndex {3}, Link {4} ",
  824. Iud, ClientsID, LogoName, SortIndex, Link), () =>
  825. {
  826. using (var db = ConnectionFactory.GetDBCoreDataContext())
  827. {
  828. db.tsp_Clients(Iud, ref ClientsID, LogoName, SortIndex, Link);
  829. }
  830. });
  831. }
  832. #endregion
  833. }
  834. public class About : ObjectBase
  835. {
  836. #region Properties
  837. /// <summary>
  838. /// AboutID field of About table
  839. /// </summary>
  840. public int ID { get; set; }
  841. /// <summary>
  842. /// CodeVal field of About table
  843. /// </summary>
  844. public int CodeVal { get; set; }
  845. /// <summary>
  846. /// BatterflyImage field of About table
  847. /// </summary>
  848. public string BatterflyImage { get; set; }
  849. /// <summary>
  850. /// DDBImage field of About table
  851. /// </summary>
  852. public string DDBImage { get; set; }
  853. /// <summary>
  854. /// BatterflyText field of About table
  855. /// </summary>
  856. [Required(ErrorMessage = "Text is required")]
  857. public string BatterflyText { get; set; }
  858. /// <summary>
  859. /// DDBText field of About table
  860. /// </summary>
  861. [Required(ErrorMessage = "Text is required")]
  862. public string DDBText { get; set; }
  863. #endregion
  864. #region Methods
  865. /// <summary>
  866. /// CRUD on About table
  867. /// </summary>
  868. /// <param name="Iud"></param>
  869. /// <param name="AboutID"></param>
  870. /// <param name="CodeVal"></param>
  871. /// <param name="BatterflyImage"></param>
  872. /// <param name="DDBImage"></param>
  873. /// <param name="BatterflyText"></param>
  874. /// <param name="DDBText"></param>
  875. public void TSP_About(byte Iud, int? AboutID, int? CodeVal, string BatterflyImage, string DDBImage, string BatterflyText, string DDBText)
  876. {
  877. TryExecute(string.Format("Core.About.TSP_About: " +
  878. "Iud {0}, AboutID {1}, CodeVal {2}, BatterflyImage {3}, DDBImage {4}, BatterflyText {5}, DDBText {6}",
  879. Iud, AboutID, CodeVal, BatterflyImage, DDBImage, BatterflyText, DDBText), () =>
  880. {
  881. using (var db = ConnectionFactory.GetDBCoreDataContext())
  882. {
  883. db.tsp_About(Iud, ref AboutID, CodeVal, BatterflyImage, DDBImage, BatterflyText, DDBText);
  884. }
  885. });
  886. }
  887. public About GetAbout()
  888. {
  889. return TryToReturn<About>(string.Format("Core.About.ListAbout"), () =>
  890. {
  891. using (var db = ConnectionFactory.GetDBCoreDataContext())
  892. {
  893. return db.Get_About().Select(f => new About()
  894. {
  895. ID = f.AboutID,
  896. CodeVal = f.CodeVal,
  897. BatterflyImage = f.BatterflyImage,
  898. DDBImage = f.DDBImage,
  899. BatterflyText = f.BatterflyText,
  900. DDBText = f.DDBText
  901. }).FirstOrDefault();
  902. }
  903. });
  904. }
  905. #endregion
  906. }
  907. public class Contact : ObjectBase
  908. {
  909. #region Properties
  910. /// <summary>
  911. /// ContactID field of Contact table
  912. /// </summary>
  913. public int ID { get; set; }
  914. /// <summary>
  915. /// CodeVal field of Contact table
  916. /// </summary>
  917. public int CodeVal { get; set; }
  918. /// <summary>
  919. /// ContactText field of Contact table
  920. /// </summary>
  921. public string ContactText { get; set; }
  922. #endregion
  923. #region Methods
  924. /// <summary>
  925. /// CRUD on Contact Table
  926. /// </summary>
  927. /// <param name="Iud"></param>
  928. /// <param name="ContactID"></param>
  929. /// <param name="CodeVal"></param>
  930. /// <param name="ContactText"></param>
  931. public void TSP_Contact(byte Iud, int? ContactID, int? CodeVal, string ContactText)
  932. {
  933. TryExecute(string.Format("Core.Contact.TSP_Contact: " +
  934. "Iud {0}, ContactID {1}, CodeVal {2}, ContactText {3}",
  935. Iud, ContactID, CodeVal, ContactText), () =>
  936. {
  937. using (var db = ConnectionFactory.GetDBCoreDataContext())
  938. {
  939. db.tsp_Contact(Iud, ref ContactID, CodeVal, ContactText);
  940. }
  941. });
  942. }
  943. public Contact GetContact()
  944. {
  945. return TryToReturn<Contact>(string.Format("Core.Contact.GetContact"), () =>
  946. {
  947. using (var db = ConnectionFactory.GetDBCoreDataContext())
  948. {
  949. return db.Get_Contact().Select(f => new Contact()
  950. {
  951. ID = f.ContactID,
  952. CodeVal = f.CodeVal,
  953. ContactText = f.ContactText
  954. }).FirstOrDefault();
  955. }
  956. });
  957. }
  958. #endregion
  959. }
  960. }