public ActionResult Create(CampaignVM campaign)
        {
            try
            {
                ViewBag.CampaignTypes = GetCampaignTypes();
                if (ModelState.IsValid)
                {
                    ViewBag.CampaignTypes = GetCampaignTypes();
                    campaign.CreatedBy = User.Identity.Name;
                    var campaignModule = new CampaignModule();
                    var report = campaignModule.ValidateCampaign(campaign);
                    TempData["CampaignReport"] = report;
                    return View("Report", report.Validations);
                }
                ViewBag.Message = "Error in input. Please correct the errors";

                return View(campaign);
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
                ViewBag.Message = "Cannot create campaign";
                return View(campaign);

            }
        }
        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);
        }
 public ActionResult Approve(int id)
 {
     var response = new CampaignModule().ApproveCampaign(id);
     return Json(response, JsonRequestBehavior.AllowGet);
 }
        public ActionResult UploadFile(HttpPostedFileBase File)
        {
            string[] formats = new string[] { ".xls", ".xlsx", ".csv"};

            if (File != null && formats.Contains(Path.GetExtension(File.FileName)))
            {
                var headers = new CampaignModule().GetHeaders(File);
                ModelState.Clear();
                return View("FileHeaders", headers);
            }
            throw new ArgumentNullException("File corrupted");
        }
 public ActionResult Approval()
 {
     var campaigns = new CampaignModule().GetAllCampaigns().OrderByDescending(p => p.Id);
     return View(campaigns);
 }
 public ActionResult Schedule(int id, DateTime scheduledDate, DateTime scheduledTime)
 {
     scheduledDate = scheduledDate.Add(scheduledTime.Subtract(scheduledTime.Date));
     var response = new CampaignModule().ScheduleCampaign(id, scheduledDate);
     return Json(response, JsonRequestBehavior.AllowGet);
 }
 public ActionResult SendTestMsg(int id, string recepient)
 {
     var response = new CampaignModule().SendTestCampaign(id, recepient);
     return Json(response, JsonRequestBehavior.AllowGet);
 }
 public ActionResult Save()
 {
     var report = (CampaignReport)TempData["CampaignReport"];
     var campaignModule = new CampaignModule();
     int campaignId = campaignModule.SaveCampaign(report);
     campaignModule.UpdateCampaignFile(campaignId);
     return RedirectToAction("Index", new { messageId = (int)ViewMessage.CampaignSaved });
 }
 public ActionResult Reject(int id)
 {
     var response = new CampaignModule().RejectCampaign(id);
     return Json(response, JsonRequestBehavior.AllowGet);
 }
Example #10
0
 //
 // GET: /Campaign/
 public ActionResult Index(int messageId = 0)
 {
     SetCampaignMessage(messageId);
     var campaigns = new CampaignModule().GetAllCampaigns().OrderByDescending(p => p.Id);
     return View(campaigns);
 }
Example #11
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);
        }
Example #12
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);
        }