示例#1
0
        public CoCResult Post([FromBody] CocRequest value)
        {
            string json = JsonConvert.SerializeObject(value.AnswerList);

            Debug.WriteLine(json);
            string jsonformatted = JValue.Parse(json).ToString(Formatting.Indented);

            Debug.WriteLine(jsonformatted);
            //Debug.WriteLine(value.Num);
            //Debug.WriteLine(value.Str);
            var       alist  = JsonConvert.DeserializeObject <List <Question> >(json);
            int       one    = 0;
            int       two    = 0;
            int       three  = 0;
            CoCResult result = new CoCResult();

            result.LevelOne         = "Not Met";
            result.LevelTwo         = "Not Met";
            result.LevelThree       = "Not Met";
            result.CoCDetermination = "Not CoC";
            result.BadgeFlag        = false;

            foreach (Question a in alist)
            {
                if (a.Level == "1")
                {
                    one++;
                }
                if (a.Level == "2")
                {
                    two++;
                }
                if (a.Level == "3")
                {
                    three++;
                }
            }
            if (one > 0)
            {
                result.LevelOne = "Met";
            }
            if (two > 1)
            {
                result.LevelTwo = "Met";
            }
            if (three > 0)
            {
                result.LevelThree = "Met";
            }
            if (result.LevelOne == "Met" && result.LevelTwo == "Met" && result.LevelThree == "Met")
            {
                result.CoCDetermination = "Admin";
            }
            else if (result.LevelTwo == "Met" && result.LevelThree == "Met")
            {
                result.CoCDetermination = "Clinical";
            }
            if (!result.CoCDetermination.StartsWith("N"))
            {
                result.BadgeFlag = true;
            }

            result.Extra = "";
            return(result);
        }
示例#2
0
        public CoCResult Post([FromBody] CocRequest value)
        {
            // string json = JsonConvert.SerializeObject(value.AnswerList);
            string json = JsonConvert.SerializeObject(value);

            Debug.WriteLine(json);
            string jsonformatted = JValue.Parse(json).ToString(Formatting.Indented);

            Debug.WriteLine(jsonformatted);
            // var alist = JsonConvert.DeserializeObject<List<Question>>(json);
            var obj   = JsonConvert.DeserializeObject <CocRequest>(json);
            var alist = obj.AnswerList;
            //Debug.WriteLine("num - " + obj.SomeNum);
            //Debug.WriteLine("str - " + obj.SomeStr);
            int       one    = 0;
            int       two    = 0;
            int       three  = 0;
            CoCResult result = new CoCResult();

            result.LevelOne         = "Not Met";
            result.LevelTwo         = "Not Met";
            result.LevelThree       = "Not Met";
            result.CoCDetermination = "Not Met";
            result.BadgeFlag        = false;

            foreach (Question a in alist)
            {
                if (a.Level == "1")
                {
                    one++;
                }
                if (a.Level == "2")
                {
                    two++;
                }
                if (a.Level == "3")
                {
                    three++;
                }
            }

            result.LevelOne         = "Not Met";
            result.LevelTwo         = "Not Met";
            result.CoCDetermination = "Not Met";
            if (obj.TreatmentType == 0)
            {
                result.CoCDetermination = "N/A";
            }
            else if (obj.TreatmentType == 1 && one > 0 && two > 0)
            {
                result.LevelOne         = "Met";
                result.CoCDetermination = "Clinical";
            }
            else if (obj.TreatmentType == 2 && one > 0)
            {
                result.LevelOne         = "Met";
                result.LevelTwo         = "Met";
                result.CoCDetermination = "Admin";
            }

            if (!result.CoCDetermination.StartsWith("N"))
            {
                result.BadgeFlag = true;
            }

            result.Extra = "";
            return(result);
        }