public async Task <string> SaveImageAsync(Bitmap image)
        {
            var imageName = _uniqueKeyService.GetUniqueKey(".bmp");
            await base.SaveImageAsync(image, imageName);

            return(imageName);
        }
        private string SaveFileInStorage(string storage, Bitmap file)
        {
            if (!Directory.Exists(storage))
            {
                Directory.CreateDirectory(storage);
            }

            var nameInStorage = _uniqueNameService.GetUniqueKey(".bmp");
            var wayToFile     = Path.Combine(storage, nameInStorage);

            using (var stream = new FileStream(wayToFile, FileMode.Create))
            {
                file.Save(stream, ImageFormat.Bmp);
            }
            return(wayToFile);
        }
Example #3
0
        public async Task <string> CreateContent(ContentModel content)
        {
            var key = await keyService.GetUniqueKey();

            if (key == null)
            {
                throw new InvalidOperationException("Cannot generate unique key");
            }
            var dbItem = new Content
            {
                Key      = key,
                Text     = content.Text,
                ExpireAt = content.ExpireAt.HasValue ? content.ExpireAt.Value.ToString("s") : null
            };
            await contentRepository.Add(dbItem);

            return(key);
        }