// GET: Donation/Details/5
        public ActionResult Details(int id)
        {
            ShowDonation        ViewModel = new ShowDonation();
            string              url       = "donationdata/finddonation/" + id;
            HttpResponseMessage response  = client.GetAsync(url).Result;

            //Can catch the status code (200 OK, 301 REDIRECT), etc.
            //Debug.WriteLine(response.StatusCode);
            if (response.IsSuccessStatusCode)
            {
                //Put data into donation data transfer object
                DonationDto SelectedDonation = response.Content.ReadAsAsync <DonationDto>().Result;
                ViewModel.donation = SelectedDonation;


                url      = "donationdata/finddonorfordonation/" + id;
                response = client.GetAsync(url).Result;
                DonorDto SelectedDonor = response.Content.ReadAsAsync <DonorDto>().Result;
                ViewModel.donor = SelectedDonor;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Пример #2
0
        public ActionResult Details(int id)
        {
            ShowDonation ViewModel = new ShowDonation();

            ViewModel.isadmin = User.IsInRole("Admin");
            string url = "DonationData/FindDonation/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            //Debug.WriteLine(response.StatusCode);
            if (response.IsSuccessStatusCode)
            {
                DonationDto SelectedDonations = response.Content.ReadAsAsync <DonationDto>().Result;
                ViewModel.Donation = SelectedDonations;

                //Find the Event for Donation by Id
                url      = "EventData/FindEventForDonation/" + id;
                response = client.GetAsync(url).Result;
                Debug.WriteLine(response.StatusCode);
                EventDto SelectedEvent = response.Content.ReadAsAsync <EventDto>().Result;
                ViewModel.events = SelectedEvent;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        // GET: Donation/Details/5
        public ActionResult Details(int id)
        {
            //using view model to detail donation by id REFERENCE teamController in varsity w auth
            ShowDonation ViewModel = new ShowDonation();

            //creating a url string
            string url = "DonationData/FindDonation/" + id;

            //sending http request and getting a response back
            HttpResponseMessage response = client.GetAsync(url).Result;

            //if statment:: if the call worked return this else return error
            if (response.IsSuccessStatusCode)
            {
                DonationDto SelectedDonation = response.Content.ReadAsAsync <DonationDto>().Result;
                ViewModel.donation = SelectedDonation;

                //add the get statement for events related to the donations (id is the donation id that we will use to get details)
                //REF VIDEO for week 4 before passion project (git code was harder to understand)
                url      = "DonationData/FindEventForDonation" + id;//donation id FYI
                response = client.GetAsync(url).Result;
                EventDto SelectedEvent = response.Content.ReadAsAsync <EventDto>().Result;
                ViewModel.events = SelectedEvent;

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