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 async Task <IActionResult> AdicionarFotoDropZone(Guid id)
        {
            byte[] miniImagemByte;
            foreach (var imagem in Request.Form.Files)
            {
                using (var memoryStream = new MemoryStream())
                {
                    await imagem.CopyToAsync(memoryStream);

                    miniImagemByte = EditorDeImagem.DrawSize(memoryStream.ToArray(), 256);
                }

                Foto foto = new Foto();
                foto.Id          = Guid.NewGuid();
                foto.Album.Id    = id;
                foto.Descricao   = String.Empty;
                foto.Nome        = String.Empty;
                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.CriarComId(foto);
            }
            return(Ok());
        }