public async Task <List <Form> > FindForms(string token, string email, int page)
        {
            List <Form> list   = new List <Form>();
            string      apiURI = APIs.FORM_URL + "?type=form&sort=-created&owner=" + email + "&limit=" + Configs.NUMBER_ROWS_PER_PAGE
                                 + "&skip=" + (page - 1) * Configs.NUMBER_ROWS_PER_PAGE + "&select=name,title,path,tags";

            HttpResponseMessage response = await _httpUtil.GetAsync(token, apiURI);

            if (response == null || !response.IsSuccessStatusCode)
            {
                return(list);
            }

            string content = await response.Content.ReadAsStringAsync();

            JArray jArray = JArray.Parse(content);

            foreach (JObject jObject in jArray)
            {
                string name   = jObject.GetValue(Keywords.NAME).ToString();
                string title  = jObject.GetValue(Keywords.TITLE).ToString();
                string path   = jObject.GetValue(Keywords.PATH).ToString();
                long   amount = await _submissionService.CountSubmissions(token, path);

                FormControl formControl = await _formControlService.FindByPathForm(path);

                if (formControl == null)
                {
                    return(list);
                }

                string start   = formControl.Start;
                string expired = formControl.Expired;
                string assign  = formControl.Assign;

                List <string> tags = new List <string>();
                foreach (string tag in JArray.Parse(jObject.GetValue(Keywords.TAGS).ToString()))
                {
                    tags.Add(tag);
                }

                int    durationPercent = CalculateUtil.GetDurationPercent(start, expired);
                string typeProgressBar = CalculateUtil.GetTypeProgressBar(durationPercent);
                list.Add(new Form(name, title, path, amount, start, expired, tags, durationPercent, typeProgressBar,
                                  assign.Equals(Keywords.ANONYMOUS)));
            }

            return(list);
        }
        private async Task <List <Form> > AddFormToList(string token, List <Form> listForm, List <FormControl> listFormControl)
        {
            foreach (FormControl formControl in listFormControl)
            {
                string path    = formControl.PathForm;
                string start   = formControl.Start;
                string expired = formControl.Expired;

                int    durationPercent = CalculateUtil.GetDurationPercent(start, expired);
                string typeProgressBar = CalculateUtil.GetTypeProgressBar(durationPercent);

                string formRes = await _formService.FindFormWithToken(token, path);

                JObject formResJSON = JObject.Parse(formRes);
                if (formResJSON.Count == 0)
                {
                    return(listForm);
                }
                string        title     = formResJSON.GetValue(Keywords.TITLE).ToString();
                List <string> tags      = new List <string>();
                JArray        tagsArray = (JArray)formResJSON.GetValue(Keywords.TAGS);
                foreach (JObject tag in tagsArray)
                {
                    tags.Add(tag.ToString());
                }

                string submissionsRes = await _submissionService.FindSubmissionsByPage(token, path, 1);

                JArray submissionResJSON = JArray.Parse(submissionsRes);
                bool   isSubmitted       = submissionResJSON.Count != 0;

                bool isPending = CalculateUtil.IsFormPendingOrExpired(start);

                listForm.Add(new Form(title, path, start, expired, tags, durationPercent, typeProgressBar, isSubmitted, isPending));
            }

            return(listForm);
        }