Untitled

mail@pastecode.io avatarunknown
csharp
18 days ago
1.2 kB
4
Indexable
Never
 public async Task<string> UpdateProjectForName(int bxUserId, DateTime localDateModified, string data, string specification, string filename)
 {
     var body = new
     {
         bx_user_id = bxUserId,
         local_date_modified = localDateModified,
         data = JsonConvert.DeserializeObject<projectDXpress>(data, formatSettings),
         specification = JsonConvert.DeserializeObject(specification, formatSettings)
     };

     var json = JsonConvert.SerializeObject(body, formatSettings);
     var content = new StringContent(json, Encoding.UTF8, "application/json");

     try
     {
         var response = await HttpClient.PostAsync(_uri + "/api/projects/update", content);
         response.EnsureSuccessStatusCode();
         var result = response.Content.ReadAsStringAsync().Result;

         // Логгирование успешной операции
         logger.LogInfo($"Successfully updated project: {filename}");

         return result;
     }
     catch (Exception ex)
     {
         // Логгирование ошибки
         logger.LogError($"Failed to update project: {filename}, Error: {ex.Message}");
         throw;
     }
 }