Exemple #1
0
        public async Task <ActionResult> Save()
        {
            string input = null;

            using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
            {
                input = await reader.ReadToEndAsync();
            }
            b2cUserModel inputClaims = b2cUserModel.Parse(input);

            string apiKey    = "your-apikey";
            string apiSecret = "your-apisecret";
            string id        = inputClaims.objectid;
            string tp        = inputClaims.typingPattern;
            string quality   = "2";
            string base_url  = string.Format("https://api.typingdna.com/save/{0}", id);

            var response = await saveUser(apiKey, apiSecret, base_url, tp);

            SaveUser saveUserResponse = SaveUser.FromJson(response);

            outputModel output = new outputModel(string.Empty, HttpStatusCode.OK)
            {
                status = saveUserResponse.Status
            };

            return(Ok(output));
        }
Exemple #2
0
        public async Task <ActionResult> getuser()
        {
            string input = null;

            using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
            {
                input = await reader.ReadToEndAsync();
            }
            b2cUserModel inputClaims = b2cUserModel.Parse(input);

            string apiKey    = "your-apikey";
            string apiSecret = "your-apisecret";
            string id        = inputClaims.objectid;
            string base_url  = string.Format("https://api.typingdna.com/user/{0}", id);

            var response = await getUser(apiKey, apiSecret, base_url);

            CheckUser   checkUserResponse = CheckUser.FromJson(response);
            outputModel output            = new outputModel(string.Empty, HttpStatusCode.OK)
            {
                success = checkUserResponse.Success,
                count   = checkUserResponse.Count
            };

            return(Ok(output));
        }
Exemple #3
0
        public async Task <ActionResult> Verify()
        {
            string input = null;

            using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
            {
                input = await reader.ReadToEndAsync();
            }
            b2cUserModel inputClaims = b2cUserModel.Parse(input);

            string apiKey    = "your-apikey";
            string apiSecret = "your-apisecret";
            string id        = inputClaims.objectid;
            string tp        = inputClaims.typingPattern;
            int    count     = inputClaims.count;
            //string quality = "2";
            string base_url = string.Format("https://api.typingdna.com/verify/{0}", id);

            var response = await verifyUser(apiKey, apiSecret, base_url, tp);

            VerifyUser verifyUserResponse = VerifyUser.FromJson(response);
            bool       savePattern        = false;

            if (inputClaims.count > 0 && verifyUserResponse.NetScore >= 80)
            {
                savePattern = true;
            }

            bool promptMFAFlag = false;

            //training model
            if (inputClaims.count <= 2)// && verifyUserResponse.NetScore < 100)
            {
                promptMFAFlag = true;
            }
            // 3 - 10 saved patterns, less than 65 score prompt mfa
            if (inputClaims.count >= 3 && verifyUserResponse.NetScore <= 50 && inputClaims.count <= 5)
            {
                promptMFAFlag = true;
            }
            // 10 - 18 saved patterns, less than 70 score prompt mfa
            if (inputClaims.count > 5 && verifyUserResponse.NetScore <= 65)
            {
                promptMFAFlag = true;
            }

            outputModel output = new outputModel(string.Empty, HttpStatusCode.OK)
            {
                netscore          = verifyUserResponse.NetScore,
                promptMFA         = promptMFAFlag,
                saveTypingPattern = savePattern
            };

            return(Ok(output));
        }
        public List <outputModel> output1(List <Company> companies)
        {
            List <Stats>       stats       = new List <Stats>();
            List <outputModel> statsResult = new List <outputModel>();
            outputModel        value       = null;

            stats = GetStats(companies);
            List <outputModel> statsList = new List <outputModel>();

            foreach (var i in stats)
            {
                value             = new outputModel();
                value.symbol      = i.symbol;
                value.companyName = i.companyName;
                value.close       = i.close;
                if ((i.week52High - i.week52Low) != 0)
                {
                    value.value = ((i.close - i.week52Low) / (i.week52High - i.week52Low)) * 100;
                }
                statsList.Add(value);
                // statsResult = statsList.Where(a => a.value > 0.82).ToList();
                statsResult = statsList.OrderByDescending(a => a.value).Take(5).ToList();
            }
            foreach (var item in statsResult)
            {
                if (item.companyName.Equals(""))
                {
                    string      companyList         = "";
                    outputModel companyName         = new outputModel();
                    String      withoutLast         = item.symbol.Substring(0, (item.symbol.Length - 1));
                    string      IEXTrading_API_PATH = BASE_URL + "stock/" + withoutLast + "/company?filter=companyName";

                    HttpResponseMessage response = httpClient.GetAsync(IEXTrading_API_PATH).GetAwaiter().GetResult();
                    if (response.IsSuccessStatusCode)
                    {
                        companyList = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
                    }

                    if (!companyList.Equals(""))
                    {
                        companyName = JsonConvert.DeserializeObject <outputModel>(companyList);
                    }

                    item.companyName = companyName.companyName;
                    response.Content.Dispose();
                }
            }
            return(statsResult.OrderByDescending(a => a.value).ToList());
        }
        public List <outputModel> output(List <Company> companies)
        {
            List <Stats>       stats       = new List <Stats>();
            List <outputModel> statsResult = new List <outputModel>();
            outputModel        value       = null;

            stats = GetStats(companies);
            List <outputModel> statsList = new List <outputModel>();

            foreach (var i in stats)
            {
                value             = new outputModel();
                value.symbol      = i.symbol;
                value.companyName = i.companyName;
                value.close       = i.close;
                if ((i.week52High - i.week52Low) != 0)
                {
                    value.value = ((i.close - i.week52Low) / (i.week52High - i.week52Low));
                }
                statsList.Add(value);
                statsResult = statsList.Where(a => a.value > 0.82).ToList();
            }
            return(statsList.OrderByDescending(a => a.value).Take(5).ToList());
        }