public async Task <IActionResult> Post([FromBody] FileViewModel model) { //string FilePath, string CodSeqAnexo, string FtpPath, string IdOs, string CodFuncionario try { if (!model.FileVMisValid()) { return(BadRequest($"Invalid parameters")); } var ansFile = new AnsFile(model.IdOs, model.Name(), model.Extension(), model.FilePath, model.FtpPath, model.CodSeqAnexo); UploadFileProcess(model, ansFile); var ansFileCreated = await _ansFileService.CreateAsync(ansFile); if (ansFileCreated == null) { return(NotFound($"Error: New File {model.FullName} not created")); } return(Ok($"File Created!")); } catch (Exception) { return(NotFound($"Error: New File {model.FullName} not created")); } }
public IActionResult Get(string fullName, string idOs) { var model = new FileViewModel() { FullName = fullName, IdOs = idOs }; if (!model.NameIsValid() && string.IsNullOrWhiteSpace(idOs)) { return(BadRequest($"Invalid parameters")); } var ansFile = _ansFileService.getFileByIdOs(model.Name(), model.Extension(), idOs); return(new ObjectResult( new FileViewModel(ansFile.Id, ansFile.File.FullName(), ansFile.File.FilePath, ansFile.File.FtpFilePath, ansFile.IdOs, ansFile.File.CodSeqAnexo, ansFile.CodFuncionario) )); }
public IActionResult Get(string fullName, string idOs, int codFuncionario) { var model = new FileViewModel() { FullName = fullName, IdOs = idOs, CodFuncionario = codFuncionario }; if (!model.NameIsValid() && !model.IdOsIsValid() && !model.CodFuncionarioIsValid()) { return(BadRequest($"Invalid parameters")); } var ansFile = _ansFileService.GetFileByEmployee(model.Name(), model.Extension(), idOs, codFuncionario); return(new ObjectResult( new FileViewModel(ansFile.Id, ansFile.File.FullName(), ansFile.File.FilePath, ansFile.File.FtpFilePath, ansFile.IdOs, ansFile.File.CodSeqAnexo, ansFile.CodFuncionario) )); }