コード例 #1
0
        public async Task <ViewResult> SurveyResponseAsync()
        {
            api.Client().BaseAddress     = new Uri(baseAddress);
            HttpResponseMessage response = await api.Client().PostAsJsonAsync("api/document/saveresponse", GetCSVModel(Request.Form));

            response.EnsureSuccessStatusCode();
            string responseString = response.Content.ReadAsStringAsync().Result;



            return(View("SurveyResponseAsync", GetResponseModelList(Request.Form)));
        }
コード例 #2
0
        public async Task <ActionResult> Index(string fileName)
        {
            requestUri = "api/Document/report";
            api.Client().BaseAddress     = new Uri(baseAddress);
            HttpResponseMessage response = await api.Client().PostAsJsonAsync <ReportModel>(requestUri, new ReportModel {
                Filename = fileName
            });

            string responseString = await response.Content.ReadAsAsync <string>();


            return(View(JsonConvert.DeserializeObject <ReportAnalysisModel>(responseString)));
        }
コード例 #3
0
        public async Task <ActionResult> Create(IFormCollection collection)
        {
            string   SurveyName  = collection["SurveyName"];
            int      UserID      = int.Parse(collection["UserID"]);
            string   Type        = collection["Type"];
            string   Description = collection["Description"];
            DateTime StartDate   = Convert.ToDateTime(collection["StartDate"]);
            DateTime EndDate     = Convert.ToDateTime(collection["EndDate"]);
            string   Permission  = collection["Permission"];

            var survey = new SurveyDataModel
            {
                SurveyName  = SurveyName,
                UserID      = UserID,
                Type        = Type,
                Description = Description,
                StartDate   = StartDate,
                EndDate     = EndDate,
                Permission  = Permission
            };

            api.Client().BaseAddress     = new Uri(baseAddress);
            HttpResponseMessage response = await api.Client().PostAsJsonAsync("api/survey/save", survey);

            response.EnsureSuccessStatusCode();

            return(RedirectToAction("Index", "Survey"));
        }
コード例 #4
0
        public async Task <ActionResult> Create(IFormCollection collection)
        {
            /*
             * try
             * {
             * // TODO: Add insert logic here
             *
             * return RedirectToAction(nameof(Index));
             * }
             * catch
             * {
             * return View();
             * }
             */


            string question = collection["Question"];

            int    surveyID = int.Parse(collection["surveyID"]);
            string type     = collection["Type"];
            string options  = collection["Options"];

            api.Client().BaseAddress = new Uri(baseAddress);
            requestUri = "api/SurveyQuestions";
            var responseSurveyQuestions = api.GetResponseAsync(baseAddress, requestUri);
            var list = JsonConvert.DeserializeObject <List <QuestionDataModel> >(responseSurveyQuestions.Result.Content.ReadAsAsync <string>().Result);

            list = list.Where(x => x.SurveyID == surveyID).ToList();
            int questionNumber = list.Count + 1;

            var Question = new QuestionDataModel(questionNumber, surveyID, question, type, options);
            HttpResponseMessage response = await api.Client().PostAsJsonAsync("api/surveyQuestions/save", Question);

            response.EnsureSuccessStatusCode();

            return(RedirectToAction("Index", "Questions"));
        }
コード例 #5
0
        public async Task <ActionResult> Create(IFormCollection collection)
        {
            string username   = collection["Username"];
            string title      = collection["Title"];
            string firstName  = collection["Firstname"];
            string lastName   = collection["Lastname"];
            string email      = collection["Email"];
            string password   = collection["Password"];
            string type       = collection["Type"];
            string permission = collection["Permission"];
            string groups     = collection["Groups"];

            var user = new UserDataModel {
                Username = username, Title = title, Firstname = firstName, Lastname = lastName,
                Email    = email, Password = password, Type = type, Permission = permission, Groups = groups
            };

            api.Client().BaseAddress     = new Uri("https://projectwebapis.azurewebsites.net/");
            HttpResponseMessage response = await api.Client().PostAsJsonAsync("api/user/save", user);

            response.EnsureSuccessStatusCode();

            return(RedirectToAction("Index", "User"));
        }