public double GetProfileCount(int empId, int companyId, byte version)
        {
            // NeedToReview
            List <PersonProfileVM> list       = new List <PersonProfileVM>();
            List <string>          IgnoreCols = new List <string>()
            {
                "TaxFamlyCnt", "BnftFamlyCnt"
            };

            //People
            List <string> columns      = context.FormsColumns.Where(f => f.Section.FieldSet.PageId == HrContext.GetPageId(companyId, "People", version) && f.isVisible && f.InputType != "button").Select(f => f.ColumnName).ToList();
            Person        peopleRecord = context.People.Where(e => e.Id == empId).FirstOrDefault();

            PersonProfileVM countObj = peopleRecord != null?getCounts(columns, peopleRecord) : getCounts(columns, new Person());

            list.Add(countObj);

            //HasImage
            list.Add(new PersonProfileVM {
                NofVisible = 1, NofData = peopleRecord.HasImage ? 1 : 0
            });

            //Additinal Info
            var flex = (from fc in context.FlexColumns
                        where fc.PageId == HrContext.GetPageId(companyId, "People", version) && fc.isVisible
                        join fd in context.FlexData on new { fc.PageId, fc.ColumnName } equals new { fd.PageId, fd.ColumnName } into g
                        from fd in g.Where(b => b.SourceId == empId).DefaultIfEmpty()
                        select new { fd.Value, fc.ColumnName }).ToList();

            list.Add(new PersonProfileVM {
                NofVisible = flex.Count(), NofData = flex.Count(l => !String.IsNullOrEmpty(l.Value))
            });

            //Employments
            columns = context.FormsColumns.Where(f => f.Section.FieldSet.PageId == HrContext.GetPageId(companyId, "Emp", version) && f.isVisible && f.InputType != "button" && f.ColumnName != "Profession").Select(f => f.ColumnName).ToList();
            Employement empRecord = context.Employements.Where(e => e.EmpId == empId && e.Status == 1).FirstOrDefault() ?? new Employement();

            list.Add(getCounts(columns, empRecord));

            //Assignments
            IgnoreCols = new List <string>()
            {
                "ManagerId", "EmpTasks", "IsDepManager", "PositionId", "IBranches", "IPayrollGrades", "IPositions", "ICompanyStuctures", "IEmployments", "IJobs", "IPayrolls", "IPeopleGroups"
            };

            columns = context.FormsColumns.Where(f => f.Section.FieldSet.PageId == HrContext.GetPageId(companyId, "AssignmentsForm", version) && f.isVisible && !IgnoreCols.Contains(f.ColumnName) && f.InputType != "button").Select(f => f.ColumnName).ToList();
            var        today        = DateTime.Today.Date;
            Assignment assignRecord = context.Assignments.Where(a => a.EmpId == empId && a.AssignDate <= today && a.EndDate >= today).FirstOrDefault() ?? new Assignment();

            list.Add(getCounts(columns, assignRecord));

            //--Calculations
            double value = Math.Round(list.Sum(l => l.NofData) / list.Sum(l => l.NofVisible), 2) * 100;

            return(value);
        }
        public IEnumerable <LookupCodesViewModel> GetFlexLookUpCodesLists(int companyId, string objectName, byte version, string culture)
        {
            var result = from flex in context.FlexColumns
                         where flex.PageId == HrContext.GetPageId(companyId, objectName, version)
                         join code in context.LookUpCodes on flex.CodeName equals code.CodeName
                         join t in context.LookUpTitles on new { code.CodeName, code.CodeId } equals new { t.CodeName, t.CodeId } into g
            from t in g.Where(a => a.Culture == culture).DefaultIfEmpty()
            select new LookupCodesViewModel
            {
                Id       = code.Id,
                CodeName = code.CodeName,
                CodeId   = code.CodeId,
                Name     = (t.Title != null ? t.Title : code.Name)
            };

            return(result.Distinct());
        }