예제 #1
0
 /// <summary>
 /// カテゴリを取得します
 /// </summary>
 /// <param name="dbConnectionString">接続文字列</param>
 /// <param name="publicStatus">Publicなものだけをとるか、PublicとPrivateなものをとるか。規定値はPublicなもののみ。PublicStatus.Privateにするとすべてとる</param>
 /// <returns>カテゴリのリスト</returns>
 public static List<Category> GetCategories(string dbConnectionString, PublicStatus publicStatus = PublicStatus.Public)
 {
     List<Category> categories = new List<Category> { };
     using (CategoryResource resource = new CategoryResource(dbConnectionString))
     {
         categories = resource.GetCategories(publicStatus);
     }
     return categories;
 }
예제 #2
0
 /// <summary>
 /// 指定されたカテゴリを取得します
 /// </summary>
 /// <param name="dbConnectionString">接続文字列</param>
 /// <param name="id">カテゴリーID</param>
 /// <param name="publicStatus">Publicなものだけをとるか、PublicとPrivateなものをとるか。規定値はPublicなもののみ。PublicStatus.Privateにするとすべてとる</param>
 /// <returns>カテゴリ</returns>
 public static Category GetCategory(string dbConnectionString, int id, PublicStatus publicStatus = PublicStatus.Public)
 {
     Category category = null;
     using (CategoryResource resource = new CategoryResource(dbConnectionString))
     {
         category = resource.GetCategory(id, publicStatus);
     }
     return category;
 }
예제 #3
0
        /// <summary>
        /// カテゴリを更新します
        /// </summary>
        /// <param name="dbConnectionString">接続文字列</param>
        /// <param name="category">更新後のカテゴリ</param>
        /// <returns>成功した場合に真を返す</returns>
        public static bool UpdateCategory(string dbConnectionString, Category category)
        {
            if (category == null || category.Id < 1)
            {
                return false;
            }

            bool result = false;
            using (CategoryResource resource = new CategoryResource(dbConnectionString))
            {
                 result = resource.UpdateCategory(category);
            }

            return result;
        }
예제 #4
0
        /// <summary>
        /// 指定したIDを基にカテゴリ情報を取得します
        /// </summary>
        /// <param name="categoryId">カテゴリID</param>
        /// <returns></returns>
        public static Category GetPublicCategory(int categoryId)
        {
            Category category = new Category();
            if (categoryId < 1)
            {
                return category;
            }

            try
            {
                using (CategoryResource resource = new CategoryResource(AppSettings.GetDbConnectionString()))
                {
                    category = resource.GetCategory(categoryId);
                }
            }
            catch (Exception e)
            {
                AzureLog.WriteToTable(e);
            }

            return category;
        }
예제 #5
0
파일: VMBase.cs 프로젝트: hiroakit/blog
        /// <summary>
        /// 公開可能なカテゴリを取得します
        /// </summary>
        /// <returns></returns>
        public List<Category> GetPublicCategories()
        {
            List<Category> categories = new List<Category> { };

            try
            {
                using (CategoryResource resource = new CategoryResource(AppSettings.GetDbConnectionString()))
                {
                    categories = resource.GetCategories();
                }
            }
            catch (Exception e)
            {
                AzureLog.WriteToTable(e);
            }

            return categories;
        }