public Task <long> CreateParecer(CreateParecerCommand command) { var requestUrl = CreateRequestUri(string.Format(System.Globalization.CultureInfo.InvariantCulture, $"{ResourceParecer}/CreateParecer")); return(Post(requestUrl, command)); }
public async Task <ActionResult <long> > CreateParecer(CreateParecerCommand command) { try { var result = await Mediator.Send(command); return(result); } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task <IActionResult> Create(IFormCollection collection) { try { string uniqueFileName = null; var listParecerArquivo = new List <ParecerArquivoDto>(); if (collection.Files.Count > 0) { var file = collection.Files; foreach (var item in file) { string uploadsFolder = Path.Combine(_hostingEnvironment.WebRootPath, "ParecerArquivo"); string extension = Path.GetExtension(item.FileName); uniqueFileName = Guid.NewGuid().ToString() + extension; var realName = item.GetFilename(); string filePath = Path.Combine(uploadsFolder, uniqueFileName); item.CopyTo(new FileStream(filePath, FileMode.Create)); listParecerArquivo.Add(new ParecerArquivoDto { NomeArquivo = uniqueFileName, Arquivo = realName, Caminho = "ParecerArquivo" }); } } var command = new CreateParecerCommand { CodRelato = int.Parse(collection["CodRelato"].ToString()), DscParecer = collection["DscParecer"].ToString(), ListParecerArquivo = listParecerArquivo, FlgStatusRelato = (int)EnumStatusRelato.OcorrenciaAtendida, FlgStatusParecer = (int)EnumStatusParecer.Atendida, DscParecerStatus = EnumStatusParecer.Atendida.GetDescription() + ", " + DateTime.Now.ToString("dd/MM/yyyy") + ", " + DateTime.Now.ToString("hh:mm"), CriadoPor = User.Identity.Name }; var idParecer = await ApiClientFactory.Instance.CreateParecer(command); return(RedirectToAction(nameof(Create), new { crud = (int)EnumCrud.Created })); } catch (Exception ex) { return(RedirectToAction(nameof(Create), new { notify = (int)EnumNotify.Error, message = ex.Message })); } }