Exemplo n.º 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);
        }
Exemplo n.º 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);        
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public ActionResult Index()
        {
            ViewBag.message = TempData["message"];
            ViewBag.error = TempData["error"];

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

            try
            {
                List<Contact> spaceUsers = lead.GetUsers();
                Dictionary<int,string> statuses = lead.GetAllStatuses();
                IEnumerable<Lead> leads = lead.GetAllLeads();

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

                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);
        }