Ejemplo n.º 1
0
        public async Task <string> PersistAsync(string path, BreadFile file)
        {
            string fileName = GetFileName(file);

            CheckPath(path);

            path = Path.Combine(path, fileName);

            await File.WriteAllBytesAsync(path, file.Bytes);

            return(fileName);
        }
Ejemplo n.º 2
0
        public async Task AddImageAsync(int id, BreadFile image)
        {
            BLL.Restaurant bllRestaurant = await restaurantRepository.GetAsync(id);

            string restaurantPath = Path.Combine(storageOptions.RestaurantUploadsAbsolutePath, bllRestaurant.Name);

            string imagePath =
                await uploadsHandler.PersistAsync(restaurantPath, image);

            bllRestaurant.ImagePath = Path.Combine(GetRestaurantUploadsUrl(), imagePath).Replace("\\", "/");

            await restaurantRepository.UpdateAsync(bllRestaurant);
        }
Ejemplo n.º 3
0
        public async Task AddImageAsync(int id, BreadFile image)
        {
            BLL.Product bllProduct = await productRepository.GetAsync(id);

            if (bllProduct == null)
            {
                return;
            }

            BLL.Restaurant bllRestaurant = await restaurantRepository.GetAsync(bllProduct.RestaurantId);

            string productsPath = Path.Combine(storageOptions.RestaurantUploadsAbsolutePath, bllRestaurant.Name, ProductsFolderName);

            string imagePath =
                await uploadsHandler.PersistAsync(productsPath, image);

            bllProduct.ImagePath = Path.Combine(GetRestaurantUploadsUrl(bllRestaurant.Name), imagePath).Replace("\\", "/");

            await productRepository.UpdateAsync(bllProduct);
        }
Ejemplo n.º 4
0
 private static string GetFileName(BreadFile file)
 {
     return(Guid.NewGuid().ToString() + file.Extension);
 }