Beispiel #1
0
 public static IEnumerable<Attrib> GetAttributes(this DAL<MainDbContext> dal, Checklist checklist)
 {
     return dal.DbContext
         .Attribs
         .Where(x => checklist.AttrbuteValues.Any(y => y.AttribId == x.Id))
         .ToList();
 }
Beispiel #2
0
        public static double GetFillingPercentage(this DAL<MainDbContext> dal, Checklist checklist)
        {
            var join = from av in checklist.AttrbuteValues
                        join a in dal.DbContext.Attribs on av.AttribId equals a.Id
                        select new {
                            Weight = a.Weight,
                            Value = av.Value != null
                        };

            return join.Sum(x => x.Value ? x.Weight : 0) * 100 / join.Sum(x => x.Weight);
        }
Beispiel #3
0
        public bool Compare(Checklist checklist, string value)
        {
            if (string.IsNullOrWhiteSpace(value))
                return true;
            var queryStr = value.Trim();
            var fullStr = string.Empty;
            foreach (var i in checklist.AttrbuteValues)
            {
                if (i.Value == null)
                    continue;
                var strValue = i.Value.ToString();
                if (i.Attrib.AttribType.Type == typeof(DictGroup).FullName)
                {
                    strValue = DataAccessLayer.Get<DictValue>(i.Value).Description;
                }
                if (i.Attrib.AttribType.Type == typeof(EntityList).FullName)
                    continue;
                fullStr += strValue + " ";
            }

            if (checklist.ChecklistType == DataAccessLayer.Constants.EmployerChecklistType)
            {
                var employerNameAttrib = DataAccessLayer.GetAttributeValue(checklist.User.MainChecklist.Id, Constants.EmployerNameCode);
                fullStr += employerNameAttrib.Value;
            }
            return fullStr.Contains(queryStr);
        }