| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- namespace SuperAdmin.Controllers
- {
- public class UtilsController : Controller
- {
- public class Constant
- {
- public const int DATA_TYPE_ONE = 1;
- public const String SERVICE_ID = "service_id";
- public const String GET_BY_ID = "newsGetById";
- public const String GET_BY_PARENT_ID = "newsGetByParentId";
- public const String INSERT_DATA = "newsInsert";
- public const String UPDATE_DATA = "newsUpdate";
- public const String DELETE_DATA = "newsDelete";
- public const String GET_PROVINCES = "usersGetProvice";
- public const String GET_TOPICS = "usersGetTopic";
- public const String ADMIN_LOGIN = "usersadminlogin";
- public const String PATH_CONTENT = "pathContent";
- public const String PATH_OUTSIDE = "pathOutside";
- public const String SERVICE_NAME = "serviceName";
- public const String SUB_DOMAIN = "subDomain";
- public const String SUB_DOMAIN_ = "subDomain_";
- public const String Enews = "\"Enews\"";
- public const String TEXT_TYPE = "1";
- public const String AUDIO_LINK = "2";
- public const String VIDEO_LINK = "3";
- public const String AUDIO_FILE = "4";
- public const String VIDEO_FILE = "5";
- public const String PICTURE_FILE = "6";
- // http code
- public const String USER_SUBSCRIBER = "1";
- public const String USER_NORMAL = "0";
- public const String WAITING_OTP = "100";
- public const String NO_DATA = "1";
- public const String SUCCESS = "0";
- public const String INVALID_MSISDN = "-1";
- public const String EXCEPTION = "-2";
- public const String USER_EXISTED = "2";
- public const String AUTHEN_FAIL = "-10";
- // code
- public const String FAILURE = "-1";
- // servive
- public const String EVENT_SERVICE = "Event";
- public const String RELIGIAO_SERVICE = "Religiao";
- public const String MAGAZINE_SERVICE = "Magazine";
- // service constant
- public const String VOCABULARY = "VOCABULARY";
- public const String GRAMMAR = "GRAMMAR";
- public const String LISTEN = "LISTEN";
- //public const String PARENT_ID = "-1";
- // type
- public const String DELETE = "0";
- public const String EDITING = "1";
- public const String ADDING = "2";
- public const String GET_CONTENT = "1";
- public const String NOT_GET_CONTENT = "0";
- public const String NEWS_BUY = "RGL_CHARGE_2";
- public const String EVENT_REGISTER_NEWS = "EVENT_REGISTER_NEWS";
- public const String EVENT_REGISTER_UPLOAD = "EVENT_REGISTER_UPLOAD";
- public const String USER_NOT_LOGIN = "-1";
- public const String HAVE_A_PROBLEM = "-20";
- public const String RESULT_SEARCH_NULL = "0";
- public const String RESULT_SEARCH = "1";
- public const String LANGUAGE_GLOBAL = "0";
- public const String LANGUAGE_LOCAL = "1";
- public const String UNKNOWN_NAME = "-1";
- public const String ROWS_ON_PAGE = "10";
- public const String ADMIN_TYPE = "1";
- public const String USER_TYPE = "0";
- public const String ALL_TYPE = "-1";
- // is_show
- public const String EVENT_ALL = "-1";
- public const String ALL_CATEGORIES = "-1";
- public const String DRAFT = "0";
- public const String WAIT_APPROVAL = "1";
- public const String APPROVED = "2";
- public const String REJECTED = "3";
- // action
- public const String CANCEL = "0";
- public const String SAVE = "1";
- public const String REJECT = "2";
- public const String PUBLISH = "3";
- public const String REMOVE = "4";
- // functions
- public const String GetTableAction = "0";
- // ENEWS
- // show in right column
- public const String STATUS_IMPORTANCE = "3";
- // show without picture
- public const String STATUS_SECONDARY = "2";
- // show in the top of page
- public const String STATUS_FOCUS = "1";
- // show by catalogue
- public const String STATUS_NORMAL = "0";
- }
- public class GetContentPath
- {
- public const String PATH = "http://tevent.tls.tl/img/event/";
- }
- public static string RandomString(int size, bool lowerCase)
- {
- StringBuilder builder = new StringBuilder();
- Random random = new Random();
- char ch;
- for (int i = 0; i < size; i++)
- {
- ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
- builder.Append(ch);
- }
- if (lowerCase)
- return builder.ToString().ToLower();
- return builder.ToString();
- }
- public static string GetStatus(String status)
- {
- switch (status)
- {
- case Constant.WAIT_APPROVAL: return "Wait approval";
- case Constant.APPROVED: return "Approved";
- case Constant.REJECTED: return "Rejected";
- default: return status;
- }
- }
- public static List<String> GetListContentType()
- {
- List<String> list = new List<string>();
- list.Add("Text type");
- list.Add("Audio link type");
- list.Add("Video link type");
- list.Add("Audio file type");
- list.Add("Video file type");
- list.Add("Picture file type");
- return list;
- }
- public static List<String> GetListIsShow()
- {
- List<String> list = new List<string>();
- list.Add("DRAFT");
- list.Add("WAIT APPROVAL");
- list.Add("APPROVED");
- list.Add("REJECTED");
- return list;
- }
- public static List<String> GetListStatus()
- {
- List<String> list = new List<string>();
- list.Add("Normal news");
- list.Add("Focus news");
- list.Add("Secondary news");
- list.Add("Important news");
- return list;
- }
- public static string ConvertStatusType(String type)
- {
- switch (type)
- {
- case "0": return "Normal news";
- case "1": return "Focus news";
- case "2": return "Secondary news";
- case "3": return "Important news";
- default: return type + " UNKNOWN CODE";
- }
- }
- public static string ConvertContentType(String type)
- {
- switch (type)
- {
- case "1": return "Text type";
- case "2": return "Audio link type";
- case "3": return "Video link type";
- case "4": return "Audio file type";
- case "5": return "Video file type";
- case "6": return "Picture file type";
- default: return type + " UNKNOWN CODE";
- }
- }
- public static string ConvertIsShow(String isShow)
- {
- switch (isShow)
- {
- case "-1": return "All TYPE";
- case "0": return "DRAFT";
- case "1": return "WAIT APPROVAL";
- case "2": return "APPROVED";
- case "3": return "REJECTED";
- //case "3": return "EVENT REJECTED";
- //case "4": return "EVENT EXPIRED";
- default: return isShow;
- }
- }
- }
- }
|