Пример #1
0
        public virtual async Task SaveAsync(T item)
        {
            if (item.Guid.Equals(Guid.Empty))
            {
                item.Guid = Guid.NewGuid();
            }

            string fileName = this.GetFileName(item);
            string json     = JsonConvert.SerializeObject(item);

            await _fileManager.SaveFileAsync(fileName, json);
        }
Пример #2
0
        public async Task <string> SaveAsync(Stream stream)
        {
            string fileName = String.Format("{0}.jpg", Guid.NewGuid());

            // Resize
            using (var image = Image.Load <Rgba32>(stream))
            {
                ImageHelper.Resize(image, MaxWidth, MaxHeight);
                using (Stream stream2 = new MemoryStream())
                {
                    image.Save(stream2, new JpegEncoder());
                    stream2.Position = 0;
                    var url = await _fileManager.SaveFileAsync(fileName, stream2);

                    return(url);
                }
            }
        }
Пример #3
0
        public virtual async Task SaveAsync(Site item)
        {
            string json = JsonConvert.SerializeObject(item);

            await _fileManager.SaveFileAsync("site.json", json);
        }