Esempio n. 1
0
 public static void RemoveValue(this LoanObject lo, int id)
 {
     if (lo.Properties?.ContainsKey(id) ?? false)
     {
         lo.Properties.Remove(id);
     }
 }
        private static void GetValueFromLoanObject(LoanObject loanObject, int id, Action <string> processValue)
        {
            {
                LoanProperty loanProperty = null;

                if (loanObject.Properties.TryGetValue(id, out loanProperty) && !string.IsNullOrEmpty(loanProperty.Value))
                {
                    processValue(loanProperty.Value);
                }
            }
        }
Esempio n. 3
0
 public static void MapValue(this LoanObject lo, int id, string value)
 {
     if (string.IsNullOrEmpty(value))
     {
         lo.RemoveValue(id);
     }
     else
     {
         lo.SetValue(id, value.ToString());
     }
 }
Esempio n. 4
0
 public static void MapValue <T>(this LoanObject lo, int id, T value, T emptyValue = default) where T : IComparable <T>
 {
     if (value.CompareTo(emptyValue) == 0)
     {
         lo.RemoveValue(id);
     }
     else
     {
         lo.SetValue(id, value.ToString());
     }
 }
        public static void SetValue(LoanObject loanObject, int id, Action <DateTime> setMe, DateTime origValue)
        {
            GetValueFromLoanObject(loanObject, id, (val) =>
            {
                DateTime newVal;

                if (DateTime.TryParse(val, out newVal))
                {
                    setMe(newVal);
                }
            });
        }
        public static void SetValue(LoanObject loanObject, int id, Action <double> setMe, double origValue)
        {
            GetValueFromLoanObject(loanObject, id, (val) =>
            {
                double newVal = -1;

                if (double.TryParse(val, out newVal))
                {
                    setMe(newVal);
                }
            });
        }
        public static void SetValue(LoanObject loanObject, int id, Action <int> setMe, int origValue)
        {
            GetValueFromLoanObject(loanObject, id, (val) =>
            {
                int newVal = -1;

                if (int.TryParse(val, out newVal))
                {
                    setMe(newVal);
                }
            });
        }
Esempio n. 8
0
        public static bool ContainsValues(this LoanObject lo, params int[] ids)
        {
            foreach (var id in ids)
            {
                if (lo.Properties.ContainsKey(id))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 9
0
        public static void SetValue(this LoanObject lo, int id, string value)
        {
            if (lo.Properties == null)
            {
                lo.Properties = new Dictionary <int, LoanProperty>();
            }

            lo.Properties[id] = new LoanProperty()
            {
                Id = id, Value = value
            };
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            Loan newLoan;

            using (Session s = new Session())
            {
                LoanObject loanObjectFromExternal = s.GetLoan(5);

                newLoan = loanObjectFromExternal.MapFrom();
            }


            using (Session s2 = new Session())
            {
                LoanObject externalLoan = s2.CreateLoan();
                newLoan.MapTo(externalLoan);

                s2.Save(externalLoan);
            }
        }
 public static void SetValue(LoanObject loanObject, int id, Action <string> setMe, string origValue)
 {
     GetValueFromLoanObject(loanObject, id, setMe);
 }