示例#1
0
        public ActionResult Index()
        {
            EmailSendVM       model      = new EmailSendVM();
            CandidatesService canService = new CandidatesService();

            model.Recievers = canService.GetAll();
            TryUpdateModel(model);

            if (!String.IsNullOrEmpty(model.Search))
            {
                switch (model.SearchType)
                {
                case SearchEnum.UsedTechnology:
                    EmailService.Recievers = model.Recievers.Where(c => c.UsedTechnologies
                                                                   .Any(t => t.Name.ToLower().Contains(model.Search.ToLower()))).ToList();
                    break;

                case SearchEnum.ProgrammingLanguage:
                    EmailService.Recievers = model.Recievers.Where(c => c.ProgrammingLanguages
                                                                   .Any(p => p.Name.ToLower().Contains(model.Search.ToLower()))).ToList();
                    break;

                case SearchEnum.Name:
                default:
                    EmailService.Recievers = model.Recievers.Where(c => c.FirstName.ToLower().Contains(model.Search.ToLower()) || c.LastName.ToLower().Contains(model.Search.ToLower())).ToList();
                    break;
                }
            }
            return(View(model));
        }
        public ActionResult Index()
        {
            EmailSendVM model = new EmailSendVM();
            CandidatesService canService = new CandidatesService();
            model.Recievers = canService.GetAll();
            TryUpdateModel(model);

            if (!String.IsNullOrEmpty(model.Search))
            {
                switch (model.SearchType)
                {
                    case SearchEnum.UsedTechnology:
                        EmailService.Recievers = model.Recievers.Where(c => c.UsedTechnologies
                                                            .Any(t => t.Name.ToLower().Contains(model.Search.ToLower()))).ToList();
                        break;
                    case SearchEnum.ProgrammingLanguage:
                        EmailService.Recievers = model.Recievers.Where(c => c.ProgrammingLanguages
                                                            .Any(p => p.Name.ToLower().Contains(model.Search.ToLower()))).ToList();
                        break;
                    case SearchEnum.Name:
                    default:
                        EmailService.Recievers = model.Recievers.Where(c => c.FirstName.ToLower().Contains(model.Search.ToLower()) || c.LastName.ToLower().Contains(model.Search.ToLower())).ToList();
                        break;
                }
            }
            return View(model);
        }
        public ActionResult List()
        {
            CandidatesService candidatesService = new CandidatesService();
            CandidateListVM   model             = new CandidateListVM();

            model.Candidates = candidatesService.GetAll();
            TryUpdateModel(model);

            // search
            if (!String.IsNullOrEmpty(model.Search))
            {
                switch (model.SearchType)
                {
                case SearchEnum.UsedTechnology:
                    model.Candidates = model.Candidates.Where(c => c.UsedTechnologies
                                                              .Any(t => t.Name.ToLower().Contains(model.Search.ToLower()))).ToList();
                    break;

                case SearchEnum.ProgrammingLanguage:
                    model.Candidates = model.Candidates.Where(c => c.ProgrammingLanguages
                                                              .Any(p => p.Name.ToLower().Contains(model.Search.ToLower()))).ToList();
                    break;

                case SearchEnum.Name:
                default:
                    model.Candidates = model.Candidates.Where(c => c.FirstName.ToLower().Contains(model.Search.ToLower()) || c.LastName.ToLower().Contains(model.Search.ToLower())).ToList();
                    break;
                }
            }

            // sort
            switch (model.SortOrder)
            {
            case "lname_asc":
                model.Candidates = model.Candidates.OrderBy(c => c.LastName).ToList();
                break;

            case "lname_desc":
                model.Candidates = model.Candidates.OrderByDescending(c => c.LastName).ToList();
                break;

            case "fname_desc":
                model.Candidates = model.Candidates.OrderByDescending(c => c.FirstName).ToList();
                break;

            case "fname_asc":
            default:
                model.Candidates = model.Candidates.OrderBy(c => c.FirstName).ToList();
                break;
            }
            return(View(model));
        }
        public ActionResult List()
        {
            CandidatesService candidatesService = new CandidatesService();
            CandidateListVM model = new CandidateListVM();
            model.Candidates = candidatesService.GetAll();
            TryUpdateModel(model);

            // search
            if (!String.IsNullOrEmpty(model.Search))
            {
                switch (model.SearchType)
                {
                    case SearchEnum.UsedTechnology:
                        model.Candidates = model.Candidates.Where(c => c.UsedTechnologies
                                                            .Any(t => t.Name.ToLower().Contains(model.Search.ToLower()))).ToList();
                        break;
                    case SearchEnum.ProgrammingLanguage:
                        model.Candidates = model.Candidates.Where(c => c.ProgrammingLanguages
                                                            .Any(p => p.Name.ToLower().Contains(model.Search.ToLower()))).ToList();
                        break;
                    case SearchEnum.Name:
                    default:
                        model.Candidates = model.Candidates.Where(c => c.FirstName.ToLower().Contains(model.Search.ToLower()) || c.LastName.ToLower().Contains(model.Search.ToLower())).ToList();
                        break;
                }
            }

            // sort
            switch (model.SortOrder)
            {
                case "lname_asc":
                    model.Candidates = model.Candidates.OrderBy(c => c.LastName).ToList();
                    break;
                case "lname_desc":
                    model.Candidates = model.Candidates.OrderByDescending(c => c.LastName).ToList();
                    break;
                case "fname_desc":
                    model.Candidates = model.Candidates.OrderByDescending(c => c.FirstName).ToList();
                    break;
                case "fname_asc":
                default:
                    model.Candidates = model.Candidates.OrderBy(c => c.FirstName).ToList();
                    break;
            }
            return View(model);
        }