Esempio n. 1
0
        public bool PostMCQuestion(MCQuestionDAO mCQuestion)
        {
            MCQuestionServiceClient client = new MCQuestionServiceClient();

            try
            {
                bool result = client.CreateMCQuestion(mCQuestion);
                return result;
            }
            catch (FaultException<KaskServiceException> e)
            {
                throw new HttpException(e.Message);
            }
        }
Esempio n. 2
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["MCQuestionDescription"]))
                {
                    // save application form data back to database through service
                    using (HttpClient httpClient = new HttpClient())
                    {
                        httpClient.BaseAddress = new Uri("http://localhost:51309");
                        httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                        HttpResponseMessage result = new HttpResponseMessage();
                        string resultContent = "";

                        // gather MCQuestionOpening form data
                        MCQuestionDAO mCQuestion = new MCQuestionDAO();
                        mCQuestion.MCQuestionDescription = Request.Form["MCQuestionDescription"];

                        // post (save) MCQuestionOpening data
                        result = httpClient.PostAsJsonAsync(ServiceURIs.ServiceMCQuestionUri, mCQuestion).Result;
                        resultContent = result.Content.ReadAsStringAsync().Result;
                    }

                    return RedirectToAction("Index", "MCQuestions");
                }
                else
                {
                    // TODO: validation later on...
                    return RedirectToAction("Create");
                }
            }
            catch
            {
                // TODO: validation later on...
                return RedirectToAction("Create");
            }
        }