コード例 #1
0
        public async Task <IActionResult> CadastrarNovo(Foto foto, IFormFile imagem)
        {
            byte[] miniImagemByte;

            using (var memoryStream = new MemoryStream())
            {
                await imagem.CopyToAsync(memoryStream);

                miniImagemByte = EditorDeImagem.DrawSize(memoryStream.ToArray(), 256);
            }
            foto.FotoUrl     = _fileServerService.UploadFile("_Foto", imagem.OpenReadStream(), SistemaFotografa.InfraStructure.AzureStorage.Properties.Resources.AzureBlobContainer, imagem.ContentType, foto.Album.Id.ToString());
            foto.MiniFotoUrl = _fileServerService.UploadFile("_MiniFoto", new MemoryStream(miniImagemByte), SistemaFotografa.InfraStructure.AzureStorage.Properties.Resources.AzureBlobContainer, imagem.ContentType, foto.Album.Id.ToString());
            _fotoService.Criar(foto);
            _session.SetString("Alertas", "Muito bem!!!|Você acabou de cadastrar uma foto!");
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult <Foto> PostFoto(Foto foto)
        {
            _fotoService.Criar(foto);

            return(CreatedAtAction("GetFoto", new { id = foto.Id }, foto));
        }