コード例 #1
0
        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"));
            }
        }