Exemplo n.º 1
0
        public ActionResult Create()
        {
            var lead = new Lead();

            var spaceContacts = lead.GetSpaceContacts();
            var spaceUsers = lead.GetUsers();
            var statuses = lead.GetAllStatuses();
            var leadContactsItems = spaceContacts.Select(x => new SelectListItem { Text = x.Name, Value = x.ProfileId.ToString() });
            var leadOwnerItems = spaceUsers.Select(x => new SelectListItem { Text = x.Name, Value = x.ProfileId.ToString() });
            var statusOptions = statuses.Select(x => new SelectListItem { Text = x.Value.ToString(), Value = x.Key.ToString() });

            var model = new LeadViewModel();
            model.LeadContactsOptions = leadContactsItems;
            model.LeadOwnersOptions = leadOwnerItems;
            model.StatusOptions = statusOptions;

            return View(model);
        }
Exemplo n.º 2
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.º 3
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.º 4
0
        public ActionResult Create()
        {
            var lead = new Lead();
            var model = new LeadViewModel();

            try
            {
                List<Contact> spaceContacts = lead.GetSpaceContacts();
                List<Contact> spaceUsers = lead.GetUsers();
                Dictionary<int, string> statuses = lead.GetAllStatuses();

                model.LeadContactsOptions = new SelectList(spaceContacts, "ProfileId", "Name");
                model.LeadOwnersOptions = new SelectList(spaceUsers, "ProfileId", "Name");
                model.StatusOptions = new SelectList(statuses, "Key", "Value");
            }
            catch (PodioException ex)
            {
                ViewBag.error = ex.Error.ErrorDescription;
            }

            return View(model);
        }
Exemplo n.º 5
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.º 6
0
        public async Task<ActionResult> Edit(int id)
        {
            ViewBag.message = TempData["message"];
            ViewBag.error = TempData["error"];

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

            try
            {
                var getLeadToEditTask = lead.GetLead(id);

                var getSpaceContactsTask = lead.GetSpaceContacts();
                var getSpaceUsersTask = lead.GetUsers();
                var getStatusesTask = lead.GetAllStatuses();

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

                var leadToEdit = getLeadToEditTask.Result;

                IEnumerable<int> selectedLeadContacts = leadToEdit.Contacts != null ? leadToEdit.Contacts.Select(x => x.Key) : null;
                IEnumerable<int> selectedLeadOwners = leadToEdit.LeadOwners != null ? leadToEdit.LeadOwners.Select(x => x.Key) : null;
                int selectedStatus = leadToEdit.Status.Item1;

                model.PodioItemID = leadToEdit.PodioItemID;
                model.Company = leadToEdit.Company;
                model.ExpectedValue = leadToEdit.ExpectedValue;
                model.ProbabilityOfSale = leadToEdit.ProbabilityOfSale;
                model.NextFollowUp = leadToEdit.NextFollowUp;
                model.StreetAddress = leadToEdit.StreetAddress;
                model.City = leadToEdit.City;
                model.Zip = leadToEdit.Zip;
                model.State = leadToEdit.State;
                model.Country = leadToEdit.Country;

                model.LeadContactsOptions = new SelectList(getSpaceContactsTask.Result, "ProfileId", "Name");
                model.LeadOwnersOptions = new SelectList(getSpaceUsersTask.Result, "ProfileId", "Name");
                model.StatusOptions = new SelectList(getStatusesTask.Result, "Key", "Value");

            }
            catch (PodioException ex)
            {
                ViewBag.error = ex.Error.ErrorDescription;
            }
            
            return View(model);
        }
Exemplo n.º 7
0
        public async Task<ActionResult> Create()
        {
            var lead = new Lead();
            var model = new LeadViewModel();

            try
            {

                var getSpaceContactsTask = lead.GetSpaceContacts();
                var getSpaceUsersTask = lead.GetUsers();
                var getStatusesTask = lead.GetAllStatuses();

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

                model.LeadContactsOptions = new SelectList(getSpaceContactsTask.Result, "ProfileId", "Name");
                model.LeadOwnersOptions = new SelectList(getSpaceUsersTask.Result, "ProfileId", "Name");
                model.StatusOptions = new SelectList(getStatusesTask.Result, "Key", "Value");
            }
            catch (PodioException ex)
            {
                ViewBag.error = ex.Error.ErrorDescription;
            }

            return View(model);
        }
Exemplo n.º 8
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.º 9
0
        public ActionResult Edit(int id)
        {
            ViewBag.message = TempData["message"];
            ViewBag.error = TempData["error"];

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

            try
            {
                Lead leadToEdit = lead.GetLead(id);

                List<Contact> spaceContacts = lead.GetSpaceContacts();
                List<Contact> spaceUsers = lead.GetUsers();
                Dictionary<int,string> statuses = lead.GetAllStatuses();

                IEnumerable<int> selectedLeadContacts = leadToEdit.Contacts != null ? leadToEdit.Contacts.Select(x => x.Key) : null;
                IEnumerable<int> selectedLeadOwners = leadToEdit.LeadOwners != null ? leadToEdit.LeadOwners.Select(x => x.Key) : null;
                int selectedStatus = leadToEdit.Status.Item1;

                model.PodioItemID = leadToEdit.PodioItemID;
                model.Company = leadToEdit.Company;
                model.ExpectedValue = leadToEdit.ExpectedValue;
                model.ProbabilityOfSale = leadToEdit.ProbabilityOfSale;
                model.NextFollowUp = leadToEdit.NextFollowUp;
                model.StreetAddress = leadToEdit.StreetAddress;
                model.City = leadToEdit.City;
                model.Zip = leadToEdit.Zip;
                model.State = leadToEdit.State;
                model.Country = leadToEdit.Country;

                model.LeadContactsOptions = new MultiSelectList(spaceContacts, "ProfileId", "Name", selectedLeadContacts);
                model.LeadOwnersOptions = new MultiSelectList(spaceUsers, "ProfileId", "Name", selectedLeadOwners);
                model.StatusOptions = new SelectList(statuses, "Key", "Value", selectedStatus);

            }
            catch (PodioException ex)
            {
                ViewBag.error = ex.Error.ErrorDescription;
            }

            return View(model);
        }
Exemplo n.º 10
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);
        }