Example #1
0
        public List <JobVm> Search(string keywords, int langId = 1)
        {
            var lookup = keywords.ToLower().Split(' ');

            using (var db = new LMISEntities())
            {
                return(db.JobOffers
                       .AsNoTracking()
                       .Where(r => r.IsDeleted == null && r.JobStatus &&
                              r.IsApproved == (byte)Approval.Approved)
                       .Select(a => new
                {
                    Offer = a,
                    TitleDesc = SqlUdf.SubCodeName(a.JobTiltleID, langId),
                    TitleSearchable = SqlUdf.SubCodeSearchString(a.JobTiltleID, langId),
                    Details = a.JobOfferDetails
                })
                       .Where(r => lookup.Any(q => r.TitleSearchable.ToLower().Contains(q)))
                       .ToList()
                       .Select(a => new JobVm
                {
                    JobId = (long)a.Offer.JobOfferID,
                    Title = a.TitleDesc,
                    Description = (new GlobalString(a.Details.Select(d => new LocalString(d.LanguageID, d.JobDescription)).ToList())).Reduce(langId),
                    EmploymentType = a.Offer.EmploymentTypeID,
                    Country = a.Offer.CountryID,
                    City = a.Offer.CityID
                })
                       .ToList());
            }
        }
Example #2
0
        public List <TrainingVm> Search(string keywords, int langId = 1)
        {
            var lookup = keywords.ToLower().Split(' ');

            using (var db = new LMISEntities())
            {
                return(db.TrainingOffers
                       .AsNoTracking()
                       .Where(r => r.IsDeleted == null && r.trainingStatus &&
                              r.Is_Approved == (byte)Approval.Approved)
                       .Select(a => new
                {
                    Offer = a,
                    TitleDesc = SqlUdf.SubCodeName(a.CourseNameID, langId),
                    TitleSearchable = SqlUdf.SubCodeSearchString(a.CourseNameID, langId),
                    Details = a.TrainingOfferDetails,
                    OrgNames = a.OrganizationDetail.OrganizationDetails_Det
                               .Select(r => new
                    {
                        r.LanguageID,
                        r.OrganizationName
                    }).ToList()
                })
                       .Where(r => lookup.Any(q => r.TitleSearchable.ToLower().Contains(q)))
                       .ToList()
                       .Select(a => new TrainingVm
                {
                    Id = (long)a.Offer.TrainingOfferID,
                    Title = a.TitleDesc,
                    Description = (new GlobalString(a.Details.Select(d => new LocalString(d.LanguageID, d.CourseDescription)).ToList())).Reduce(langId),
                    PortalUserId = (long)a.Offer.PortalUsersID,
                    Country = a.Offer.CountryID,
                    City = a.Offer.CityID,
                    Extras = new Dictionary <string, object>
                    {
                        { "OrgName", new GlobalString(a.OrgNames.Select(d => new LocalString(d.LanguageID, d.OrganizationName)).ToList())
                          .ToLocalString((Language)langId, true).T }
                    }
                })
                       .ToList());
            }
        }