/// <summary> /// Runs the submit function in background catching common exceptions. /// </summary> /// <param name="submitFunction"></param> /// <returns></returns> public async Task<bool> Submit() { var error = Errors.FirstOrDefault(); if (error != null) { MessageBoxUtils.Error((string)error.ErrorContent); return false; } if (!SubmitValidation()) { MessageBoxUtils.FormIncompleteError(); return false; } try { Loading = true; var result = await RequestService.Execute(() => SubmitFunction()); Loading = false; return result; } catch (Exception e) { MessageBox.Show(e.Message); Loading = false; } return true; }