Exemple #1
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));
        }