Ejemplo n.º 1
0
        private void GenerateCurrencyType()
        {
            var generator = new CurrencyTypeGenerator(_pathToSolution);
            var names = generator.GetCurrencyTypesLines();

            foreach (string name in names)
            {
                string fullName = name.Substring(0, name.LastIndexOf('('));
                string shortName = name.Substring(name.LastIndexOf('(') + 1, 3);
                fullName = GeneratorHelper.RemoveDigits(fullName);

                var currencyType = new CurrencyType
                    {
                        Name = fullName,
                        ShortName = shortName
                    };

                var condition = new SelectCondition();
                var rule = new Rule(ClassNameHelper.GetFieldName<CurrencyType>(p => p.ShortName), Rule.Operations.Like,
                                    shortName);
                condition.Where.Rules.Add(rule);
                if (!Dao.IsExist<CurrencyType>(condition))
                {
                    Dao.SaveOrUpdate(currencyType);
                }
            }
        }
Ejemplo n.º 2
0
 private CurrencyType GetCurrencyType(string shortName)
 {
     shortName = shortName.Trim();
     var condition = new SelectCondition();
     var rule = new Rule(ClassNameHelper.GetFieldName<CurrencyType>(p => p.ShortName), Rule.Operations.Like, shortName);
     condition.Where.Rules.Add(rule);
     var result = Dao.SelectRange<CurrencyType>(condition);
     if (result.ItemsCount > 0)
     {
         return result.Result.First();
     }
     return null;
 }