USDADataImport.USDAImport.GetCountOfAllIngredients C# (CSharp) Method

GetCountOfAllIngredients() public method

public GetCountOfAllIngredients ( ) : int
return int
        public int GetCountOfAllIngredients()
        {
            //NutritionType returnValue;
            try
            {
                using (Restaurants restaurantsDb = new Restaurants())
                {
                    MongoEntityRepositoryBase<Ingredient> basicData =
                                                new MongoEntityRepositoryBase<Ingredient>(restaurantsDb.DB);
                    var allAllIngredients = basicData.GetAll();
                    List<Ingredient> ingredientsList = allAllIngredients.ToList();
                    log.InfoFormat("[GetCountOfAllIngredients] Count of all ingredients in DB = {0}.", ingredientsList.Count);
                    return ingredientsList.Count;
                }
            }
            catch (Exception e)
            {
                log.ErrorFormat("[GetAllIngredients] Exception={0}", e);
                return -1;
            }
        }