private async void AddPasswords_ToCollection(Passwords obj) { //Add Notes to Server Animate = true; Instructions = "Creating Password"; //Diagnostics string Message = string.Empty; string StackTrace = string.Empty; bool _HasError = false; string cid = obj.Password_ID; //Temp Client Id await Task.Run(() => { try { Device.BeginInvokeOnMainThread(() => { var curr = new PasswordCellViewModel(obj, navigation, dialogue); curr._DeleteContent += RemovePassword_FromCollection; this.Passwords.Add(curr); }); DataVaultWebServiceClient dataService = new DataVaultWebServiceClient(ConfigurationManager.InSecurePublicBinding(), new System.ServiceModel.EndpointAddress(Constants.Data_InSecureUrl)); var response = dataService._AddPassword(LocalMapper.MapPassword_ToServer(obj)); if (response.Errors.Count != 0) { response.Errors.ForEach(w => { //Add to log table for diagnostics if (this.logging != null) { var log = LocalMapper.Map_LogWithMessage(w, Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); this.logging.AddLog(log); } }); _HasError = true; } else { Device.BeginInvokeOnMainThread(() => { var password = this.Passwords.SingleOrDefault(w => w.ID.Equals(cid)); password.ID = response.Content_ID; ReloadData = true; }); //Update Password obj.Password_ID = response.Content_ID; this.passwordManager.UpdatePassword(obj); } } catch (Exception ex) { if (ex.InnerException != null) { Message = ex.InnerException.Message; StackTrace = ex.InnerException.StackTrace; } else { Message = ex.Message; StackTrace = ex.StackTrace; } _HasError = true; var mEx = new Exceptions(logging, Message, StackTrace); if (mEx != null) { mEx.HandleException(mEx, logging); } } }).ContinueWith((e) => { Device.BeginInvokeOnMainThread(() => { Animate = false; //if (_HasError && dialogue != null) // dialogue.ShowAlert("mmm...Something went wrong", Message); }); }); }
private async void UpdatePasswords_FromCollection(Passwords obj) { //Add Notes to Server Animate = true; Instructions = "Updating"; //Diagnostics string Message = string.Empty; string StackTrace = string.Empty; bool _HasError = false; await Task.Run(() => { try { //Update Collection var Index = this.Passwords.IndexOf(this.Passwords.SingleOrDefault(i => i.ID == obj.Password_ID)); this.Passwords[Index].Password = obj.Password; this.Passwords[Index].Description = obj.Description; DataVaultWebServiceClient dataService = new DataVaultWebServiceClient(ConfigurationManager.InSecurePublicBinding(), new System.ServiceModel.EndpointAddress(Constants.Data_InSecureUrl)); var response = dataService._UpdatePassword_ByID(LocalMapper.MapPassword_ToServer(obj)); if (response.Errors.Count != 0) { response.Errors.ForEach(w => { //Add to log table for diagnostics if (this.logging != null) { var log = LocalMapper.Map_LogWithMessage(w, Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); this.logging.AddLog(log); } }); _HasError = true; } } catch (Exception ex) { if (ex.InnerException != null) { Message = ex.InnerException.Message; StackTrace = ex.InnerException.StackTrace; } else { Message = ex.Message; StackTrace = ex.StackTrace; } _HasError = true; var mEx = new Exceptions(logging, Message, StackTrace); if (mEx != null) { mEx.HandleException(mEx, logging); } } }).ContinueWith((e) => { Device.BeginInvokeOnMainThread(() => { Animate = false; //if (_HasError) // dialogue.ShowAlert("mmm...Something went wrong", Message); }); }); }