diff --git a/src/WorkFlowCheck.Web/Services/BaseStockService.cs b/src/WorkFlowCheck.Web/Services/BaseStockService.cs index ab8f015..9a97623 100644 --- a/src/WorkFlowCheck.Web/Services/BaseStockService.cs +++ b/src/WorkFlowCheck.Web/Services/BaseStockService.cs @@ -99,6 +99,49 @@ namespace WorkFlowCheck.Web.Services } return retVal; } + public async Task GetEquipment(int id) + { + string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetEquipment/{id}"; + var retVal = new EquipmentDTO(); + try + { + var response = await _httpClient.GetFromJsonAsync>(endpoint); + if (response != null) + { + if (response.IsSuccess) + { + return response.Data; + } + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } + public async Task GetLocation(int id) + { + string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetLocation/{id}"; + var retVal = new LocationDTO(); + try + { + var response = await _httpClient.GetFromJsonAsync>(endpoint); + if (response != null) + { + if (response.IsSuccess) + { + return response.Data; + } + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } + public async Task GetCheckListTemplateRow(int id) { string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetCheckListTemplateRow/{id}"; @@ -149,6 +192,62 @@ namespace WorkFlowCheck.Web.Services }; } } + public async Task> UpdateEquipment(EquipmentDTO EquipmentDTO) + { + try + { + string endpoint = $"{_httpClient.BaseAddress}api/sync/updateEquipment"; + + using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, EquipmentDTO)) + { + httpResponseMessage.EnsureSuccessStatusCode(); + + var jsonString = await httpResponseMessage.Content.ReadAsStringAsync(); + var response = JsonConvert.DeserializeObject>(jsonString); + + return response ?? new ApiResponseDTO + { + IsSuccess = false, + }; + } + } + catch (Exception ex) + { + // Hiba visszaadása + return new ApiResponseDTO + { + IsSuccess = false + }; + } + } + public async Task> UpdateLocation(LocationDTO LocationDTO) + { + try + { + string endpoint = $"{_httpClient.BaseAddress}api/sync/updateLocation"; + + using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, LocationDTO)) + { + httpResponseMessage.EnsureSuccessStatusCode(); + + var jsonString = await httpResponseMessage.Content.ReadAsStringAsync(); + var response = JsonConvert.DeserializeObject>(jsonString); + + return response ?? new ApiResponseDTO + { + IsSuccess = false, + }; + } + } + catch (Exception ex) + { + // Hiba visszaadása + return new ApiResponseDTO + { + IsSuccess = false + }; + } + } } }