Exemplo n.º 1
0
        // GET: CMS/Trainer
        //[Authorize(Roles = "Employee,Admin")]
        public ActionResult Index(int?page, int PageSize = 10, string Qualification = null, string Organization = null, string Name = null, string Domain = null, string Zone = null, string LanguageKnown = null, string City = null)
        {
            string        UserId      = User.Identity.GetUserId();
            UserViewModel userDetails = generic.GetUserDetail(UserId);

            ViewData["UserProfile"] = userDetails;
            if (userDetails.Role == "Employee")
            {
                var empdetails = ems.GetEmployeeBasicDetails(UserId).FirstOrDefault();
                ViewData["EmpDetails"]  = empdetails;
                ViewData["CompanyLogo"] = cms.GetCompanyLogo(userDetails.SubscriberId).FirstOrDefault();
            }
            PopulatePaging(PageSize);
            ViewBag.Paging = PageSize;
            ViewBag.Page   = page;
            int pageSize   = PageSize;
            int pageNumber = (page ?? 1);

            PopulateDomain();
            PopulateLanguageKnown();
            PopulateQualification();
            PopulateOrganization();
            PopulateZone();
            var InstructorLead = cms.GetInstructerLead(userDetails.SubscriberId);

            if (!string.IsNullOrEmpty(Qualification))
            {
                ViewBag.Qualifications = Qualification;
                var values = InstructorLead.Select(x => "," + x + ",");
                var query  = from c in InstructorLead
                             where values.Any(i => ("," + c.Qualification + ",").Contains(Qualification))
                             select c;
                //InstructorLead = InstructorLead.Where(c => c.Qualification == Qualification).ToList();

                //var query = from c in InstructorLead
                //           where c.Qualification.Contains(Qualification)

                //            select c;
                InstructorLead = query.ToList();
            }
            if (!string.IsNullOrEmpty(Organization))
            {
                ViewBag.Organizations = Organization;
                var values = InstructorLead.Select(x => "," + x + ",");
                var query  = from c in InstructorLead
                             where values.Any(i => ("," + c.Organization + ",").Contains(Organization))
                             select c;
                //InstructorLead = InstructorLead.Where(c => c.Organization == Organization).ToList();
                //var query = from c in InstructorLead
                //            where  (c.Organization.Split(',').Contains(Organization) || c.Organization == Organization)
                //            select c;
                InstructorLead = query.ToList();
            }
            if (!string.IsNullOrEmpty(LanguageKnown))
            {
                ViewBag.LanguageKnowns = LanguageKnown;
                var values = InstructorLead.Select(x => "," + x + ",");
                var query  = from c in InstructorLead
                             where values.Any(i => ("," + c.LanguageKnown + ",").Contains(LanguageKnown))
                             select c;
                //InstructorLead = InstructorLead.Where(c => c.Organization == Organization).ToList();
                //var query = from c in InstructorLead
                //            where  (c.Organization.Split(',').Contains(Organization) || c.Organization == Organization)
                //            select c;
                InstructorLead = query.ToList();
            }
            if (!string.IsNullOrEmpty(Name))
            {
                ViewBag.Name   = Name;
                InstructorLead = (from u in InstructorLead where u.IName.Contains(Name.ToUpper()) select u).ToList();
            }
            if (!string.IsNullOrEmpty(City))
            {
                ViewBag.Cites  = City;
                InstructorLead = (from u in InstructorLead where (u.City ?? "").Contains(City.ToUpper()) select u).ToList();
            }
            if (!string.IsNullOrEmpty(Zone))
            {
                ViewBag.Zones  = Zone;
                InstructorLead = InstructorLead.Where(c => c.Zone == Zone).ToList();
            }
            if (!string.IsNullOrEmpty(Domain))
            {
                ViewBag.Domains = Domain;
                // InstructorLead = InstructorLead.Where(c => c.DomainExpertize == Domain).ToList();
                var values = InstructorLead.Select(x => "," + x + ",");
                var query  = from c in InstructorLead
                             where values.Any(i => ("," + c.DomainExpertize + ",").Contains(Domain))
                             select c;
                //List<InstructorLeadProfileView> inmt= new List<InstructorLeadProfileView>();
                ////InstructorLead = (from u in InstructorLead where u.DomainExpertize.Contains(Domain) select u).ToList();
                //foreach (var item in InstructorLead)
                //{
                //    var InstructorLeadss = (from u in InstructorLead where item.DomainExpertize.StartsWith(Domain) select u);
                //    if(InstructorLeadss != null)
                //    {
                //        inmt.Add(item);
                //    }
                //}
                //InstructorLead = inmt;
                InstructorLead = query.ToList();
            }
            ViewBag.EmCount = InstructorLead.Count();
            return(View(InstructorLead.ToPagedList(pageNumber, pageSize)));
        }