public Article() { // insert empty strings to avoid null exceptions. ArticleID = ""; ArticleDescription = ""; ArticleText = ""; TaxClass = new Utils.TaxClass(); ArticleUnit = new Utils.Unit(); ArticleCategory = ""; Price1 = new Models.PriceModel(this); Price2 = new Models.PriceModel(this); Price3 = new Models.PriceModel(this); }
private bool importArticle(FuncClasses.FastXML bdb) { var list = bdb.GetAllArticles(user); var savingList = new List<Articles.Article>(); foreach(var prevart in list) { var article = bdb.GetArticle(prevart.ArticleID, user); var outputArticle = new Articles.Article(); outputArticle.ArticleID = article.ArticleID; outputArticle.ArticleDescription = article.ArticleDescription; outputArticle.ArticleCategory = article.ArticleCategory; outputArticle.ArticleText = article.ArticleText; //outputArticle.ArticleWeight = article.WeightString; outputArticle.Price1 = new Models.PriceModel(outputArticle) { Price1 = new Utils.EMoney(article.ArticlePrice1.Amount, article.ArticlePrice1.IsGross) }; outputArticle.Price2 = new Models.PriceModel(outputArticle) { Price1 = new Utils.EMoney(article.ArticlePrice2.Amount, article.ArticlePrice2.IsGross) }; outputArticle.Price3 = new Models.PriceModel(outputArticle) { Price1 = new Utils.EMoney(article.ArticlePrice3.Amount, article.ArticlePrice3.IsGross) }; // TaxClass var TaxClass = new Utils.TaxClass(); TaxClass.Name = article.TaxClass.Name; TaxClass.TaxRate = new Utils.Percentage() { PercentageString = article.TaxClass.TaxRateString }; Database.SaveOrUpdateTaxClass(TaxClass); outputArticle.TaxClass = TaxClass; // Unit var ArticleUnit = new Utils.Unit(); ArticleUnit.DecimalSeperator = ","; // Gets the count of digits after the seperating "." var format = article.ArticleUnit.UnitFormat.Split(new Char[] { '.' }); if (format.Length>1) { ArticleUnit.DecimalDigits = format[1].Length; } else { ArticleUnit.DecimalDigits = 0; } ArticleUnit.Name = article.ArticleUnit.Name; ArticleUnit.ShortName = article.ArticleUnit.ShortName; outputArticle.ArticleUnit = ArticleUnit; Database.SaveOrUpdateArticleUnit(ArticleUnit); savingList.Add(outputArticle); } Database.SaveOrUpdateArticle(savingList); return true; }
private IEnumerable<Utils.Unit> ArticleUnitsList() { logger.Debug("Start getting Units-list"); var templist = new ObservableCollection<Utils.Unit>(); if (!SettingsDB.Elements("Units").Any()) return templist; var itemlist = SettingsDB.Element("Units").Elements("Unit"); foreach (XElement item in itemlist) { try { var tempitem = new Utils.Unit(); tempitem.ParseFromXElement(item); templist.Add(tempitem); } catch (Exception e) { logger.Fatal("Error parsing the element", e); } } return templist; }