public static string MakePostRequest(string address, NameValueCollection values) { IFileUploader uploader = FileUploaderFactory.CreateFileUploader(); try { byte[] response = uploader.UploadFiles(address, new List <object>(), values); return(Encoding.Default.GetString(response)); } catch { return("CONNECTION_FAIL"); } }
public static string UploadFileWithParams(string address, IEnumerable <object> files, NameValueCollection values) { IFileUploader uploader = FileUploaderFactory.CreateFileUploader(); try { byte[] response = uploader.UploadFiles(address, files, values); uploader.CloseStreams(files); return(Encoding.Default.GetString(response)); } catch { return("CONNECTION_FAIL"); } }
public async Task <IActionResult> CreateTicket(NewTicketViewModel model) { var id = Guid.NewGuid(); var userId = Guid.Parse("88888888-8888-8888-8888-888888888888"); var files = model.Files == null || model.Files.Any() ? new List <File>() : await _fileUploader.UploadFiles(userId, model.Files.ToArray()); await _mediator.Send(new NewTicketCommand { Id = id, UserId = userId, Title = model.Title, Description = model.Description, PriorityId = model.PriorityId, Files = files.ToList() }); return(Ok(id)); }