Beispiel #1
0
        public ActionResult Index(string id, int? page, string order)
        {
            if (string.IsNullOrEmpty(id))
                return RedirectToAction("Index", new { id = "New" });

            string message = (string)TempData["StatusMessage"];
            ViewBag.message = message;

            var campaigns = (List<Campaign>)TempData["SelectedCampaigns"];
            TempData.Keep("SelectedCampaigns");

            var tags = (List<Tag>)TempData["SelectedTags"];
            TempData.Keep("SelectedCampaigns");

            var options = new LeadFilterOptions()
            {
                Order = string.IsNullOrEmpty(order) ? string.Empty : order.ToLower(),
                Campaigns = campaigns != null ? campaigns.ToList<object>() : null,
                Tags = tags != null ? tags.ToList<object>() : null
            };
            ViewBag.order = order;

            var model = new LeadViewModel();
            model.LeadType = (LeadType)Enum.Parse(typeof(CrumbCRM.LeadType), id, true);
            model.TotalNew = _leadService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == LeadType.New).Count();
            model.TotalEmailed = _leadService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == LeadType.Emailed).Count();
            model.TotalNoAnswer = _leadService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == LeadType.NoAnswer).Count();
            model.TotalNotInterested = _leadService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == LeadType.NotInterested).Count();
            model.TotalCallback = _leadService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == LeadType.Callback).Count();
            model.TotalDoNotContact = _leadService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == LeadType.DoNotContact).Count();

            ViewData.SelectListEnumViewData<NoteActionType>("ActionType", true);

            int pageNo = page ?? 1;
            int total = _leadService.Total(options);
            int totalPages = System.Convert.ToInt32(Math.Ceiling((decimal)total / (decimal)10));            

            if (totalPages > pageNo)
                ViewBag.Next = (pageNo + 1);

            return View("Index", model);
        }
Beispiel #2
0
        public ActionResult RenderItems(string id, int? page, string order)
        {
            var campaigns = (List<Campaign>)TempData["SelectedCampaigns"];
            TempData.Keep("SelectedCampaigns");

            var tags = (List<Tag>)TempData["SelectedTags"];
            TempData.Keep("SelectedCampaigns");

            var options = new LeadFilterOptions()
            {
                Order = string.IsNullOrEmpty(order) ? string.Empty : order.ToLower(),
                Campaigns = campaigns != null ? campaigns.ToList<object>() : null,
                Tags = tags != null ? tags.ToList<object>() : null
            };
            ViewBag.order = order;

            int pageNo = page ?? 1;
            int total = _leadService.Total(options);
            int totalPages = System.Convert.ToInt32(Math.Ceiling((decimal)total / (decimal)10)); 

            //default lead type
            if (string.IsNullOrEmpty(id))
                id = "New";

            if (totalPages > pageNo)
                ViewBag.Next = (pageNo + 1);

            var leadType = (LeadType)Enum.Parse(typeof(CrumbCRM.LeadType), id, true);
            var model = _leadService.GetAll(options, new PagingSettings() { PageCount = 10, PageIndex = pageNo }).Where(x => (string.IsNullOrEmpty(id) || (x.Status.HasValue && x.Status.Value == leadType))).ToList();

            return PartialView("Controls/_RenderItems", model);
        }