/ServerCydeData/objects/dynamic/backup/site-obj.cs

https://github.com/easymovet/ServerCyde · C# · 204 lines · 173 code · 24 blank · 7 comment · 59 complexity · e2a48cbaf50e05d3ee0bec3361de1397 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using SharpFusion;
  6. namespace ServerCydeData
  7. {
  8. public partial class Site : GenObjects
  9. {
  10. //Properties
  11. public Int64 id { get; set; }
  12. public DateTime? created_dt { get; set; }
  13. public DateTime? updated_dt { get; set; }
  14. public DateTime? deleted_dt { get; set; }
  15. public Byte? is_deleted { get; set; }
  16. public Int64 user_id { get; set; }
  17. public String name { get; set; }
  18. public String url { get; set; }
  19. public String FBKey { get; set; }
  20. public String FBPassword { get; set; }
  21. public String GoogleKey { get; set; }
  22. public String GooglePassword { get; set; }
  23. public String AmazonKey { get; set; }
  24. public String AmazonPassword { get; set; }
  25. public String smtpserver { get; set; }
  26. public String smtpusername { get; set; }
  27. public String smtppassword { get; set; }
  28. public Int64? Requests { get; set; }
  29. public Boolean? is_protected { get; set; }
  30. public String supportemailname { get; set; }
  31. public String supportemail { get; set; }
  32. //Parents
  33. public User parent_user_user_id { get { if (_parent_user_user_id == null || _parent_user_user_id.id == 0) _parent_user_user_id = new User(user_id, val); return _parent_user_user_id; } set { _parent_user_user_id = value; } }
  34. private User _parent_user_user_id { get; set; }
  35. //Children
  36. public IList<Custom_Tokens> get_children_custom_tokens_site_ids { get { if (_custom_tokens_site_ids == null || _custom_tokens_site_ids.Count == 0) _custom_tokens_site_ids = Custom_Tokens.GetCustom_TokenssBySite_site_id(id ,val); return _custom_tokens_site_ids; } set { _custom_tokens_site_ids = value; } }
  37. private IList<Custom_Tokens> _custom_tokens_site_ids ;
  38. public IList<Emails> get_children_emails_site_ids { get { if (_emails_site_ids == null || _emails_site_ids.Count == 0) _emails_site_ids = Emails.GetEmailssBySite_site_id(id ,val); return _emails_site_ids; } set { _emails_site_ids = value; } }
  39. private IList<Emails> _emails_site_ids ;
  40. public IList<Person> get_children_person_site_ids { get { if (_person_site_ids == null || _person_site_ids.Count == 0) _person_site_ids = Person.GetPersonsBySite_site_id(id ,val); return _person_site_ids; } set { _person_site_ids = value; } }
  41. private IList<Person> _person_site_ids ;
  42. public IList<Proc_Api> get_children_proc_api_site_ids { get { if (_proc_api_site_ids == null || _proc_api_site_ids.Count == 0) _proc_api_site_ids = Proc_Api.GetProc_ApisBySite_site_id(id ,val); return _proc_api_site_ids; } set { _proc_api_site_ids = value; } }
  43. private IList<Proc_Api> _proc_api_site_ids ;
  44. public IList<Proc_Create_Domain> get_children_proc_create_domain_site_ids { get { if (_proc_create_domain_site_ids == null || _proc_create_domain_site_ids.Count == 0) _proc_create_domain_site_ids = Proc_Create_Domain.GetProc_Create_DomainsBySite_site_id(id ,val); return _proc_create_domain_site_ids; } set { _proc_create_domain_site_ids = value; } }
  45. private IList<Proc_Create_Domain> _proc_create_domain_site_ids ;
  46. public IList<Proc_Delete_Domain> get_children_proc_delete_domain_site_ids { get { if (_proc_delete_domain_site_ids == null || _proc_delete_domain_site_ids.Count == 0) _proc_delete_domain_site_ids = Proc_Delete_Domain.GetProc_Delete_DomainsBySite_site_id(id ,val); return _proc_delete_domain_site_ids; } set { _proc_delete_domain_site_ids = value; } }
  47. private IList<Proc_Delete_Domain> _proc_delete_domain_site_ids ;
  48. public IList<Proc_Get> get_children_proc_get_site_ids { get { if (_proc_get_site_ids == null || _proc_get_site_ids.Count == 0) _proc_get_site_ids = Proc_Get.GetProc_GetsBySite_site_id(id ,val); return _proc_get_site_ids; } set { _proc_get_site_ids = value; } }
  49. private IList<Proc_Get> _proc_get_site_ids ;
  50. public IList<Proc_List_Domains> get_children_proc_list_domains_site_ids { get { if (_proc_list_domains_site_ids == null || _proc_list_domains_site_ids.Count == 0) _proc_list_domains_site_ids = Proc_List_Domains.GetProc_List_DomainssBySite_site_id(id ,val); return _proc_list_domains_site_ids; } set { _proc_list_domains_site_ids = value; } }
  51. private IList<Proc_List_Domains> _proc_list_domains_site_ids ;
  52. public IList<Proc_Modify> get_children_proc_modify_site_ids { get { if (_proc_modify_site_ids == null || _proc_modify_site_ids.Count == 0) _proc_modify_site_ids = Proc_Modify.GetProc_ModifysBySite_site_id(id ,val); return _proc_modify_site_ids; } set { _proc_modify_site_ids = value; } }
  53. private IList<Proc_Modify> _proc_modify_site_ids ;
  54. public IList<Proc_Select> get_children_proc_select_site_ids { get { if (_proc_select_site_ids == null || _proc_select_site_ids.Count == 0) _proc_select_site_ids = Proc_Select.GetProc_SelectsBySite_site_id(id ,val); return _proc_select_site_ids; } set { _proc_select_site_ids = value; } }
  55. private IList<Proc_Select> _proc_select_site_ids ;
  56. //default
  57. public Site(Validate val)
  58. {
  59. this.val = val;
  60. }
  61. //select one
  62. public Site(long ID, Validate val)
  63. {
  64. this.val = val;
  65. //select
  66. using (DAL.Procs.usp_site_sel dal = new DAL.Procs.usp_site_sel())
  67. {
  68. dal.id = ID;
  69. dal.Execute(val);
  70. foreach (DAL.Procs.usp_site_sel.ResultSet1 rs1 in dal.RS1)
  71. {
  72. this.id = rs1.id;
  73. if (rs1.created_dt.HasValue) this.created_dt = rs1.created_dt.Value;;
  74. if (rs1.updated_dt.HasValue) this.updated_dt = rs1.updated_dt.Value;;
  75. if (rs1.deleted_dt.HasValue) this.deleted_dt = rs1.deleted_dt.Value;;
  76. if (rs1.is_deleted.HasValue) this.is_deleted = rs1.is_deleted.Value;;
  77. this.user_id = rs1.user_id;
  78. this.name = rs1.name;
  79. this.url = rs1.url;
  80. this.FBKey = rs1.FBKey;
  81. this.FBPassword = rs1.FBPassword;
  82. this.GoogleKey = rs1.GoogleKey;
  83. this.GooglePassword = rs1.GooglePassword;
  84. this.AmazonKey = rs1.AmazonKey;
  85. this.AmazonPassword = rs1.AmazonPassword;
  86. this.smtpserver = rs1.smtpserver;
  87. this.smtpusername = rs1.smtpusername;
  88. this.smtppassword = rs1.smtppassword;
  89. if (rs1.Requests.HasValue) this.Requests = rs1.Requests.Value;;
  90. if (rs1.is_protected.HasValue) this.is_protected = rs1.is_protected.Value;;
  91. this.supportemailname = rs1.supportemailname;
  92. this.supportemail = rs1.supportemail;
  93. }
  94. }
  95. }
  96. #region Lists
  97. //get Sites by User user_id
  98. public static IList<Site> GetSitesByUser_user_id(Int64 user_id, Validate val)
  99. {
  100. List<Site> _Sites = new List<Site>();
  101. using (DAL.Procs.usp_site_sel_by_user_id dal = new DAL.Procs.usp_site_sel_by_user_id())
  102. {
  103. dal.user_id = user_id;
  104. dal.Execute(val);
  105. foreach (DAL.Procs.usp_site_sel_by_user_id.ResultSet1 rs1 in dal.RS1)
  106. {
  107. Site _Site = new Site(val);
  108. _Site.id = rs1.id;
  109. if (rs1.created_dt.HasValue) _Site.created_dt = rs1.created_dt.Value;
  110. if (rs1.updated_dt.HasValue) _Site.updated_dt = rs1.updated_dt.Value;
  111. if (rs1.deleted_dt.HasValue) _Site.deleted_dt = rs1.deleted_dt.Value;
  112. if (rs1.is_deleted.HasValue) _Site.is_deleted = rs1.is_deleted.Value;
  113. _Site.user_id = rs1.user_id;
  114. _Site.name = rs1.name;
  115. _Site.url = rs1.url;
  116. _Site.FBKey = rs1.FBKey;
  117. _Site.FBPassword = rs1.FBPassword;
  118. _Site.GoogleKey = rs1.GoogleKey;
  119. _Site.GooglePassword = rs1.GooglePassword;
  120. _Site.AmazonKey = rs1.AmazonKey;
  121. _Site.AmazonPassword = rs1.AmazonPassword;
  122. _Site.smtpserver = rs1.smtpserver;
  123. _Site.smtpusername = rs1.smtpusername;
  124. _Site.smtppassword = rs1.smtppassword;
  125. if (rs1.Requests.HasValue) _Site.Requests = rs1.Requests.Value;
  126. if (rs1.is_protected.HasValue) _Site.is_protected = rs1.is_protected.Value;
  127. _Site.supportemailname = rs1.supportemailname;
  128. _Site.supportemail = rs1.supportemail;
  129. _Sites.Add(_Site);
  130. }
  131. }
  132. return _Sites;
  133. }
  134. #endregion
  135. public Site UpSert(GenObjects executinguser)
  136. {
  137. val.Test(executinguser.AuthorizedLevel == AuthLevel.Write, "You are not authorized perform this action");
  138. preUpsertEvent(val);
  139. using (DAL.Procs.usp_site_ups dal = new DAL.Procs.usp_site_ups())
  140. {
  141. dal.id = this.id;
  142. dal.created_dt = this.created_dt;
  143. dal.updated_dt = this.updated_dt;
  144. dal.deleted_dt = this.deleted_dt;
  145. dal.is_deleted = this.is_deleted;
  146. dal.user_id = this.user_id;
  147. dal.name = this.name;
  148. dal.url = this.url;
  149. dal.AmazonKey = this.AmazonKey;
  150. dal.AmazonPassword = this.AmazonPassword;
  151. dal.FBKey = this.FBKey;
  152. dal.FBPassword = this.FBPassword;
  153. dal.GoogleKey = this.GoogleKey;
  154. dal.GooglePassword = this.GooglePassword;
  155. dal.Requests = this.Requests;
  156. dal.is_protected = this.is_protected;
  157. dal.smtpserver = this.smtpserver;
  158. dal.smtpusername = this.smtpusername;
  159. dal.smtppassword = this.smtppassword;
  160. dal.supportemail = this.supportemail;
  161. dal.supportemailname = this.supportemailname;
  162. dal.Execute(val);
  163. if (dal.InsertedID.HasValue)
  164. this.id = dal.InsertedID.Value;
  165. }
  166. postUpsertEvent(val);
  167. return this;
  168. }
  169. public void Delete(bool HardDelete, GenObjects executinguser)
  170. {
  171. val.Test(executinguser.AuthorizedLevel == AuthLevel.Write, "You are not authorized perform this action");
  172. using (DAL.Procs.usp_site_del dal = new DAL.Procs.usp_site_del())
  173. {
  174. dal.id = this.id;
  175. dal.hard = HardDelete;
  176. dal.Execute(val);
  177. }
  178. }
  179. }
  180. }