コード例 #1
0
        public async Task <OperationResult> Save(ToDoItem toDoItem)
        {
            var             methodBase      = System.Reflection.MethodBase.GetCurrentMethod();
            OperationResult operationResult = OperationResult.ForError
                                                  (operationResultMessage: Core.Enums.OperationResultMessage.Error,
                                                  methodBase: methodBase);

            try
            {
                HttpResponseMessage response = await ApiMessage.Post(toDoItem, _appsettings.ToDoApiSettings.ToDoItemSave, _httpClient);

                var jsonString = await response.Content.ReadAsStringAsync();

                operationResult = JsonConvert.DeserializeObject <OperationResult>(jsonString);
            }
            catch (Exception ex)
            {
                operationResult = OperationResult.ForError
                                      (operationResultMessage: Core.Enums.OperationResultMessage.Error,
                                      methodBase: methodBase, exception: ex);
            }
            return(operationResult);
        }