Пример #1
0
        public async Task <ActionResult> Filter(LeadListingViewModel leadListingModel)
        {
            var lead  = new Lead();
            var model = new LeadListingViewModel();

            try
            {
                DateTime?nextFollowUpFromDate = leadListingModel.NextFollowUpFrom;
                DateTime?nextFollowUpToDate   = leadListingModel.NextFollowUpTo;
                decimal? expectedValueFrom    = leadListingModel.ExpectedValueFrom;
                decimal? expectedValueTo      = leadListingModel.ExpectedValueTo;
                int?     status    = leadListingModel.Status;
                int?     leadOwner = leadListingModel.LeadOwner;

                IEnumerable <Contact> spaceUsers = await lead.GetUsers();

                Dictionary <int, string> statuses = await lead.GetAllStatuses();

                IEnumerable <Lead> leads = await lead.GetAllLeads(nextFollowUpFromDate, nextFollowUpToDate, expectedValueFrom, expectedValueTo, status, leadOwner);

                model.LeadOwnersOptions = new SelectList(spaceUsers, "ProfileId", "Name", leadOwner);
                model.StatusOptions     = new SelectList(statuses, "Key", "Value", status);

                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,
                        PodioItemID   = x.PodioItemID
                    });
                }
            }
            catch (PodioException ex)
            {
                ViewBag.error = ex.Error.ErrorDescription;
            }

            return(View("Index", model));
        }
Пример #2
0
        public async Task <ActionResult> Index()
        {
            ViewBag.message = TempData["message"];
            ViewBag.error   = TempData["error"];

            var model = new LeadListingViewModel();
            var lead  = new Lead();

            try
            {
                var getSpaceUsersTask = lead.GetUsers();
                var getStatusesTask   = lead.GetAllStatuses();
                var getLeadsTask      = lead.GetAllLeads();

                await System.Threading.Tasks.Task.WhenAll(getSpaceUsersTask, getStatusesTask, getLeadsTask);

                model.LeadOwnersOptions = new SelectList(getSpaceUsersTask.Result, "ProfileId", "Name");
                model.StatusOptions     = new SelectList(getStatusesTask.Result, "Key", "Value");
                var leads = getLeadsTask.Result;

                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,
                        PodioItemID   = x.PodioItemID
                    }).ToList();
                }
            }
            catch (PodioException ex)
            {
                ViewBag.error = ex.Error.ErrorDescription;
            }

            return(View(model));
        }