// GET: Donation/Edit/5 public ActionResult Edit(int id) { UpdateDonation ViewModel = new UpdateDonation(); 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; //get information about donors which could make this donation. url = "donordata/getdonors"; response = client.GetAsync(url).Result; IEnumerable <DonorDto> PotentialDonors = response.Content.ReadAsAsync <IEnumerable <DonorDto> >().Result; ViewModel.alldonors = PotentialDonors; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
// GET: Donation/Edit/5 //UPDATED CODE to get the event id to edit although I dont think event id needs to be edited as anything with money should not be edit not sure how to lock that down public ActionResult Edit(int id) { //add n the new view model and create a new instance of it UpdateDonation ViewModel = new UpdateDonation(); //starting with the url string REFERENCES:varsity MVP for this code and inclass live example //this is where I had issues in my passion project!!!! (Mind blown) string url = "DonationData/FindDonation/" + id; //reusing code from "Find Donation By Id". HttpResponseMessage response = client.GetAsync(url).Result; // The http call worked. if (response.IsSuccessStatusCode) { DonationDto Selecteddonation = response.Content.ReadAsAsync <DonationDto>().Result; ViewModel.donation = Selecteddonation; //adding in event id //REUSING CODE FROM create donation //url : from AMANDA's DATA CONTROLLER url = "EventData/GetEvents"; response = client.GetAsync(url).Result; IEnumerable <EventDto> PotentialEvents = response.Content.ReadAsAsync <IEnumerable <EventDto> >().Result; ViewModel.allevents = PotentialEvents; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
//[Authorize(Roles = "Admin")] public ActionResult Create() { UpdateDonation ViewModel = new UpdateDonation(); ViewModel.isadmin = User.IsInRole("Admin"); string url = "EventData/GetEvents"; HttpResponseMessage response = client.GetAsync(url).Result; IEnumerable <EventDto> PotetnialEvents = response.Content.ReadAsAsync <IEnumerable <EventDto> >().Result; ViewModel.Allevents = PotetnialEvents; return(View(ViewModel)); }
private void EditDonation(object sender, MouseButtonEventArgs e) { try { DataGrid dg = sender as DataGrid; DonationsGrid p = (DonationsGrid)dg.SelectedItems[0]; // OR: Patient p = (Patient)dg.SelectedItem; UpdateDonation up = new UpdateDonation(p); up.DonationDate.SelectedDate = p.DonationDate; up.ShowDialog(); } catch { } Refresh_DonationGrid(sender, e); }
public ActionResult Edit(int id) { UpdateDonation ViewModel = new UpdateDonation(); 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; url = "EventData/GetEvents"; response = client.GetAsync(url).Result; IEnumerable <EventDto> DonationsEvent = response.Content.ReadAsAsync <IEnumerable <EventDto> >().Result; ViewModel.Allevents = DonationsEvent; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
public Task <OperationResult <bool> > Update(UpdateDonation cmd) => _lazyDbConnection.TryExecuteDbMessageAsync(cmd);
private void EditDonation(object sender, MouseButtonEventArgs e) { try { DataGrid dg = sender as DataGrid; DonationsGrid p = (DonationsGrid)dg.SelectedItems[0]; // OR: Patient p = (Patient)dg.SelectedItem; UpdateDonation up = new UpdateDonation(p); up.DonationDate.SelectedDate = p.DonationDate; up.ShowDialog(); } catch { } Refresh_DonationGrid(sender, e); }