コード例 #1
0
        public ActionResult DeleteConfirm(int id)
        {
            string url = "volunteeropportunitydata/findvolunteeropportunity/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                VolunteerOpportunityDto SelectedVolunteerOpportunity = response.Content.ReadAsAsync <VolunteerOpportunityDto>().Result;
                return(View(SelectedVolunteerOpportunity));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
コード例 #2
0
        public IHttpActionResult GetVolunteerOpportunities()
        {
            List <VolunteerOpportunity>    VolunteerOpportunities   = db.VolunteerOpportunities.ToList();
            List <VolunteerOpportunityDto> VolunteerOpportunityDtos = new List <VolunteerOpportunityDto> {
            };

            foreach (var VolunteerOpportunity in VolunteerOpportunities)
            {
                VolunteerOpportunityDto NewVolunteerOpportunity = new VolunteerOpportunityDto
                {
                    OpportunityID   = VolunteerOpportunity.OpportunityID,
                    OpportunityName = VolunteerOpportunity.OpportunityName,
                    Description     = VolunteerOpportunity.Description
                };
                VolunteerOpportunityDtos.Add(NewVolunteerOpportunity);
            }
            return(Ok(VolunteerOpportunityDtos));
        }
コード例 #3
0
        public IHttpActionResult FindVolunteerOpportunity(int id)
        {
            //Find the data
            VolunteerOpportunity VolunteerOpportunity = db.VolunteerOpportunities.Find(id);

            //if not found, return 404 status code.
            if (VolunteerOpportunity == null)
            {
                return(NotFound());
            }

            //put into a 'friendly object format'
            VolunteerOpportunityDto VolunteerOpportunityDto = new VolunteerOpportunityDto
            {
                OpportunityID   = VolunteerOpportunity.OpportunityID,
                OpportunityName = VolunteerOpportunity.OpportunityName,
                Description     = VolunteerOpportunity.Description
            };


            //pass along data as 200 status code OK response
            return(Ok(VolunteerOpportunityDto));
        }