コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        // GET: Inform/Details/1
        public ActionResult Details(int id)
        {
            ShowInform          ViewModel = new ShowInform();
            string              url       = "InformData/FindInform/" + id;
            HttpResponseMessage response  = client.GetAsync(url).Result;

            Debug.WriteLine(response.StatusCode);
            if (response.IsSuccessStatusCode)
            {
                //Put data into Inform Data Transfer Object
                InformDto SelectedInform = response.Content.ReadAsAsync <InformDto>().Result;
                ViewModel.Inform = SelectedInform;

                //Find the Project for Inform by Id
                url      = "ProjectData/FindProjectForInform/" + id;
                response = client.GetAsync(url).Result;
                Debug.WriteLine(response.StatusCode);
                ProjectDto SelectedProject = response.Content.ReadAsAsync <ProjectDto>().Result;
                ViewModel.Project = SelectedProject;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
コード例 #2
0
        public ActionResult Edit(int id)
        {
            UpdateInform ViewModel = new UpdateInform();

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

            //Can catch the status code (200 OK, 301 REDIRECT), etc.
            Debug.WriteLine(response.StatusCode);
            if (response.IsSuccessStatusCode)
            {
                InformDto SelectedInform = response.Content.ReadAsAsync <InformDto>().Result;
                ViewModel.Inform = SelectedInform;

                url      = "ProjectData/GetProjects";
                response = client.GetAsync(url).Result;
                IEnumerable <ProjectDto> InformsProject = response.Content.ReadAsAsync <IEnumerable <ProjectDto> >().Result;
                ViewModel.Allprojects = InformsProject;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
コード例 #3
0
        public ActionResult DeleteConfirm(int id)
        {
            string url = "InformData/FindInform/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            //Can catch the status code (200 OK, 301 REDIRECT), etc.
            //Debug.WriteLine(response.StatusCode);
            if (response.IsSuccessStatusCode)
            {
                InformDto SelectedInform = response.Content.ReadAsAsync <InformDto>().Result;
                return(View(SelectedInform));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
コード例 #4
0
        public IHttpActionResult FindInform(int id)
        {
            //This will look through the database and find the Inform Id
            Inform Inform = db.Informs.Find(id);

            //if not found, return 404 status code.
            if (Inform == null)
            {
                return(NotFound());
            }
            InformDto InformDto = new InformDto
            {
                InformID        = Inform.InformID,
                InfoData        = Inform.InfoData,
                InfoPhoneNumber = Inform.InfoPhoneNumber,
                InfoEmail       = Inform.InfoEmail,
                InfoUrl         = Inform.InfoUrl,
                ProjectID       = Inform.ProjectID
            };

            return(Ok(InformDto));
        }
コード例 #5
0
        public IHttpActionResult GetInforms()
        {
            List <Inform>    Informs    = db.Informs.ToList();
            List <InformDto> InformDtos = new List <InformDto> {
            };

            //Choosen information to expose to the API
            foreach (var Inform in Informs)
            {
                InformDto NewInform = new InformDto
                {
                    InformID        = Inform.InformID,
                    InfoData        = Inform.InfoData,
                    InfoPhoneNumber = Inform.InfoPhoneNumber,
                    InfoEmail       = Inform.InfoEmail,
                    InfoUrl         = Inform.InfoUrl,
                    ProjectID       = Inform.ProjectID
                };
                InformDtos.Add(NewInform);
            }
            return(Ok(InformDtos));
        }
コード例 #6
0
        public IHttpActionResult GetInformForProject(int id)
        {
            List <Inform> Informs = db.Informs.Where(t => t.ProjectID == id)
                                    .ToList();
            List <InformDto> InformDtos = new List <InformDto> {
            };

            foreach (var Inform in Informs)
            {
                InformDto NewInform = new InformDto
                {
                    InformID        = Inform.InformID,
                    InfoData        = Inform.InfoData,
                    InfoPhoneNumber = Inform.InfoPhoneNumber,
                    InfoEmail       = Inform.InfoEmail,
                    InfoUrl         = Inform.InfoUrl,
                    ProjectID       = Inform.ProjectID
                };
                InformDtos.Add(NewInform);
            }
            return(Ok(InformDtos));
        }