Пример #1
0
        public ActionResult PublicView()
        {
            //Model used to combine a the faq list and the objects for the form
            ViewFaq modelView = new ViewFaq();

            string url = "FaqData/GetPublicFaqs";
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                IEnumerable <FaqDto> faqs = response.Content.ReadAsAsync <IEnumerable <FaqDto> >().Result;
                modelView.FaqList = faqs;
            }
            else
            {
                return(RedirectToAction("Error"));
            }

            // FAQ is empty for before creating new FAQ
            modelView.newFaq = new FaqDto();

            //The view needs to be sent a list of all the Departments so the client can select a Department for FAQ in the view
            modelView.DepartmentsSelectList = GetDepartmentSelectList();

            return(View(modelView));
        }
Пример #2
0
        public ActionResult PublicView(ViewFaq faqInfo)
        {
            string url = "faqdata/AddFaq";

            HttpContent content = new StringContent(jss.Serialize(faqInfo.newFaq));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync(url, content).Result;

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("PublicView"));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }