public async Task <string> UpdateClaimRequest(ReClaimsDetails clm) { UpdateClaimRequest reImClaimdetails = null; string status = "false"; try { reImClaimdetails = GetUpdateRequestModel(clm); HttpMessageHandler handler = new HttpClientHandler(); string url = "https://localhost:44328/api/UpdateClaim"; string cpath = url; var httpClient = new HttpClient(handler) { BaseAddress = new Uri(cpath), Timeout = new TimeSpan(0, 2, 0) }; httpClient.DefaultRequestHeaders.Add("ContentType", "application/json"); var content = JsonConvert.SerializeObject(reImClaimdetails); var httpContent = new StringContent(content, Encoding.UTF8, "application/json"); HttpResponseMessage response = await httpClient.PostAsync(url, httpContent); if (response.StatusCode == HttpStatusCode.OK) { var a = JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result); status = a; } } catch (Exception ex) { throw ex; } return(status); }
private UpdateClaimRequest GetUpdateRequestModel(ReClaimsDetails _updatedetails) { UpdateClaimRequest _clmdet = null; List <RequestFileDTO> _uploadedfiles = null; if (_updatedetails != null) { _clmdet = new UpdateClaimRequest(); _clmdet.RequestId = Convert.ToInt32(_updatedetails.RequestCreateDTO.RequestNumber); _clmdet.Comment = _updatedetails.RequestCreateDTO.Comment; _uploadedfiles = new List <RequestFileDTO>(); foreach (var file in _updatedetails.FilesUploaded) { if (file.Length > 0) { using (var ms = new MemoryStream()) { RequestFileDTO requestFile = new RequestFileDTO(); requestFile.FileDesc = file.FileName; requestFile.FilePath = file.FileName; file.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); requestFile.MyFile = fileBytes; // act on the Base64 data _uploadedfiles.Add(requestFile); } } } _clmdet.RequestFileList = _uploadedfiles; } return(_clmdet); }
public IActionResult Update([FromBody] UpdateClaimRequest claim) { _updateClaimCommand.Execute(claim); return(NoContent()); }