Ejemplo n.º 1
0
        internal Expression RecentFlagAdded()
        {
            var codes0 = CodeValues.Split(',').Select(ff => ff.Trim()).ToList();
            var q      = db.ViewStatusFlagLists.ToList();

            if (!db.FromBatch)
            {
                q = (from f in q
                     where f.RoleName == null || db.CurrentRoles().Contains(f.RoleName)
                     select f).ToList();
            }
            var codes = (from f in q
                         join c in codes0 on f.Flag equals c into j
                         from c in j
                         select c).ToList();
            var now = Util.Now;
            var dt  = now.AddDays(-Days).Date;

            Expression <Func <Person, bool> > pred = p => (
                from t in p.Tags
                where codes.Contains(t.Tag.Name)
                where t.Tag.TypeId == DbUtil.TagTypeId_StatusFlags
                where t.DateCreated >= dt
                select t
                ).Any();
            Expression expr = Expression.Invoke(pred, parm); // substitute parm for p

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
Ejemplo n.º 2
0
        internal Expression FamHasStatusFlag()
        {
            var codes0 = CodeValues.Split(',').Select(ff => ff.Trim()).ToList();
            var q      = db.ViewStatusFlagLists.ToList();

            if (!db.FromBatch)
            {
                q = (from f in q
                     where f.RoleName == null || db.CurrentRoles().Contains(f.RoleName)
                     select f).ToList();
            }
            var codes = (from f in q
                         join c in codes0 on f.Flag equals c into j
                         from c in j
                         select c).ToList();
            Expression <Func <Person, bool> > pred = p =>
                                                     p.Family.People.Any(m => m.Tags.Any(tt => codes.Contains(tt.Tag.Name) && tt.Tag.TypeId == 100));
            Expression expr = Expression.Invoke(pred, parm); // substitute parm for p

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
Ejemplo n.º 3
0
        private List<SelectListItem> ConvertToSelect(object items, string valuefield, List<string> values = null)
        {
            var codeValueItems = items as IEnumerable<CodeValueItem>;
            if (codeValueItems == null)
                return new List<SelectListItem>();

            var codeValueList = codeValueItems.ToList();

            List<SelectListItem> list2;
            if (values == null)
                values = CodeValues?.ToList() ?? new List<string>();

            switch (valuefield)
            {
                case "IdCode":
                    list2 = codeValueList.Select(c => new SelectListItem { Text = c.Value, Value = c.IdCode, Selected = values.Contains(c.IdCode) }).ToList();
                    break;
                case "IdValue":
                    list2 = codeValueList.Select(c => new SelectListItem { Text = c.Value, Value = c.IdValue, Selected = values.Any(vv => vv.StartsWith($"{c.Id},") || vv == $"{c.Id}") }).ToList();
                    break;
                case "Id":
                    list2 = codeValueList.Select(c => new SelectListItem { Text = c.Value, Value = c.Id.ToString(), Selected = values.Contains(c.Id.ToString()) }).ToList();
                    break;
                case "CodeValue":
                    list2 = codeValueList.Select(c => new SelectListItem { Text = c.Value, Value = c.CodeValue, Selected = values.Any(vv => vv.StartsWith($"{c.Code}:") || vv == c.Code)}).ToList();
                    break;
                case "Code":
                    list2 = codeValueList.Select(c => new SelectListItem { Text = c.Value, Value = c.Code, Selected = values.Contains(c.Code) }).ToList();
                    break;
                default:
                    list2 = codeValueList.Select(c => new SelectListItem { Text = c.Value, Value = c.Value, Selected = values.Contains(c.Value) }).ToList();
                    break;
            }
            return list2;
        }
Ejemplo n.º 4
0
        public List <PayingGuestHouse> GetAllPgs()
        {
            var pgs = (from pg in _dbContext.tbl_pgsb_paying_guest_homestay
                       select new PayingGuestHouse
            {
                PGFullName = pg.name,
                AddressLine1 = pg.address_line_1,
                AddressLine2 = pg.address_line_2,
                DetailedDescription = pg.incharge_person_details,
                IsInCharge = !string.IsNullOrEmpty(pg.incharge_id),
                OwnerName = pg.owner_name,
                PhoneNumber = pg.contact_phone_number,
                Email = pg.email_id,
                PGMasterId = Guid.Parse(pg.pg_id),
                //PointOfContact = pg.tbl_pgsb_users.
                Area = new Area(CodeValues.GetCodeValue("Area", pg.area_code), CodeValues.GetCodeValue("pincode", Convert.ToInt32(pg.pin_code))),
                PGType = new PGTypeGenderWise(CodeValues.GetCodeValue("pgtype", pg.pg_type_code)),
                //PointOfContact

                //pg.tbl_pgsb_pg_amenities.ToList().ForEach(
                //a =>
                //{
                //    Amenities.Add(CodeValues.GetCodeValue("PGAmenity", a.amenity_code));
                //}),
            }
                       );

            return(pgs.ToList());
        }
Ejemplo n.º 5
0
 public IEnumerable<SelectListItem> StatusFlags()
 {
     var q = from s in CodeValueModel.StatusFlags()
             select new SelectListItem
             {
                 Value = $"{s.Code}:{s.Value}",
                 Text = s.Value,
                 Selected = CodeValues.Any(vv => vv == s.Code)
             };
     return q;
 }
Ejemplo n.º 6
0
 private IEnumerable<SelectListItem> SelectedList(IEnumerable<SelectListItem> items)
 {
     if (CodeValues != null)
         return items.Select(c =>
             new SelectListItem
             {
                 Text = c.Text,
                 Value = c.Value,
                 Selected = CodeValues.Contains(c.Value)
             });
     return items;
 }
Ejemplo n.º 7
0
        public List <SelectListItem> ConvertToSelect(object items, string valuefield)
        {
            var list = items as IEnumerable <CodeValueItem>;
            List <SelectListItem> list2;
            List <string>         values;

            if (CodeValues != null)
            {
                values = CodeValues.ToList();
            }
            else if (CodeValue != null)
            {
                values = new List <string> {
                    CodeValue
                }
            }
            ;
            else
            {
                values = new List <string>();
            }
            switch (valuefield)
            {
            case "IdCode":
                list2 = list.Select(c => new SelectListItem {
                    Text = c.Value, Value = c.IdCode, Selected = values.Contains(c.IdCode)
                }).ToList();
                break;

            case "Id":
                list2 = list.Select(c => new SelectListItem {
                    Text = c.Value, Value = c.Id.ToString(), Selected = values.Contains(c.Id.ToString())
                }).ToList();
                break;

            case "Code":
                list2 = list.Select(c => new SelectListItem {
                    Text = c.Value, Value = c.Code, Selected = values.Contains(c.Code)
                }).ToList();
                break;

            default:
                list2 = list.Select(c => new SelectListItem {
                    Text = c.Value, Value = c.Value, Selected = values.Contains(c.Value)
                }).ToList();
                break;
            }
            return(list2);
        }
Ejemplo n.º 8
0
        private void GetAllCodeValues()
        {
            if (CodeValues.IsLoaded)
            {
                return;
            }

            var cds = (from cd in _dbContext.tbl_pgsb_code_values
                       select new CodeValue
            {
                Code = cd.code,
                CodeValueDesc = cd.code_value_desc,
                CodeValueDisplay = cd.code_value,
                CodeValueType = cd.code_value_type,
                CodeValueId = cd.code_value_id,
                ParentCode = cd.tbl_pgsb_code_values2.code,
                ParentCodeValueType = cd.tbl_pgsb_code_values2.code_value_type,
            }).ToList();

            CodeValues.SetCodeValues(cds);
        }
Ejemplo n.º 9
0
        public void EditCondition()
        {
            var c = Db.LoadQueryById(SelectedId);

            if (c == null)
            {
                return;
            }
            ConditionName = c.FieldInfo.Name;
            SetVisibility();
            Comparison = c.Comparison;
            switch (c.FieldInfo.Type)
            {
            case FieldType.String:
            case FieldType.StringEqual:
            case FieldType.StringEqualOrStartsWith:
                TextValue = c.TextValue;
                break;

            case FieldType.Integer:
            case FieldType.IntegerSimple:
            case FieldType.IntegerEqual:
            case FieldType.NullInteger:
                IntegerValue = c.TextValue;
                break;

            case FieldType.Number:
            case FieldType.NullNumber:
                NumberValue = c.TextValue;
                break;

            case FieldType.Date:
            case FieldType.DateSimple:
                DateValue = DateString(c.DateValue);
                break;

            case FieldType.Code:
            case FieldType.NullCode:
            case FieldType.CodeStr:
            case FieldType.DateField:
            case FieldType.Bit:
            case FieldType.NullBit:
                CodeValue = c.CodeIdValue;
                if (c.HasMultipleCodes && CodeValue.HasValue())
                {
                    CodeValues = c.CodeIdValue.Split(';');
                    foreach (var i in CodeData)
                    {
                        i.Selected = CodeValues.Contains(i.Value);
                    }
                }
                break;
            }
            Program           = c.Program;
            DivisionData      = Divisions(Program).ToList();
            Division          = c.Division;
            OrganizationData  = Organizations(Division).ToList();
            Organization      = c.Organization;
            Schedule          = c.Schedule;
            Campus            = c.Campus;
            OrgType           = c.OrgType;
            StartDate         = DateString(c.StartDate);
            EndDate           = DateString(c.EndDate);
            SelectMultiple    = c.HasMultipleCodes;
            AddToGroupEnabled = c.IsGroup;
            AddEnabled        = !c.IsFirst;
            RemoveEnabled     = !c.IsFirst;
            Days     = c.Days.ToString();
            Age      = c.Age.ToString();
            Quarters = c.Quarters;
            if (TagsVisible)
            {
                if (c.Tags != null)
                {
                    Tags = c.Tags.Split(';');
                }
                var cv = new CodeValueModel();
                TagData = CodeValueModel.ConvertToSelect(cv.UserTags(Util.UserPeopleId), "Code");
                foreach (var i in TagData)
                {
                    i.Selected = Tags.Contains(i.Value);
                }
            }
            if (PmmLabelsVisible)
            {
                if (c.Tags != null)
                {
                    PmmLabels = c.Tags.Split(',').Select(vv => vv).ToArray();
                }
                var cv = new CodeValueModel();
                PmmLabelData = CodeValueModel.ConvertToSelect(cv.PmmLabels(), "Id");
                if (PmmLabels != null)
                {
                    foreach (var i in PmmLabelData)
                    {
                        i.Selected = PmmLabels.Contains(i.Value);
                    }
                }
            }
            if (MinistryVisible)
            {
                Ministry = c.Program;
            }
            SavedQueryDesc = c.SavedQueryIdDesc;
        }