public ActionResult Create(UpdateFeedbackViewModel FeedbackViewInfo)
        {
            FeedbackModel FeedbackInfo = new FeedbackModel
            {
                feedback_id  = FeedbackViewInfo.feedback.feedback_id,
                date         = DateTime.Now,
                fname        = FeedbackViewInfo.feedback.fname,
                lname        = FeedbackViewInfo.feedback.lname,
                email        = FeedbackViewInfo.feedback.email,
                title        = FeedbackViewInfo.feedback.title,
                text         = FeedbackViewInfo.feedback.text,
                DepartmentId = FeedbackViewInfo.DepartmentId
            };

            string      url     = "feedbackapi/addfeedback";
            HttpContent content = new StringContent(jss.Serialize(FeedbackInfo));

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

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("CreateConfirm"));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        /// <summary>
        /// Routes to a dynamically generated "Feedback Create" Page. Adds information from the database.
        /// </summary>
        /// <returns>A dynamic "Feedback Create" webpage which can add a blog entry to the database.</returns>
        /// <example>GET : /Feedback/Create</example>
        public ActionResult Create()
        {
            UpdateFeedbackViewModel ViewModel = new UpdateFeedbackViewModel();
            string url = "departmentsdata/getdepartments";

            HttpResponseMessage          response             = client.GetAsync(url).Result;
            IEnumerable <DepartmentsDto> PotentialDepartments = response.Content.ReadAsAsync <IEnumerable <DepartmentsDto> >().Result;

            ViewModel.departments = PotentialDepartments;

            return(View(ViewModel));
        }
Ejemplo n.º 3
0
        public ActionResult Update(int id)
        {
            GetApplicationCookie();

            UpdateFeedbackViewModel ViewModel = new UpdateFeedbackViewModel();

            string url = "feedbackapi/findfeedback/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                FeedbackDto SelectedFeedback = response.Content.ReadAsAsync <FeedbackDto>().Result;
                ViewModel.Feedback = SelectedFeedback;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }