private async void UploadFilesToServer() { if (_proxy._user == null || string.IsNullOrEmpty(uploadPath)) { return; } string connectionString = ConfigurationManager.ConnectionStrings[UPDATEFILESINSERVER].ToString(); var dir = new DirectoryInfo(uploadPath); System.IO.FileInfo[] files = dir.GetFiles(); List <FilesInfo> fileInfos = new List <FilesInfo>(); foreach (var fileInfo in files) { FilesInfo the_file = new FilesInfo(); the_file.FileName = fileInfo.Name; the_file.Location = fileInfo.DirectoryName; the_file.Size = fileInfo.Length; fileInfos.Add(the_file); } FilesPerUser filesPerUser = new FilesPerUser(); filesPerUser._User = _proxy._user; filesPerUser._FilesList = fileInfos; await _proxy.UpdateFilesAtServer(connectionString, filesPerUser); }
public async Task UpdateFilesAtServer(string connectionString, FilesPerUser filesPerUser) { using (var client = new HttpClient()) { HttpResponseMessage response = await client.PostAsJsonAsync(connectionString, filesPerUser); // return response.IsSuccessStatusCode; } }
public IHttpActionResult UpdateFilesPerUser(FilesPerUser filesPerUser) { try { _users.UpdateFilesPerUser(filesPerUser._User, filesPerUser._FilesList); return(Ok()); } catch (Exception e) { return(InternalServerError(e)); } }