/// <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; }
/// <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; }
/// <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; }
/// <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; }
/// <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; }