public void TestDeleteFilesWithEvent()
        {
            var tempFiles = RandomData.GenerateFiles(_fileCount, _fileLength);

            var processor = new FileProcessor();

            processor.Processed += this.Processor_Processed;

            _ = processor.DeleteFiles(_tempFiles);

            processor.Processed -= this.Processor_Processed;
        }
示例#2
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            Campaign campaign = Db.Campaigns.Find(id);
            var      proDatas = Db.ProDatas.Where(x => x.CampaignId == campaign.Id);

            foreach (var proData in proDatas)
            {
                Db.ProDatas.Remove(proData);
            }
            Db.SaveChanges();

            var segments = Db.CampaignSegments.Where(x => x.CampaignId == campaign.Id);

            foreach (var segment in segments)
            {
                Db.CampaignSegments.Remove(segment);
            }
            Db.SaveChanges();

            var assets = Db.CampaignAssets.FirstOrDefault(x => x.CampaignId == campaign.Id);

            if (assets != null)
            {
                Db.CampaignAssets.Remove(assets);
            }
            Db.SaveChanges();

            var testing = Db.CampaignsTesting.FirstOrDefault(x => x.CampaignId == campaign.Id);

            if (testing != null)
            {
                Db.CampaignsTesting.Remove(testing);
            }
            Db.SaveChanges();

            var approved = Db.CampaignsApproved.FirstOrDefault(x => x.CampaignId == campaign.Id);

            if (approved != null)
            {
                Db.CampaignsApproved.Remove(approved);
            }
            Db.SaveChanges();

            var trackings = Db.CampaignTrackings.Where(x => x.CampaignId == campaign.Id);

            foreach (var tracking in trackings)
            {
                Db.CampaignTrackings.Remove(tracking);
            }
            Db.SaveChanges();

            var notifications = Db.Notifications.Where(x => x.CampaignId == campaign.Id);

            foreach (var notification in notifications)
            {
                Db.Notifications.Remove(notification);
            }
            Db.SaveChanges();

            Db.Campaigns.Remove(campaign);
            Db.SaveChanges();

            string orderNumber = campaign.OrderNumber;

            if (!IsUseS3)
            {
                FileProcessor.DeleteFiles(UploadPath, orderNumber);
            }

            ForceOrders         = true;
            TempData["Success"] = "Order :" + orderNumber + " has been DELETED succesfully.";
            return(RedirectToAction("Index"));
        }