// GET: Donation/Create
        public ActionResult Create()
        {
            //using view model for add donation.
            //here we want to display a form and a drop down for all events if the user wished to donate to an event
            CreateDonation ViewModel = new CreateDonation();
            //Pulling from AMANDA's eventcontroller for get events
            string url = "EventData/GetEvents";
            HttpResponseMessage    response        = client.GetAsync(url).Result;
            IEnumerable <EventDto> PotentialEvents = response.Content.ReadAsAsync <IEnumerable <EventDto> >().Result;

            ViewModel.allevents = PotentialEvents;

            return(View(ViewModel));
        }
コード例 #2
0
        public ActionResult Create()
        {
            CreateDonation ModelView = new CreateDonation();

            ModelView.Donation = new DonationDto();

            //Get department data
            string urlDep = "departmentdata/getdepartments";
            HttpResponseMessage         responseDepartment   = client.GetAsync(urlDep).Result;
            IEnumerable <DepartmentDto> PotentialDepartments = responseDepartment.Content.ReadAsAsync <IEnumerable <DepartmentDto> >().Result;

            ModelView.AllDepartments = PotentialDepartments;

            return(View(ModelView));
        }
コード例 #3
0
        public ActionResult Edit(int id)
        {
            CreateDonation ModelView = new CreateDonation();

            //Get donation data
            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;
                ModelView.Donation = SelectedDonation;

                //Get department data
                string urlDep = "departmentdata/getdepartments/";
                response = client.GetAsync(urlDep).Result;
                IEnumerable <DepartmentDto> allDepartments = response.Content.ReadAsAsync <IEnumerable <DepartmentDto> >().Result;
                ModelView.AllDepartments = allDepartments;

                //Get donor data
                string urlDonor = "donationdata/finddonorfordonation/" + id;
                response = client.GetAsync(urlDonor).Result;
                ApplicationUserDto selectedUser = response.Content.ReadAsAsync <ApplicationUserDto>().Result;
                ModelView.User = selectedUser;

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