Ejemplo n.º 1
0
        public ActionResult Filter(FormCollection formCollection)
        {
            var nextFollowUpFromDate = !string.IsNullOrEmpty(formCollection["inputFromDate"]) ? DateTime.Parse(formCollection["inputFromDate"]) : (DateTime?)null;
            var nextFollowUpToDate =  !string.IsNullOrEmpty(formCollection["inputToDate"]) ? DateTime.Parse(formCollection["inputToDate"]) : (DateTime?)null;
            var expectedValueFrom = !string.IsNullOrEmpty(formCollection["inputExpectedValueFrom"]) ? int.Parse(formCollection["inputExpectedValueFrom"]) : (int?)null;
            var expectedValueTo = !string.IsNullOrEmpty(formCollection["inputExpectedValueTo"]) ? int.Parse(formCollection["inputExpectedValueTo"]) : (int?)null;
            var status = !string.IsNullOrEmpty(formCollection["ddlStatus"]) && formCollection["ddlStatus"] != "-1" ? int.Parse(formCollection["ddlStatus"]) : (int?)null;
            var leadOwner = !string.IsNullOrEmpty(formCollection["ddlLeadOwner"]) && formCollection["ddlLeadOwner"] != "-1" ? int.Parse(formCollection["ddlLeadOwner"]) : (int?)null;

            var lead = new Lead();
            var spaceUsers = lead.GetUsers();
            var statuses = lead.GetAllStatuses();
            var leads = lead.GetAllLeads(nextFollowUpFromDate, nextFollowUpToDate, expectedValueFrom, expectedValueTo, status, leadOwner);

            var model = new LeadListingViewModel();
            LeadViewModelOptions leadModelOption = new LeadViewModelOptions();
            if (spaceUsers.Any())
                leadModelOption.LeadOwnersOptions = spaceUsers.Select(x => new SelectListItem { Text = x.Name, Value = x.ProfileId.ToString() });

            if (statuses.Any())
                leadModelOption.StatusOptions = statuses.Select(x => new SelectListItem { Text = x.Value.ToString(), Value = x.Key.ToString() });

            if (leads.Any())
                model.Leads = leads.Select(x =>
                    new LeadView
                    {
                        Company = x.Company,
                        LeadOwners = x.LeadOwners,
                        ExpectedValue = x.ExpectedValue,
                        Status = x.Status,
                        NextFollowUp = x.NextFollowUp})
                        .ToList();

            model.LeadViewModelOptions = leadModelOption;
            return View("Index", model);
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            var lead = new Lead();
            var spaceUsers = lead.GetUsers();
            var statuses = lead.GetAllStatuses();
            var leads = lead.GetAllLeads();

            var model = new LeadListingViewModel();
            LeadViewModelOptions leadModelOption = new LeadViewModelOptions();
            if (spaceUsers.Any())
                leadModelOption.LeadOwnersOptions = spaceUsers.Select(x => new SelectListItem { Text = x.Name, Value = x.ProfileId.ToString() });

            if (statuses.Any())
                leadModelOption.StatusOptions = statuses.Select(x => new SelectListItem { Text = x.Value.ToString(), Value = x.Key.ToString() });

            if (leads.Any())
                model.Leads = leads.Select(x =>
                    new LeadView { Company = x.Company,
                        LeadOwners = x.LeadOwners,
                        ExpectedValue = x.ExpectedValue,
                        Status = x.Status,
                        NextFollowUp = x.NextFollowUp })
                        .ToList();

            model.LeadViewModelOptions = leadModelOption;
            return View(model);
        }