Ejemplo n.º 1
0
        public async Task <IActionResult> AddPhoto(IFormFile Image, int id)
        {
            Memory memory = _memoryRepository.GetById(id);

            if (Image != null)
            {
                using (var stream = new MemoryStream())
                {
                    await Image.CopyToAsync(stream);

                    memory.AddPhoto(new Photo(Convert.ToBase64String(stream.ToArray())));
                }
            }
            _memoryRepository.Update(memory);
            _memoryRepository.SaveChanges();

            return(Ok());
        }