public async Task SaveTodoItemAsync(TodoItem item, bool isNewItem = false) { try { var todoItem = ToASMXServiceTodoItem(item); saveRequestComplete = new TaskCompletionSource <bool>(); if (isNewItem) { todoService.CreateTodoItemAsync(todoItem); } else { todoService.EditTodoItemAsync(todoItem); } await saveRequestComplete.Task; } catch (SoapException se) { Debug.WriteLine("\t\t{0}", se.Message); } catch (Exception ex) { Debug.WriteLine("\t\tERROR {0}", ex.Message); } }
public async Task <SoapResult <bool> > SaveTodoItemAsync(TodoItem item, bool isNewItem = false) { saveRequestComplete = new TaskCompletionSource <SoapResult <bool> >(); try { var todoItem = ToASMXServiceTodoItem(item); if (isNewItem) { todoService.CreateTodoItemAsync(todoItem); } else { todoService.EditTodoItemAsync(todoItem); } return(await saveRequestComplete.Task); } catch (SoapException se) { Debug.WriteLine("\t\t{0}", se.Message); saveRequestComplete?.TrySetResult(new SoapResult <bool>() { res = false, error = se }); } catch (Exception ex) { Debug.WriteLine("\t\tERROR {0}", ex.Message); saveRequestComplete?.TrySetResult(new SoapResult <bool>() { res = false, error = ex }); } return(await saveRequestComplete.Task); }