UtilsController.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.AspNetCore.Mvc;
  7. namespace SuperAdmin.Controllers
  8. {
  9. public class UtilsController : Controller
  10. {
  11. public class Constant
  12. {
  13. public const int DATA_TYPE_ONE = 1;
  14. public const String SERVICE_ID = "service_id";
  15. public const String GET_BY_ID = "newsGetById";
  16. public const String GET_BY_PARENT_ID = "newsGetByParentId";
  17. public const String INSERT_DATA = "newsInsert";
  18. public const String UPDATE_DATA = "newsUpdate";
  19. public const String DELETE_DATA = "newsDelete";
  20. public const String GET_PROVINCES = "usersGetProvice";
  21. public const String GET_TOPICS = "usersGetTopic";
  22. public const String ADMIN_LOGIN = "usersadminlogin";
  23. public const String PATH_CONTENT = "pathContent";
  24. public const String PATH_OUTSIDE = "pathOutside";
  25. public const String SERVICE_NAME = "serviceName";
  26. public const String SUB_DOMAIN = "subDomain";
  27. public const String SUB_DOMAIN_ = "subDomain_";
  28. public const String Enews = "\"Enews\"";
  29. public const String TEXT_TYPE = "1";
  30. public const String AUDIO_LINK = "2";
  31. public const String VIDEO_LINK = "3";
  32. public const String AUDIO_FILE = "4";
  33. public const String VIDEO_FILE = "5";
  34. public const String PICTURE_FILE = "6";
  35. // http code
  36. public const String USER_SUBSCRIBER = "1";
  37. public const String USER_NORMAL = "0";
  38. public const String WAITING_OTP = "100";
  39. public const String NO_DATA = "1";
  40. public const String SUCCESS = "0";
  41. public const String INVALID_MSISDN = "-1";
  42. public const String EXCEPTION = "-2";
  43. public const String USER_EXISTED = "2";
  44. public const String AUTHEN_FAIL = "-10";
  45. // code
  46. public const String FAILURE = "-1";
  47. // servive
  48. public const String EVENT_SERVICE = "Event";
  49. public const String RELIGIAO_SERVICE = "Religiao";
  50. public const String MAGAZINE_SERVICE = "Magazine";
  51. // service constant
  52. public const String VOCABULARY = "VOCABULARY";
  53. public const String GRAMMAR = "GRAMMAR";
  54. public const String LISTEN = "LISTEN";
  55. //public const String PARENT_ID = "-1";
  56. // type
  57. public const String DELETE = "0";
  58. public const String EDITING = "1";
  59. public const String ADDING = "2";
  60. public const String GET_CONTENT = "1";
  61. public const String NOT_GET_CONTENT = "0";
  62. public const String NEWS_BUY = "RGL_CHARGE_2";
  63. public const String EVENT_REGISTER_NEWS = "EVENT_REGISTER_NEWS";
  64. public const String EVENT_REGISTER_UPLOAD = "EVENT_REGISTER_UPLOAD";
  65. public const String USER_NOT_LOGIN = "-1";
  66. public const String HAVE_A_PROBLEM = "-20";
  67. public const String RESULT_SEARCH_NULL = "0";
  68. public const String RESULT_SEARCH = "1";
  69. public const String LANGUAGE_GLOBAL = "0";
  70. public const String LANGUAGE_LOCAL = "1";
  71. public const String UNKNOWN_NAME = "-1";
  72. public const String ROWS_ON_PAGE = "10";
  73. public const String ADMIN_TYPE = "1";
  74. public const String USER_TYPE = "0";
  75. public const String ALL_TYPE = "-1";
  76. // is_show
  77. public const String EVENT_ALL = "-1";
  78. public const String ALL_CATEGORIES = "-1";
  79. public const String DRAFT = "0";
  80. public const String WAIT_APPROVAL = "1";
  81. public const String APPROVED = "2";
  82. public const String REJECTED = "3";
  83. // action
  84. public const String CANCEL = "0";
  85. public const String SAVE = "1";
  86. public const String REJECT = "2";
  87. public const String PUBLISH = "3";
  88. public const String REMOVE = "4";
  89. // functions
  90. public const String GetTableAction = "0";
  91. // ENEWS
  92. // show in right column
  93. public const String STATUS_IMPORTANCE = "3";
  94. // show without picture
  95. public const String STATUS_SECONDARY = "2";
  96. // show in the top of page
  97. public const String STATUS_FOCUS = "1";
  98. // show by catalogue
  99. public const String STATUS_NORMAL = "0";
  100. }
  101. public class GetContentPath
  102. {
  103. public const String PATH = "http://tevent.tls.tl/img/event/";
  104. }
  105. public static string RandomString(int size, bool lowerCase)
  106. {
  107. StringBuilder builder = new StringBuilder();
  108. Random random = new Random();
  109. char ch;
  110. for (int i = 0; i < size; i++)
  111. {
  112. ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
  113. builder.Append(ch);
  114. }
  115. if (lowerCase)
  116. return builder.ToString().ToLower();
  117. return builder.ToString();
  118. }
  119. public static string GetStatus(String status)
  120. {
  121. switch (status)
  122. {
  123. case Constant.WAIT_APPROVAL: return "Wait approval";
  124. case Constant.APPROVED: return "Approved";
  125. case Constant.REJECTED: return "Rejected";
  126. default: return status;
  127. }
  128. }
  129. public static List<String> GetListContentType()
  130. {
  131. List<String> list = new List<string>();
  132. list.Add("Text type");
  133. list.Add("Audio link type");
  134. list.Add("Video link type");
  135. list.Add("Audio file type");
  136. list.Add("Video file type");
  137. list.Add("Picture file type");
  138. return list;
  139. }
  140. public static List<String> GetListIsShow()
  141. {
  142. List<String> list = new List<string>();
  143. list.Add("DRAFT");
  144. list.Add("WAIT APPROVAL");
  145. list.Add("APPROVED");
  146. list.Add("REJECTED");
  147. return list;
  148. }
  149. public static List<String> GetListStatus()
  150. {
  151. List<String> list = new List<string>();
  152. list.Add("Normal news");
  153. list.Add("Focus news");
  154. list.Add("Secondary news");
  155. list.Add("Important news");
  156. return list;
  157. }
  158. public static string ConvertStatusType(String type)
  159. {
  160. switch (type)
  161. {
  162. case "0": return "Normal news";
  163. case "1": return "Focus news";
  164. case "2": return "Secondary news";
  165. case "3": return "Important news";
  166. default: return type + " UNKNOWN CODE";
  167. }
  168. }
  169. public static string ConvertContentType(String type)
  170. {
  171. switch (type)
  172. {
  173. case "1": return "Text type";
  174. case "2": return "Audio link type";
  175. case "3": return "Video link type";
  176. case "4": return "Audio file type";
  177. case "5": return "Video file type";
  178. case "6": return "Picture file type";
  179. default: return type + " UNKNOWN CODE";
  180. }
  181. }
  182. public static string ConvertIsShow(String isShow)
  183. {
  184. switch (isShow)
  185. {
  186. case "-1": return "All TYPE";
  187. case "0": return "DRAFT";
  188. case "1": return "WAIT APPROVAL";
  189. case "2": return "APPROVED";
  190. case "3": return "REJECTED";
  191. //case "3": return "EVENT REJECTED";
  192. //case "4": return "EVENT EXPIRED";
  193. default: return isShow;
  194. }
  195. }
  196. }
  197. }