public static IEnumerable <SelectListItem> GetList(string name)
        {
            List <SelectListItem> skillsets = new List <SelectListItem>();

            try
            {
                SelectListItem skillset = null;
                using (RPEntities db = new RPEntities())
                {
                    var skillsetsFromDB = db.SkillSets.Where(u => u.Name.Contains(name)).ToList();
                    {
                        foreach (SkillSet thisSkillSet in skillsetsFromDB)
                        {
                            skillset          = new SelectListItem();
                            skillset.Value    = thisSkillSet.SkillSetId.ToString();
                            skillset.Text     = thisSkillSet.Name;
                            skillset.Selected = false;
                            skillsets.Add(skillset);
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                Logger.LogException(exp);
            }
            return(skillsets);
        }
        public static Resource Initialize(int resourceId)
        {
            Resource resource = null;

            using (RPEntities db = new RPEntities())
            {
                resource = db.Resources.Include(r => r.ResourceDocuments.Select(d => d.DocumentType)).Include(t => t.ResourceType).Include(v => v.Vendor).Include(v => v.Vendor1)
                           .Include(c => c.Client).Include(u => u.AspNetUser).Include(s => s.ResourceSkillSets.Select(n => n.SkillSet)).Where(r => r.ResourceId == resourceId).FirstOrDefault();
            }
            return(resource);
        }
 public static IEnumerable <InterviewViewModel> GetInterviews(int resourceId)
 {
     using (RPEntities db = new RPEntities())
     {
         var interviews = db.Interviews.Include(i => i.InterviewDetails).Where(i => i.ResourceId == resourceId).Select(x => new InterviewViewModel
         {
             InterviewId     = x.InterviewId,
             InterviewDate   = x.StartTime,
             InterviewType   = x.InterviewType,
             InterviewStatus = x.Status,
             InterviewerName = x.Interviewer.AspNetUser.FirstName + " " + x.Interviewer.AspNetUser.LastName,
             InterviewerId   = x.InterviewerId.Value,
             AverageRating   = x.InterviewDetails.Where(d => d.InterviewId == x.InterviewId).Select(r => r.Rating).Average()
         });
         return(interviews.ToList());
     }
 }
 public static IEnumerable <SuggestedResourceModel> GetResources(int requirementId)
 {
     using (RPEntities db = new RPEntities())
     {
         var requirementSkillSetIds = db.RequirementSkillSets.Where(r => r.RequirementId == requirementId).Select(s => s.SkillSetId).ToList();
         var resources = db.Resources.Include(r => r.AspNetUser).Where(r => r.ResourceSkillSets.Any(s => requirementSkillSetIds.Contains(s.SkillSetId)))
                         .GroupBy(x => new { x.ResourceId, x.AspNetUser.FirstName, x.AspNetUser.LastName, x.Availability, x.ProjectEndDate })
                         .Select(g => new SuggestedResourceModel
         {
             ResourceId     = g.Key.ResourceId,
             Name           = g.Key.FirstName + " " + g.Key.LastName,
             Availability   = g.Key.Availability,
             ProjectEndDate = g.Key.ProjectEndDate
         });
         return(resources.ToList());
     }
 }
 public static IEnumerable <RequirementDisplayModel> GetRequirements(int resourceId)
 {
     using (RPEntities db = new RPEntities())
     {
         var resourceSkillSetIds = db.ResourceSkillSets.Where(r => r.ResourceId == resourceId).Select(s => s.SkillSetId).ToList();
         var requirements        = db.Requirements.Include(r => r.Client).Where(r => r.RequirementSkillSets.Any(s => resourceSkillSetIds.Contains(s.SkillSetId)) && r.Status == 1)
                                   .GroupBy(x => new { x.JobNumber, x.JobTitle, x.Client.Name, x.Description })
                                   .Select(g => new RequirementDisplayModel
         {
             Client        = g.Key.Name,
             JobNumber     = g.Key.JobNumber,
             JobTitle      = g.Key.JobTitle,
             Description   = g.Key.Description,
             RequirementId = g.Min(r => r.RequirementId)
         });
         return(requirements.ToList());
     }
 }
        public static IEnumerable <SuggestedResourceModel> GetList(string name)
        {
            List <SuggestedResourceModel> resources = null;

            try
            {
                using (RPEntities db = new RPEntities())
                {
                    resources = db.Resources.Where(u => u.AspNetUser.FirstName.Contains(name) || u.AspNetUser.LastName.Contains(name))
                                .Select(g => new SuggestedResourceModel
                    {
                        ResourceId     = g.ResourceId,
                        Name           = g.AspNetUser.FirstName + " " + g.AspNetUser.LastName,
                        Availability   = g.Availability,
                        ProjectEndDate = g.ProjectEndDate
                    }).ToList();
                }
            }
            catch (Exception exp)
            {
                Logger.LogException(exp);
            }
            return(resources);
        }