Exemplo n.º 1
0
        private async void SaveButton_Click(object sender, EventArgs ea)
        {
            var dialog = new ProgressDialog(this);

            dialog.SetMessage(Resources.GetString(Resource.String.Saving));
            dialog.SetCancelable(false);
            dialog.Show();

            try
            {
                Bindings.UpdateSourceForLastView();
                this.Model.ApplyEdit();
                var returnModel = await this.Model.SaveAsync();

                InitializeBindings(returnModel);
            }
            catch (Exception ex)
            {
                var alert = new AlertDialog.Builder(this);
                alert.SetMessage(string.Format(Resources.GetString(Resource.String.Error), ex.Message));
                alert.Show();
            }
            finally
            {
                dialog.Hide();
            }
        }
Exemplo n.º 2
0
        private async void SaveButton_Click(object sender, EventArgs ea)
        {
            var waitingOverlay = new WaitingOverlay(UIScreen.MainScreen.Bounds, "Saving...");

            View.Add(waitingOverlay);

            Bindings.UpdateSourceForLastView();
            this.Model.ApplyEdit();
            try
            {
                //this.Model.GetBrokenRules();
                this.Model = await this.Model.SaveAsync();

                var alert = new UIAlertView();
                alert.Message = "Saved...";
                alert.AddButton("Close");
                alert.DismissWithClickedButtonIndex(0, false);
                alert.Show();
            }
            catch (Exception ex)
            {
                var alert = new UIAlertView();
                alert.Message = string.Format("the following error has occurred: {0}", ex.Message);
                alert.AddButton("Close");
                alert.DismissWithClickedButtonIndex(0, false);
                alert.Show();
            }
            finally
            {
                InitializeBindings(this.Model);
                waitingOverlay.Hide();
            }
        }
Exemplo n.º 3
0
 void saveButton_Click(object sender, EventArgs e)
 {
     ErrorText.Text = string.Empty;
     Bindings.UpdateSourceForLastView();
     if (Model.IsSavable)
     {
         try
         {
             Model.BeginSave((src, a) =>
             {
                 if (a.Error != null)
                 {
                     ErrorText.Text =
                         string.Format("Save: {0}-{1}", a.Error.GetType().Name, a.Error.Message);
                 }
                 else
                 {
                     InitializeBindings((Person)a.NewObject);
                 }
             });
         }
         catch (Exception ex)
         {
             ErrorText.Text =
                 string.Format("Save: {0}-{1}", ex.GetType().Name, ex.Message);
         }
     }
     else if (!Model.IsValid)
     {
         var error = Model.BrokenRulesCollection.Where(r => r.Severity == Csla.Rules.RuleSeverity.Error).FirstOrDefault();
         if (error != null)
         {
             ErrorText.Text = error.Description;
         }
         else
         {
             ErrorText.Text = "Object is invalid";
         }
     }
     else
     {
         ErrorText.Text = "Nothing to save";
     }
 }