Пример #1
0
        public ActionResult ApprovalDetails(int id)
        {
            CampaignModule campaignModule = new CampaignModule();

            var campaign = campaignModule.GetCampaign(id);
            if (campaign.TypeId == (int)CampaignType.Email)
            {
                ViewBag.EmailList = campaignModule.GetCampaignEmails(campaign.Id);
            }
            else
            {
                ViewBag.SmsList = campaignModule.GetCampaignSmses(campaign.Id);
            }

            return View(campaign);
        }
Пример #2
0
        public FileResult Export(int campaignId, int statusId)
        {
            CampaignModule campaignModule = new CampaignModule();
            var campaign = campaignModule.GetCampaign(campaignId);
            string fileName = "export-" + campaign.Id + ".csv";
            var memoryStream = new MemoryStream();
            var streamWriter = new StreamWriter(memoryStream);
                if (campaign.TypeId == (int)CampaignType.Email)
                {
                    var emailList = campaignModule.GetCampaignEmails(campaign.Id).Where(p => p.StatusId == statusId);
                    using (var csv = new CsvWriter(streamWriter))
                    {
                        csv.WriteRecords(emailList);
                    }
                }
                else
                {
                    var smsList = campaignModule.GetCampaignSmses(campaign.Id).Where(p => p.StatusId == statusId);
                    using (var csv = new CsvWriter(streamWriter))
                    {
                        csv.WriteRecords(smsList);
                    }
                }

                MemoryStream newStream = new MemoryStream(memoryStream.ToArray());
                newStream.Seek(0, SeekOrigin.Begin);

                return File(newStream, "text/csv", fileName);
        }
Пример #3
0
        public ActionResult Details(int id)
        {
            CampaignModule campaignModule = new CampaignModule();

            var campaign = campaignModule.GetCampaign(id);
            int newStatus = 0, send = 0, failed = 0;

            if (campaign.TypeId == (int)CampaignType.Email)
            {
                var emailList = campaignModule.GetCampaignEmails(campaign.Id);
                if (emailList != null)
                {
                    newStatus = emailList.Where(p => p.StatusId == (int)MessageStatus.New).Count();
                    send = emailList.Where(p => p.StatusId == (int)MessageStatus.Send).Count();
                    failed = emailList.Where(p => p.StatusId == (int)MessageStatus.Failed).Count();
                }

            }
            else
            {
                var smsList = campaignModule.GetCampaignSmses(campaign.Id);
                if (smsList != null)
                {
                    newStatus = smsList.Where(p => p.StatusId == (int)MessageStatus.New).Count();
                    send = smsList.Where(p => p.StatusId == (int)MessageStatus.Send).Count();
                    failed = smsList.Where(p => p.StatusId == (int)MessageStatus.Failed).Count();
                }
            }
            ViewBag.NewStatus = newStatus.ToString();
            ViewBag.Send = send.ToString();
            ViewBag.Failed = failed.ToString();

            return View(campaign);
        }