GetExtraValue() public static method

public static GetExtraValue ( CmsData.CMSDataContext db, int id, string field ) : CmsData.PeopleExtra
db CmsData.CMSDataContext
id int
field string
return CmsData.PeopleExtra
Beispiel #1
0
        public string ExtraValue(int pid, string name)
        {
            var ev = Person.GetExtraValue(db, pid, name);

            if (ev != null)
            {
                switch (ev.Type)
                {
                case "Code":
                    return(ev.StrValue);

                case "Text":
                    return(ev.Data);

                case "Date":
                    return(ev.DateValue.FormatDate());

                case "Bit":
                    return(ev.BitValue.ToString());

                case "Int":
                    return(ev.IntValue.ToString());

                case "Data":
                    return($"{ev.StrValue};{ev.DateValue.FormatDate()};{ev.BitValue};{ev.IntValue};{ev.Data}");

                default:
                    return($"unknown type: {ev.Type}");
                }
            }
            return("");
        }
Beispiel #2
0
        public int ExtraValueInt(int pid, string name)
        {
            var ev = Person.GetExtraValue(db, pid, name);

            if (ev != null)
            {
                return(ev.IntValue ?? 0);
            }
            return(0);
        }
Beispiel #3
0
        public string ExtraValueText(int pid, string name)
        {
            var ev = Person.GetExtraValue(db, pid, name);

            if (ev != null)
            {
                return(ev.Data ?? "");
            }
            return("");
        }
Beispiel #4
0
        public DateTime ExtraValueDate(int pid, string name)
        {
            var ev = Person.GetExtraValue(db, pid, name);

            if (ev != null)
            {
                return(ev.DateValue ?? DateTime.MinValue);
            }
            return(DateTime.MinValue);
        }
Beispiel #5
0
        public bool ExtraValueBit(int pid, string name)
        {
            var ev = Person.GetExtraValue(db, pid, name);

            if (ev != null)
            {
                return(ev.BitValue ?? false);
            }
            return(false);
        }
        public string ExtraValue(object pid, string name)
        {
            var ev = Person.GetExtraValue(db, pid.ToInt(), name);

            if (ev != null)
            {
                return(ev.StrValue ?? "");
            }
            return("");
        }
Beispiel #7
0
 public void DeleteExtraValue(object query, string name)
 {
     using (var db2 = NewDataContext())
         foreach (var pid in db2.PeopleQueryIds(query))
         {
             var ev = Person.GetExtraValue(db2, pid, name);
             db2.PeopleExtras.DeleteOnSubmit(ev);
             db2.SubmitChanges();
         }
 }
Beispiel #8
0
        public string ExtraValueAttributes(int pid, string name)
        {
            var ev = Person.GetExtraValue(db, pid, name);

            if (ev?.IsAttributes != true)
            {
                return("");
            }
            return(ev.Data ?? "");
        }
Beispiel #9
0
        public void DeleteExtraValue(object query, string name)
        {
            var list = db.PeopleQuery2(query).Select(ii => ii.PeopleId).ToList();

            foreach (var pid in list)
            {
                var db2 = NewDataContext();
                var ev  = Person.GetExtraValue(db2, pid, name);
                db2.PeopleExtras.DeleteOnSubmit(ev);
                db2.SubmitChanges();
                db2.Dispose();
            }
        }