Example #1
0
        public static CategoryItem GetCategoryItemById(string categoryItemId, string categoryId)
        {
            if (string.IsNullOrEmpty(categoryItemId))
            {
                throw new ArgumentException(Resources.Categories.MessageEmptyItemId);
            }

            if (string.IsNullOrEmpty(categoryId))
            {
                throw new ArgumentException(Resources.Categories.MessageEmptyCategoryId);
            }

            CategoryItem theData = null;

            try
            {
                CategoryItemsTableAdapter         localAdapter = new CategoryItemsTableAdapter();
                CategoryDS.CategoryItemsDataTable theTable     = localAdapter.GetCategoryItemById(categoryItemId, categoryId);
                if (theTable != null && theTable.Rows.Count > 0)
                {
                    CategoryDS.CategoryItemsRow theRow = theTable[0];
                    theData = FillRecord(theRow);
                }
            }
            catch (Exception exc)
            {
                log.Error("Error en GetCategoryItemById para categoryItemId: " + categoryItemId + " y categoryId: " + categoryId, exc);
                throw new ArgumentException(Resources.Categories.MessageErrorGetItem);
            }

            return(theData);
        }
Example #2
0
        private static CategoryItem FillRecord(CategoryDS.CategoryItemsRow row)
        {
            CategoryItem theNewRecord = new CategoryItem(
                row.categoryItemID,
                row.name,
                row.categoryID);

            return(theNewRecord);
        }