示例#1
0
		private void HandleActivateVoucher (object sender, ActivateVoucherCompletedEventArgs args)
		{
			Tuple<Timer, object> userState;
			
			bool error = ServiceAgent.HandleAsynchCompletedError (args, "ActivateVoucher");
			InvokeOnMainThread (delegate	{
				Busy = false;
				if (error)
					return;
					
				Model.QuizVoucher voucher = null;
				
				userState = args.UserState as Tuple<Timer, object>;
				if (userState != null && userState.Item2 != null) {
					voucher = userState.Item2 as Model.QuizVoucher;
				} else {
					using (var alert = new UIAlertView (Locale.GetText ("Unbekannte Fehler"), "", null, "OK", null)) {
						alert.Show ();
					}
					return;
				}
				
				bool result = args.Result;
				
				if (result == true) {
					voucher.IsActivated = true;
					QuizVoucherRepository.Update (voucher);
					CreateActivateResult (true);
				} else {
					voucher.IsUsed = true;
					voucher.Deleted = true;
					QuizVoucherRepository.Update (voucher);
					CreateActivateResult (false);
				}
					
			});
			
		}
示例#2
0
		private void HandleActivateVoucherCompleted (object sender, ActivateVoucherCompletedEventArgs args)
		{
			Tuple<Timer, object> userState;
			
			bool error = ServiceAgent.HandleAsynchCompletedError (args, "ActivateVoucher");
			InvokeOnMainThread (delegate	{
				Busy = false;
				if (error)
					return;
					
				QuizVoucher voucher = null;
				bool result = args.Result;
				userState = args.UserState as Tuple<Timer, object>;
				if (userState != null && userState.Item2 != null) {
					voucher = userState.Item2 as QuizVoucher;
				} else {
					using (var alert = new UIAlertView (Locale.GetText ("Unbekannte Fehler"), "", null, "OK", null)) {
						alert.Show ();
					}
					return;
				}
				
				if (result == true) {
					voucher.IsActivated = true;
					QuizVoucherRepository.Update (voucher);
					Load ();
					var text = "Den Gutschein {0} wurde erfolgreich aktiviert.";
					using (var alert = new UIAlertView (Locale.Format (text, voucher.Code), "", null, "OK", null)) {
						alert.Show ();
					}
				} else {
					voucher.IsUsed = true;
					voucher.Deleted = true;
					QuizVoucherRepository.Update (voucher);
					var text = "Sie haben Ihren Gutschein-Code bereits bekommen.";
					using (var alert = new UIAlertView (Locale.GetText (text), "", null, "OK", null)) {
						alert.Show ();
					}
				}
					
			});
			
		}