public ActionResult Index(string id, int?page, string order) { if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Index", new { id = "Prospecting" })); } 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 SaleFilterOptions() { 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 SaleViewModel(); model.SaleType = (SaleType)Enum.Parse(typeof(CrumbCRM.SaleType), id, true); model.Sales = _saleService.GetAll(options).Where(x => (x.Status.HasValue && x.Status.Value == model.SaleType)).ToList(); model.TotalProspecting = _saleService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == SaleType.Prospecting).Count(); model.TotalQualified = _saleService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == SaleType.Qualified).Count(); model.TotalUnqualified = _saleService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == SaleType.Unqualified).Count(); model.TotalQuote = _saleService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == SaleType.Quote).Count(); model.TotalClosure = _saleService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == SaleType.Closure).Count(); model.TotalWon = _saleService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == SaleType.Won).Count(); model.TotalLost = _saleService.GetAll(options).Where(x => x.Status.HasValue && x.Status.Value == SaleType.Lost).Count(); ViewData.SelectListEnumViewData <NoteActionType>("ActionType", true); int pageNo = page ?? 1; int total = _saleService.Total(options); int totalPages = System.Convert.ToInt32(Math.Ceiling((decimal)total / (decimal)10)); if (totalPages > pageNo) { ViewBag.Next = (pageNo + 1); } return(View("Index", model)); }
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 SaleFilterOptions() { 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 = _saleService.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 saleType = (SaleType)Enum.Parse(typeof(CrumbCRM.SaleType), id, true); var model = _saleService.GetAll(options, new PagingSettings() { PageCount = 10, PageIndex = pageNo }).Where(x => (x.Status.HasValue && x.Status.Value == saleType)).ToList(); return(PartialView("Controls/_RenderItems", model)); }