public ActionResult <Foto> PostFotoComId(Guid Id, Foto foto)
        {
            foto.Id = Id;
            _fotoService.CriarComId(foto);

            return(CreatedAtAction("GetFoto", new { id = foto.Id }, foto));
        }
Ejemplo n.º 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());
        }