Beispiel #1
0
        public Image GetUploadedImage(IHaveImage model)
        {
            using (var memory = new MemoryStream())
            {
                model.UploadedImage.InputStream.CopyTo(memory);
                var content = memory.GetBuffer();

                var fileExtension = model.UploadedImage.FileName.Split('.').Last();

                var image = new Image
                {
                    Content       = content,
                    FileExtension = fileExtension,
                    CreatedOn     = DateTime.Now,
                };

                this.data.Images.Add(image);
                this.data.SaveChanges();

                return(image);
            }
        }
Beispiel #2
0
        public Image GetUploadedImage(IHaveImage model)
        {
            using (var memory = new MemoryStream())
            {
                model.UploadedImage.InputStream.CopyTo(memory);
                var content = memory.GetBuffer();

                var fileExtension = model.UploadedImage.FileName.Split('.').Last();

                var image = new Image
                {
                    Content = content,
                    FileExtension = fileExtension,
                    CreatedOn = DateTime.Now,
                };

                this.data.Images.Add(image);
                this.data.SaveChanges();

                return image;
            }
        }