Ejemplo n.º 1
0
        private async Task ExecuteLoadDonations(int id)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                donation = await donationRep.GetDonationAsync(id);

                DonationTitle = donation.Title;
                OnPropertyChanged("DonationTitle");

                Quantity = donation.Amount;
                OnPropertyChanged("Quantity");

                DonationType = donation.Type.ToString();
                OnPropertyChanged("DonationType");

                DateTime expiration;
                if (donation.Expiration < DateTime.Now)
                {
                    // If expired, set new expiration to two hours from now
                    expiration = DateTime.Now.AddHours(2);
                }
                else
                {
                    expiration = donation.Expiration.Value;
                }
                ExpirationDate = expiration.Date;
                ExpirationTime = new TimeSpan(expiration.Hour, expiration.Minute, expiration.Second);
                OnPropertyChanged("ExpirationDate");
                OnPropertyChanged("ExpirationTime");

                ImageSource = donation.PictureUrl;
                OnPropertyChanged("ImageSource");
            }
            catch
            {
                ShowFailureDialog("Unable to Load Donation");
            }
            finally
            {
                IsBusy = false;
            }
        }