public async Task <ISaida> CadastrarAnexo([FromForm, SwaggerParameter("Informações de cadastro do anexo.", Required = true)] CadastrarAnexoViewModel model) { CadastrarAnexoEntrada cadastrarEntrada; using (var memoryStream = new MemoryStream()) { await model.Arquivo.CopyToAsync(memoryStream); cadastrarEntrada = new CadastrarAnexoEntrada( base.ObterIdUsuarioClaim(), model.IdLancamento.Value, model.Descricao, model.NomeArquivo + model.Arquivo.FileName.Substring(model.Arquivo.FileName.LastIndexOf(".")), memoryStream.ToArray(), model.Arquivo.ContentType); } return(await _lancamentoServico.CadastrarAnexo(cadastrarEntrada)); }
public async Task <IActionResult> CadastrarAnexo( [FromQuery, SwaggerParameter("ID do lançamento.", Required = true)] int idLancamento, [FromForm, SwaggerParameter("Informações de cadastro do anexo.", Required = true)] LancamentoAnexoViewModel model) { LancamentoAnexoEntrada entrada; using (var memoryStream = new MemoryStream()) { await model.Arquivo.CopyToAsync(memoryStream); entrada = new LancamentoAnexoEntrada( base.ObterIdUsuarioClaim(), model.Descricao, model.NomeArquivo + model.Arquivo.FileName.Substring(model.Arquivo.FileName.LastIndexOf(".")), memoryStream.ToArray(), model.Arquivo.ContentType); } return(new ApiResult(await _lancamentoServico.CadastrarAnexo(idLancamento, entrada))); }