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);
        }
        private PersonProfileVM getCounts(List <string> columns, object record)
        {
            var matchedProps = record.GetType().GetProperties().Where(r => columns.Contains(r.Name) && !r.PropertyType.FullName.Contains("Model.Domain")).ToList();

            PersonProfileVM counts = new PersonProfileVM()
            {
                NofVisible = matchedProps.Count(),
                NofData    = matchedProps.Count(r => r.GetValue(record) != null)
            };

            return(counts);
        }