Пример #1
0
        public Web.ViewModel.AppointmentSheetViewModel GetAppointmentSheet(int leadId)
        {
            Web.ViewModel.AppointmentSheetViewModel appointmentModel = new Web.ViewModel.AppointmentSheetViewModel();
            var results = _AppointmentSheetRepository.AppointmentSheets.Single(row => row.ParentLeadId == leadId);

            appointmentModel.appointmentSheet = results;
            var aaUsersResult = _UserRepository.GetAllUsersByPermission(Data.Constants.Permissions.LEAD_ASSIGNABLE);

            appointmentModel.AAUsersDropdown = aaUsersResult.Select(row => new SelectListItem()
            {
                Text  = row.LastName + " , " + row.LastName,
                Value = row.UserId.ToString()
            });
            return(appointmentModel);
        }
        //
        // GET: /ImportLead/

        public ActionResult Index()
        {
            Lead lead = new Lead();

            Web.ViewModel.AppointmentSheetViewModel asvm = new Web.ViewModel.AppointmentSheetViewModel();

            IList <AppointmentSheet> apmtq = new List <AppointmentSheet>();
            var username = HttpContext.User.Identity.Name;

            var user = _UserRepository.GetUserByUsername(username);

            asvm.user = user;
            //Get all unassigned appointments
            var appointments = _UsageRepository.AppointmentQueue(0, false);


            foreach (var appointmentq in appointments)
            {
                if (appointmentq.Score == "Good")
                {
                    //do nothing
                }
                else if (appointmentq.Score == "Bad")
                {
                    //do nothing
                }
                else
                {
                    // To get the assigned username
                    Lead parentLead = _LeadRepos.LeadByLeadID(appointmentq.ParentLeadId);
                    if (lead.LeadId != parentLead.LeadId)
                    {
                        lead = parentLead;
                        User newUser = _UserRepository.GetUserById(parentLead.AssignedAAUserId);
                        if (newUser == null)
                        {
                            // Should not this condition
                            appointmentq.AssignedUser.UserName = "******";
                            appointmentq.companyname           = parentLead.CompanyName;
                        }
                        else
                        {
                            appointmentq.AssignedUser = newUser;
                            appointmentq.companyname  = parentLead.CompanyName;
                        }
                        apmtq.Add(appointmentq);
                    }
                }
            }
            asvm.AppointmentQueue = apmtq;

            // Drop down showing list of SA's
            var saUsersResult = _UserRepository.GetAllUsersByRole(3);

            asvm.AAUsersDropdown = saUsersResult.Select(row => new SelectListItem()
            {
                Text  = row.LastName + "," + row.FirstName,
                Value = row.UserId.ToString()
            });
            return(View(asvm));
        }