Ejemplo n.º 1
0
        private async void ConfirmPictureAndGoBack()
        {
            Func <Task> confirmPicture = new Func <Task>(
                async() =>
            {
                if (ImageTakenPreview != null)
                {
                    var imageStream       = _selectedPicture.GetStream();
                    _newProfilePictureUrl = await AzureStorageService.LoadImage(imageStream, _selectedPicture.Path);
                    ViewModelFactory.GetInstance <MainMenuViewModel>().UpdateCurrentUserImage(_newProfilePictureUrl);
                    ImageLocation = _newProfilePictureUrl;
                    CurrentUser.UserProfilePictureUrl = ImageLocation;
                    _selectedPicture.Dispose();
                    _selectedPicture = null;
                    OnPropertyChanged("CurrentUser");

                    await((MasterDetailPage)App.Current.MainPage).Detail.Navigation.PopModalAsync();
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Alert", "Please take or select an image first", "OK");
                }
            });

            await ExecuteSafeOperation(confirmPicture);
        }
Ejemplo n.º 2
0
 public FileController(
     AzureStorageService _azure,
     IStringLocalizer <FileController> localizer)
 {
     azure = _azure;
     l     = localizer;
 }
        private async void UploadImageToServer(String userId, String fileName, FileStream imageStream)
        {
            try
            {
                var service = new AzureStorageService(Services.AzureConnectionString, userId);
                var status  = await service.SaveFileToBlob(fileName, imageStream);

                if (status.IsSuccess)
                {
                    var url     = Services.CardBaseUrl + userId + "/" + fileName;
                    var newCard = new CardEntity {
                        Url = url
                    };
                    BirthdayUtility.AddBirthdayCard(newCard);

                    var birthdays = DataContext as Birthdays;

                    if (birthdays != null)
                    {
                        birthdays.BirthdayCards.Add(newCard);
                    }
                }
                else
                {
                    MessageBox.Show(status.ErrorMessage, AppResources.ErrAddCard, MessageBoxButton.OK);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, AppResources.ErrAddCard, MessageBoxButton.OK);
            }
        }
        public async Task InvalidFile_UsingBlobWithSignedUri_ShouldReturnError()
        {
            var instance = new AzureStorageService(InvalidSource(), NullLoggerFactory.Instance);
            var content  = await instance.FetchData(null);

            Assert.True(content.SyncError && !content.HasResult, "Response must be invalid");
        }
Ejemplo n.º 5
0
        public void SaveFileToBlob_ValidScenario_ReturnTrue()
        {
            FileStream          stream  = new FileStream(@"D:/DSC_0235.jpg", FileMode.Open);
            AzureStorageService service = new AzureStorageService(stream, "AAAA", "test.jpg");
            var response = service.SaveFileToBlob();

            Assert.IsTrue(response.IsSuccess);
        }
        public void SaveFileToBlob_ValidScenario_ReturnTrue()
        {
            FileStream stream = new FileStream(@"D:/DSC_0235.jpg", FileMode.Open);
            AzureStorageService service = new AzureStorageService(stream, "AAAA", "test.jpg");
            var response = service.SaveFileToBlob();

            Assert.IsTrue(response.IsSuccess);
        }
Ejemplo n.º 7
0
 public CatagoryController(ApplicationDbContext dbContext, IDataProtectionProvider dataProtectionProvider,
                           IConfiguration configuration)
 {
     catagoryService     = new CatagoryService(dbContext);
     fileUploadService   = new FileUploadService();
     _protector          = dataProtectionProvider.CreateProtector("");
     azureStorageService = new AzureStorageService(configuration);
 }
        public async Task ValidFile_UsingBlobWithSignedUri_ShouldReturnValidConfiguration()
        {
            var instance = new AzureStorageService(ValidSourceWithSignedUri(), NullLoggerFactory.Instance);
            var content  = await instance.FetchData(null);

            Assert.True(content.HasResult, "Error while fetching data from a SignedUri");
            Assert.True(content.Configuration != null, "Error while deserializing data from a SignedUri");
        }
 public DefaultController(YoutubeService youtubeService, ApplicationDbContext db, EmotionServiceClient emotionService, IHostingEnvironment hostingEnvironment, AzureStorageService storageService, FFMpegLocator ffmpegLocator)
 {
     this.youtubeService     = youtubeService;
     this.db                 = db;
     this.emotionService     = emotionService;
     this.hostingEnvironment = hostingEnvironment;
     this._StorageService    = storageService;
     this._FFMpegLocator     = ffmpegLocator;
 }
Ejemplo n.º 10
0
 public PackageController(
     AzureStorageService _storageService,
     SdkDbContext _sdkDB,
     IStringLocalizer <PackageController> localizer)
 {
     storageService = _storageService;
     sdkDB          = _sdkDB;
     l = localizer;
 }
        public async Task ValidFile_ConsecutiveCalls_ShouldSkipSecondFetch()
        {
            var instance = new AzureStorageService(ValidSourceWithSignedUri(), NullLoggerFactory.Instance);
            var content1 = await instance.FetchData(null);

            Assert.True(content1.HasResult, "Invalid object detected");
            var content2 = await instance.FetchData(content1.Version);

            Assert.False(content2.HasResult, "Fetch must not have place is same version is detected");
        }
Ejemplo n.º 12
0
        public static NodeEntryPoint StartWithOptions(NodeOptions options, Action <int> termination)
        {
            var slim = new ManualResetEventSlim(false);
            var list = String.Join(Environment.NewLine,
                                   options.GetPairs().Select(p => String.Format("{0} : {1}", p.Key, p.Value)));

            Log.Info(list);

            var bus        = new InMemoryBus("OutputBus");
            var controller = new NodeController(bus);
            var mainQueue  = new QueuedHandler(controller, "Main Queue");

            controller.SetMainQueue(mainQueue);
            Application.Start(i =>
            {
                slim.Set();
                termination(i);
            });

            var http = new PlatformServerApiService(mainQueue, String.Format("http://{0}:{1}/", options.LocalHttpIp, options.HttpPort));

            bus.Subscribe <SystemMessage.Init>(http);
            bus.Subscribe <SystemMessage.StartShutdown>(http);


            var timer = new TimerService(new ThreadBasedScheduler(new RealTimeProvider()));

            bus.Subscribe <TimerMessage.Schedule>(timer);

            // switch, based on configuration
            AzureStoreConfiguration azureConfig;

            if (AzureStoreConfiguration.TryParse(options.StoreLocation, out azureConfig))
            {
                var storageService = new AzureStorageService(azureConfig, mainQueue);
                bus.Subscribe <ClientMessage.AppendEvents>(storageService);
                bus.Subscribe <SystemMessage.Init>(storageService);
                bus.Subscribe <ClientMessage.ImportEvents>(storageService);
                bus.Subscribe <ClientMessage.RequestStoreReset>(storageService);
            }
            else
            {
                var storageService = new FileStorageService(options.StoreLocation, mainQueue);
                bus.Subscribe <ClientMessage.AppendEvents>(storageService);
                bus.Subscribe <SystemMessage.Init>(storageService);
                bus.Subscribe <ClientMessage.ImportEvents>(storageService);
                bus.Subscribe <ClientMessage.RequestStoreReset>(storageService);
            }


            mainQueue.Start();

            mainQueue.Enqueue(new SystemMessage.Init());
            return(new NodeEntryPoint(mainQueue, slim));
        }
Ejemplo n.º 13
0
        private void ConfigureServices()
        {
            _storageServices = new Dictionary <string, IStorageService>();

            foreach (var ss in _hiarcSettings.StorageServices)
            {
                if (ss.Provider == AWS_S3)
                {
                    var settings = new S3Settings
                    {
                        AccessKeyId      = ((dynamic)ss.Config).AccessKeyId,
                        SecretAccessKey  = ((dynamic)ss.Config).SecretAccessKey,
                        RegionSystemName = ((dynamic)ss.Config).RegionSystemName,
                        Bucket           = ((dynamic)ss.Config).Bucket
                    };
                    IOptions <S3Settings> s3Settings = Options.Create(settings);

                    IStorageService s3Service = new S3StorageService(ss.Name, s3Settings, ss.AllowDirectDownload, ss.AllowDirectUpload, _logger);
                    _storageServices.Add(ss.Name, s3Service);
                }
                else if (ss.Provider == AZURE_BLOB_STORAGE)
                {
                    var settings = new AzureSettings
                    {
                        StorageConnectionString = ((dynamic)ss.Config).StorageConnectionString,
                        Container = ((dynamic)ss.Config).Container
                    };

                    IOptions <AzureSettings> azureSettings = Options.Create(settings);

                    IStorageService azureService = new AzureStorageService(ss.Name, azureSettings, ss.AllowDirectDownload, ss.AllowDirectUpload, _logger);
                    _storageServices.Add(ss.Name, azureService);
                }
                else if (ss.Provider == GOOGLE_STORAGE)
                {
                    var settings = new GoogleSettings
                    {
                        ServiceAccountCredential = ((dynamic)ss.Config).ServiceAccountCredential,
                        Bucket = ((dynamic)ss.Config).Bucket
                    };

                    IOptions <GoogleSettings> googleSettings = Options.Create(settings);

                    IStorageService googleService = new GoogleStorageService(ss.Name, googleSettings, ss.AllowDirectDownload, ss.AllowDirectUpload, _logger);
                    _storageServices.Add(ss.Name, googleService);
                }
                else
                {
                    throw new Exception($"Unsupported storage service provider: {ss.Provider}");
                }
            }
        }
        async Task ExecuteTakePhotoCommand()
        {
            bool   success = false;
            Stream photoStream;
            var    photoService = new PhotoService();

            var result = await Shell.Current.DisplayActionSheet("Smart Shopping", "Cancel", null, "Take Photo", "Select from Camera Roll");


            if (result.Equals("Take Photo", StringComparison.OrdinalIgnoreCase))
            {
                photoStream = await photoService.TakePhoto();
            }
            else
            {
                photoStream = await photoService.PickPhoto();
            }

            try
            {
                IsBusy = true;

                var storage = new AzureStorageService();
                var sas     = await storage.GetSharedAccessSignature();

                success = await storage.UploadPhoto(photoStream, sas);

                Shell.Current.FlyoutIsPresented = false;
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex, new Dictionary <string, string> {
                    { "Function", "AzureShellViewModel.ExecuteTakePhotoCommand" }
                });
            }
            finally
            {
                IsBusy = false;
            }

            var toast = new NotificationOptions
            {
                Title            = success ? "Upload Succeeded" : "Upload Failed",
                Description      = success ? "Photo successfully uploaded" : "There was an error while uploading",
                ClearFromHistory = true,
                IsClickable      = false
            };

            var notification = DependencyService.Get <IToastNotificator>();

            await notification.Notify(toast);
        }
 public CodeGenController(
     AzureStorageService _storageService,
     IStringLocalizer <CodeGenController> localizer,
     SwaggerCodeGenService _swagerCodeGen,
     INodeServices _nodeServices,
     RedisService _redis)
 {
     l              = localizer;
     swagerCodeGen  = _swagerCodeGen;
     nodeServices   = _nodeServices;
     storageService = _storageService;
     redis          = _redis;
 }
Ejemplo n.º 16
0
        public static NodeEntryPoint StartWithOptions(NodeOptions options, Action<int> termination)
        {
            var slim = new ManualResetEventSlim(false);
            var list = String.Join(Environment.NewLine,
                options.GetPairs().Select(p => String.Format("{0} : {1}", p.Key, p.Value)));

            Log.Info(list);

            var bus = new InMemoryBus("OutputBus");
            var controller = new NodeController(bus);
            var mainQueue = new QueuedHandler(controller, "Main Queue");
            controller.SetMainQueue(mainQueue);
            Application.Start(i =>
                {
                    slim.Set();
                    termination(i);
                });

            var http = new PlatformServerApiService(mainQueue, String.Format("http://{0}:{1}/", options.LocalHttpIp, options.HttpPort));

            bus.Subscribe<SystemMessage.Init>(http);
            bus.Subscribe<SystemMessage.StartShutdown>(http);

            var timer = new TimerService(new ThreadBasedScheduler(new RealTimeProvider()));
            bus.Subscribe<TimerMessage.Schedule>(timer);

            // switch, based on configuration
            AzureStoreConfiguration azureConfig;
            if (AzureStoreConfiguration.TryParse(options.StoreLocation, out azureConfig))
            {
                var storageService = new AzureStorageService(azureConfig, mainQueue);
                bus.Subscribe<ClientMessage.AppendEvents>(storageService);
                bus.Subscribe<SystemMessage.Init>(storageService);
                bus.Subscribe<ClientMessage.ImportEvents>(storageService);
                bus.Subscribe<ClientMessage.RequestStoreReset>(storageService);
            }
            else
            {
                var storageService = new FileStorageService(options.StoreLocation, mainQueue);
                bus.Subscribe<ClientMessage.AppendEvents>(storageService);
                bus.Subscribe<SystemMessage.Init>(storageService);
                bus.Subscribe<ClientMessage.ImportEvents>(storageService);
                bus.Subscribe<ClientMessage.RequestStoreReset>(storageService);
            }

            mainQueue.Start();

            mainQueue.Enqueue(new SystemMessage.Init());
            return new NodeEntryPoint(mainQueue,slim);
        }
        public async Task Run([TimerTrigger("0 0 */6 * * *")] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"Timer trigger function started at: {DateTime.Now}");

            // instanciando os serviços
            var storageService = new AzureStorageService(_config["AzureBlobConnectionString"]);
            var apiClient      = new ApiClient();

            List <ApiToJsonEntity> listApiToJson = await ApiToJsonRepository.GetAll();

            ApiJsonCacheGenerator cacheGenerator = new ApiJsonCacheGenerator(log, storageService, apiClient);

            cacheGenerator.Generate(listApiToJson);
        }
 public CodeGenController(
     AzureStorageService _storageService,
     IStringLocalizer <CodeGenController> localizer,
     SwaggerCodeGenService _swagerCodeGen,
     INodeServices _nodeServices,
     //RedisService _redis,
     IDistributedCache _cache)
 {
     l              = localizer;
     swagerCodeGen  = _swagerCodeGen;
     nodeServices   = _nodeServices;
     storageService = _storageService;
     //redis = _redis;
     cache = _cache;
 }
Ejemplo n.º 19
0
        public async Task UpdateStorageAccountReplayLog(string storageAccountConnectionString, string tableName, string subscriptionId, string resourceGroupName, string logicAppName, string oldRunId, string newRunId)
        {
            AzureStorageService azureStorageService = new AzureStorageService(storageAccountConnectionString);
            var _createTable = await azureStorageService.CreateCloudTable(tableName);

            LogicAppRunLog entity = new LogicAppRunLog();

            entity.PartitionKey = $"{subscriptionId}@{resourceGroupName}@{logicAppName}";
            entity.RowKey       = $"{oldRunId}";

            entity.IsReplayed = true;
            entity.NewRunId   = newRunId;

            await azureStorageService.InsertOrMergeEntityToTable(tableName, entity, enableMerge : true);
        }
        private async void btnAddPicture_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                pictureName = await FilePicker.FilePickerAsync();

                if (pictureName != null)
                {
                    byte[] picture = await AzureStorageService.GetPictureAsync(pictureName);

                    imageAdd.Source = await ByteArrayToImageAsync(picture);
                }
            }
            catch { }
        }
Ejemplo n.º 21
0
        public async Task Test_Upload_To_Azure_Storage_Should_Ret_Status_Success()
        {
            // Arrange
            var fileName = Guid.NewGuid().ToString() + "-" + "SampleFAQ.tsv";
            var filePath = @"D:\Tmp\SampleFAQ.tsv";
            AzureStorageService service = new AzureStorageService();

            using (var stream = new FileStream(filePath, FileMode.Open))
            {
                // Act
                var result = await service.UploadToAzureStorage(connectionString, containerName, fileName, stream);

                // Assert
                Assert.IsTrue(result.ResultStatus == ActionStatus.Success);
            }
        }
Ejemplo n.º 22
0
        async Task ExecuteTakePhotoCommand()
        {
            bool   success = false;
            Stream photoStream;
            var    photoService = new PhotoService();

            var result = await Shell.Current.DisplayActionSheet("Smart Shopping", "Cancel", null, "Take Photo", "Select from Camera Roll");


            if (result.Equals("Take Photo", StringComparison.OrdinalIgnoreCase))
            {
                photoStream = await photoService.TakePhoto();
            }
            else
            {
                photoStream = await photoService.PickPhoto();
            }

            try
            {
                IsBusy = true;

                var storage = new AzureStorageService();
                var sas     = await storage.GetSharedAccessSignature();

                if (!(string.IsNullOrWhiteSpace(sas)))
                {
                    success = await storage.UploadPhoto(photoStream, sas);
                }

                Shell.Current.FlyoutIsPresented = false;
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex, new Dictionary <string, string> {
                    { "Function", "AzureShellViewModel.ExecuteTakePhotoCommand" }
                });
            }
            finally
            {
                IsBusy = false;
            }

            var message = success ? "Photo successfully uploaded" : "There was an error while uploading";
            var snack   = DependencyService.Get <IXSnack>();
            await snack.ShowMessageAsync(message);
        }
        public async Task <int> Delete(long id)
        {
            AzureStorageService azureStorageService = serviceProvider.GetService <AzureStorageService>();
            Activity            model = await ActivityLogic.ReadById(id);

            if (model.Attachments != null)
            {
                foreach (ActivityAttachment attachment in model.Attachments)
                {
                    await azureStorageService.DeleteImage("Activity", attachment.FilePath);
                }
            }

            await ActivityLogic.Delete(id);

            return(await DbContext.SaveChangesAsync());
        }
Ejemplo n.º 24
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                IStorageService storageService = new AzureStorageService();
                string          accessToken    = storageService.GetAccessToken();
                string          form           = collection.GetValue("upn").AttemptedValue;


                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 25
0
        static void Main(string[] args)
        {
            var service = new AzureStorageService(
                ConfigurationManager.AppSettings["AzureServerName"],
                ConfigurationManager.AppSettings["AzureUserName"],
                ConfigurationManager.AppSettings["AzurePassword"],
                ConfigurationManager.AppSettings["AzureStorageAccountName"],
                ConfigurationManager.AppSettings["AzureStorageKey"],
                ConfigurationManager.AppSettings["AzureBlobContainer"],
                DacServiceUrls.NorthCentralUs
                );

            // perform the backup
            string filename;    // filename generated for the bacpac backup
            service.BackupDataSync("DatabaseName", out filename);

            // cleanup the storage container
            service.BlobCleanup();
        }
        private async Task GetIssue(int detailId)
        {
            try
            {
                List <Issue> issue = GetDataService.GetIssueDetailsAsync(detailId).GetAwaiter().GetResult();

                foreach (var i in issue)
                {
                    List <Picture> picture = new List <Picture>();
                    tbxIssue.Text     = i.Issue1;
                    tbxIssueDate.Text = i.IssueTime.ToString();
                    tbxCustomer.Text  = i.Customer.CustomerName;
                    tbxId.Text        = $"Issue id: {i.IssueId}";;
                    tbxCategory.Text  = i.Category.Category1;
                    tbxSituation.Text = i.Situation.Situation1;

                    picture = i.Picture.ToList();
                    if (picture != null)
                    {
                        try
                        {
                            foreach (var p in picture)
                            {
                                byte[] pic = await AzureStorageService.GetPictureAsync(p.Picture1.ToString());

                                imageDetail.Source = await ByteArrayToImageAsync(pic);
                            }
                        }
                        catch { }
                    }

                    var comms = i.Comment.ToList();
                    if (comms != null)
                    {
                        foreach (var c in comms)
                        {
                            comments.Add(c);
                        }
                    }
                }
            }
            catch { }
        }
Ejemplo n.º 27
0
        public async Task <ActionResult> Authorize(string code)
        {
            //Get access token
            var authContext = new AuthenticationContext(Settings.microsoftLoginUrl);
            var authResult  = await authContext.AcquireTokenByAuthorizationCodeAsync(
                code,
                new Uri($"{ConfigurationManager.AppSettings["AppUrl"]}/Auth/Authorize"),
                new ClientCredential(
                    ConfigurationManager.AppSettings["ClientId"],
                    ConfigurationManager.AppSettings["ClientSecret"]
                    )
                );

            #region Get access token and refresh token without ADAL. Because we can't get refresh token from ADAL authContext.<= refresh token is non-public members...
            Token token;
            using (var httpClient = new HttpClient())
            {
                HttpContent content = new FormUrlEncodedContent(new Dictionary <string, string>
                {
                    { "grant_type", "authorization_code" },
                    { "client_id", ConfigurationManager.AppSettings["ClientId"] },
                    { "client_secret", ConfigurationManager.AppSettings["ClientSecret"] },
                    { "redirect_uri", $"{ConfigurationManager.AppSettings["AppUrl"]}/Auth/Authorize" },
                    { "code", code }
                });
                //content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                HttpResponseMessage response = await httpClient.PostAsync(Settings.tokenEndpoint, content);

                token = await response.Content.ReadAsAsync <Token>();
            }
            #endregion

            #region Set Access Token & Refresh Token in Azue Storage Table
            IStorageService storageService = new AzureStorageService();
            storageService.SaveAccessToken(token);
            storageService.SaveRefreshToken(token);
            #endregion

            ViewBag.Message = "Plase input group alias for using award bot";

            return(View());
        }
Ejemplo n.º 28
0
        static async Task Main(string[] args)
        {
            AzureStorageService client = null;

            try
            {
                client = new AzureStorageService();

                client.Open();
                await client.CreateBlobContainer();

                Console.WriteLine(client.IsBlobContainerCreated ? "Created with success" : "Container already exists");

                foreach (var blob in await client.GetBlobs())
                {
                    Console.WriteLine(blob.Name);
                }

                var file = File.OpenRead("./test.txt");

                var name = $"test123{Guid.NewGuid()}";

                await client.Save(file, name);

                Thread.Sleep(2000);

                var stream = await client.Load(name);

                Console.WriteLine(new StreamReader(stream).ReadToEnd());
            }
            catch (Exception exception)
            {
                Console.Write(exception.Message);
            }
            finally
            {
                //await client?.Delete();
            }
        }
Ejemplo n.º 29
0
        public async Task LogToStorageAccount(IEnumerable <LogicAppWorkflowRun> logicAppWorkflowRuns, string storageAccountConnectionString, string tableName)
        {
            //string storageAccountConnectionString = "DefaultEndpointsProtocol=https;AccountName=azaust1lam585;AccountKey=1xTEw9Zf4aUtjfEaJs0DUNm5UWJ8t9mELjBOt+COd2dzfdngOr2uiahMJpG/8z7GegmzZ5RoA2mAbqS9XM9fvg==;EndpointSuffix=core.windows.net";
            //string tableName = "LogicAppRunHistory";

            AzureStorageService azureStorageService = new AzureStorageService(storageAccountConnectionString);
            var createTable = await azureStorageService.CreateCloudTable(tableName);

            foreach (var item in logicAppWorkflowRuns)
            {
                LogicAppRunLog entity = new LogicAppRunLog();
                entity.PartitionKey = $"{item.SubscriptionId}@{item.ResourceGroupName}@{item.LogicAppName}";
                entity.RowKey       = $"{item.Name}";

                var existedRecord = await azureStorageService.RetrieveEntityFromTable <LogicAppRunLog>(tableName, partitionKey : entity.PartitionKey, rowKey : entity.RowKey);

                if (existedRecord == null)
                {
                    await azureStorageService.InsertOrMergeEntityToTable(tableName, entity, enableMerge : false);
                }
            }
        }
Ejemplo n.º 30
0
 public ActivityController(IMapper mapper, IdentityService identityService, ValidateService validateService, ActivityFacade ActivityFacade, AzureStorageService azureStorageService) : base(mapper, identityService, validateService, ActivityFacade, apiVersion)
 {
     this.azureStorageService = azureStorageService;
 }
        private void DeleteAppBarClick(object sender, EventArgs e)
        {
            try
            {
                if (App.IsTrial)
                {
                    //messagebox to prompt to buy
                    var buyAppForDeleteMessageBox = new CustomMessageBox
                    {
                        Height             = 300,
                        Caption            = AppResources.BuyFullVersion,
                        Message            = AppResources.BuyAppForDelete,
                        LeftButtonContent  = AppResources.BuyLabel,
                        RightButtonContent = AppResources.LaterLabel,
                        VerticalAlignment  = VerticalAlignment.Center
                    };

                    buyAppForDeleteMessageBox.Dismissed += BuyAppForDeleteMessageBoxDismissed;
                    buyAppForDeleteMessageBox.Show();

                    return;
                }
                //display warning for confirmation
                var result = MessageBox.Show(AppResources.DeleteConfirmMessage, AppResources.DeleteLabel, MessageBoxButton.OKCancel);

                if (!result.Equals(MessageBoxResult.OK))
                {
                    return;
                }

                //check which list is active
                if (MainPagePanorama.SelectedItem.Equals(MostRecentPanorama))
                {
                    if (RecentBirthdayList != null && RecentBirthdayList.SelectedItems != null && RecentBirthdayList.SelectedItems.Count > 0)
                    {
                        foreach (FriendBirthday friend in RecentBirthdayList.SelectedItems)
                        {
                            BirthdayUtility.DeleteFriend(friend.Id);
                        }
                    }
                    else
                    {
                        MessageBox.Show(AppResources.WarnSelectItem, AppResources.WarnTryAgain, MessageBoxButton.OK);
                    }

                    BindDataContext();
                }
                else if (MainPagePanorama.SelectedItem.Equals(AllItemPanorama))
                {
                    if (AllBirthdayList != null && AllBirthdayList.SelectedItems != null && AllBirthdayList.SelectedItems.Count > 0)
                    {
                        foreach (FriendBirthday friend in AllBirthdayList.SelectedItems)
                        {
                            BirthdayUtility.DeleteFriend(friend.Id);
                        }
                    }
                    else
                    {
                        MessageBox.Show(AppResources.WarnSelectItem, AppResources.WarnTryAgain, MessageBoxButton.OK);
                    }

                    BindDataContext();
                }
                else if (MainPagePanorama.SelectedItem.Equals(BirthdayCardPanorama))
                {
                    //if image upload/delete is complete
                    if (NetworkInterface.GetIsNetworkAvailable())
                    {
                        if (BirthdayCardList != null && BirthdayCardList.SelectedItems != null && BirthdayCardList.SelectedItems.Count > 0)
                        {
                            var service      = new AzureStorageService(Services.AzureConnectionString, App.UserPreferences.UserDetails.FacebookId);
                            var items        = BirthdayCardList.SelectedItems;
                            var deletedCards = new List <int>();

                            if (items != null)
                            {
                                foreach (var cardEntity in items.Cast <CardEntity>())
                                {
                                    service.DeleteBlob(Path.GetFileName(cardEntity.Url));
                                    deletedCards.Add(cardEntity.Id);
                                }
                            }

                            var birthdays = DataContext as Birthdays;

                            if (birthdays == null)
                            {
                                return;
                            }

                            var birthdayCards = birthdays.BirthdayCards;

                            foreach (var cardId in deletedCards)
                            {
                                birthdayCards.Remove(birthdayCards.Single(c => c.Id == cardId));
                            }

                            //remove entry fromm database
                            BirthdayUtility.DeleteCards(deletedCards);
                        }
                        else
                        {
                            MessageBox.Show(AppResources.WarnSelectItem, AppResources.WarnTryAgain, MessageBoxButton.OK);
                        }
                    }
                    else
                    {
                        MessageBox.Show(AppResources.WarnInternetMsg, AppResources.WarnNwTitle, MessageBoxButton.OK);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, AppResources.ErrDeleting, MessageBoxButton.OK);
            }
        }