private async Task UpdateGoal(DateTime dateValue) { var updateGoal = new UpdateGoal() { CustomerId = ViewModel.CustomerId, InteractionId = ViewModel.InteractionId, ActionPlanId = ViewModel.ActionPlanId, GoalId = new Guid(ViewModel.Goal.GoalId), DateGoalShouldBeCompletedBy = dateValue, GoalStatus = ViewModel.Goal.GoalStatus }; await _dssWriter.UpdateGoal(updateGoal); }
public async Task UpdateGoal(UpdateGoal updateGoal) { if (updateGoal == null) { var errorMessage = $"Failure Update Goal, No data provided"; _logger.LogError(errorMessage); throw new DssException(errorMessage); } try { ActionPlan result; using (var request = CreateRequestMessage()) { request.Content = new StringContent( JsonConvert.SerializeObject(updateGoal), Encoding.UTF8, MediaTypeNames.Application.Json); request.Headers.Add(VersionHeader, _dssSettings.Value.GoalsApiVersion); await _restClient.PatchAsync <Goal>(_dssSettings.Value.GoalsApiUrl .Replace(CustomerIdTag, updateGoal.CustomerId.ToString()) .Replace(InteractionIdTag, updateGoal.InteractionId.ToString()) .Replace(ActionPlanIdTag, updateGoal.ActionPlanId.ToString()) + "/" + updateGoal.GoalId , request); } if (_restClient.LastResponse.StatusCode == HttpStatusCode.NoContent) { var errorMessage = $"Failure Update Goal - Response {_restClient.LastResponse.Content} "; _logger.LogError(errorMessage); throw new DssException(errorMessage); } } catch (Exception e) { var errorMessage = $"Failure Update Goal, {e.InnerException}"; _logger.LogError(errorMessage); throw new DssException(errorMessage); } }