示例#1
0
        public static Category GetCategoryById(string categoryId)
        {
            if (string.IsNullOrEmpty(categoryId))
            {
                throw new ArgumentException(Resources.Categories.MessageEmptyCategoryId);
            }

            Category theData = null;

            try
            {
                CategoriesTableAdapter         localAdapter = new CategoriesTableAdapter();
                CategoryDS.CategoriesDataTable theTable     = localAdapter.GetCategoryById(categoryId);
                if (theTable != null && theTable.Rows.Count > 0)
                {
                    CategoryDS.CategoriesRow theRow = theTable[0];
                    theData = FillRecord(theRow);
                }
            }
            catch (Exception exc)
            {
                log.Error("Error en GetCategoryById para categoryId: " + categoryId, exc);
                throw new ArgumentException(Resources.Categories.MessageErrorGetCategory);
            }

            return(theData);
        }
示例#2
0
        private static Category FillRecord(CategoryDS.CategoriesRow row)
        {
            Category theNewRecord = new Category(
                row.categoryID,
                row.name);

            return(theNewRecord);
        }