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); }
public static List <CategoryItem> GetCategoriesItemByCategoryId(string categoryId) { if (string.IsNullOrEmpty(categoryId)) { throw new ArgumentException(Resources.Categories.MessageEmptyCategoryId); } List <CategoryItem> theList = new List <CategoryItem>(); CategoryItem theData = null; try { CategoryItemsTableAdapter localAdapter = new CategoryItemsTableAdapter(); CategoryDS.CategoryItemsDataTable theTable = localAdapter.GetCategoryItemsByCategoryId(categoryId); if (theTable != null && theTable.Rows.Count > 0) { foreach (CategoryDS.CategoryItemsRow theRow in theTable) { theData = FillRecord(theRow); theList.Add(theData); } } } catch (Exception exc) { log.Error("Error en GetCategoriesItemByCategoryId para categoryId: " + categoryId, exc); throw new ArgumentException(Resources.Categories.MessageErrorGetItemsByCategory); } return(theList); }