Example #1
0
        public static TypeSite GetTypeSite(string url)
        {
            TypeSite ReturnDef = TypeSite.Unknown;

            try
            {
                if (!url.StartsWith("http://") && !url.StartsWith("https://"))
                {
                    url = "http://" + url;
                }
                Uri      myUri     = new Uri(url);
                string[] AllDomain = myUri.Host.Split('.');
                foreach (var item in AllDomain)
                {
                    var LeechersList = Enum.GetValues(typeof(TypeSite)).Cast <TypeSite>().ToList();
                    foreach (TypeSite LeechItem in LeechersList)
                    {
                        if (item.ToLower().Contains(LeechItem.ToString().ToLower()) || LeechItem.ToString().ToLower().Contains(item.ToLower()))
                        {
                            ReturnDef = LeechItem;
                            break;
                        }
                    }
                    if (ReturnDef != TypeSite.Unknown)
                    {
                        break;
                    }
                }
            }
            catch { }
            return(ReturnDef);
        }
        // GET: Sites/Create
        public async Task <IActionResult> Create(TypeSite pSiteType)
        {
            ICollection <LevelDto> levelsDto = null;

            using (var httpClient = new HttpClient())
            {
                using (var response = await httpClient.GetAsync("http://localhost:50106/api/v1/levels/"))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        levelsDto = JsonConvert.DeserializeObject <ICollection <LevelDto> >(apiResponse);
                    }
                }
            }
            ViewData["SiteType"] = pSiteType;
            ViewData["LevelID"]  = new SelectList(levelsDto, "LevelID", "Name");
            return(View());
        }