IConfigurationService.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using GreenTree.Nachtragsmanagement.Core.Configuration;
  7. using GreenTree.Nachtragsmanagement.Core.Domain.Config;
  8. namespace GreenTree.Nachtragsmanagement.Services.Configuration
  9. {
  10. public interface IConfigurationService
  11. {
  12. /// <summary>
  13. /// Reads the current configuration from the global config
  14. /// </summary>
  15. AppendixConfigurationSection GetCurrentConfiguration();
  16. #region ConfigItem
  17. /// <summary>
  18. /// Gets all configItems
  19. /// </summary>
  20. IList<ConfigItem> GetAllConfigItems();
  21. /// <summary>
  22. /// Gets a configItem by specified Id
  23. /// </summary>
  24. /// <param name="id">ConfigItem identifier.</param>
  25. ConfigItem GetConfigItemById(int id);
  26. /// <summary>
  27. /// Gets a configItem by specified name
  28. /// </summary>
  29. /// <param name="name">ConfigItem name.</param>
  30. ConfigItem GetConfigItemByName(string name);
  31. /// <summary>
  32. /// Gets all configItems to the specified ids
  33. /// </summary>
  34. IList<ConfigItem> GetConfigItemsByIds(int[] ids);
  35. /// <summary>
  36. /// Insert a configItem
  37. /// </summary>
  38. /// <param name="configItem">ConfigItem.</param>
  39. void InsertConfigItem(ConfigItem configItem);
  40. /// <summary>
  41. /// Update a configItem
  42. /// </summary>
  43. /// <param name="configItem">ConfigItem.</param>
  44. void UpdateConfigItem(ConfigItem configItem);
  45. /// <summary>
  46. /// Delete a configItem
  47. /// </summary>
  48. /// <param name="configItem">ConfigItem.</param>
  49. void DeleteConfigItem(ConfigItem configItem);
  50. #endregion
  51. #region UserConfigItem
  52. /// <summary>
  53. /// Gets all userConfigItems
  54. /// </summary>
  55. IList<UserConfigItem> GetAllUserConfigItems();
  56. /// <summary>
  57. /// Gets a userConfigItem by specified Id
  58. /// </summary>
  59. /// <param name="id">UserConfigItem identifier.</param>
  60. UserConfigItem GetUserConfigItemById(int id);
  61. /// <summary>
  62. /// Gets a userConfigItem by specified name and user id
  63. /// </summary>
  64. /// <param name="name">UserConfigItem name.</param>
  65. /// <param name="userId">User Id.</param>
  66. UserConfigItem GetUserConfigItemByNameAndUserId(string name, int userId);
  67. /// <summary>
  68. /// Insert or update a userConfigItem
  69. /// </summary>
  70. /// <param name="userConfigItem">UserConfigItem.</param>
  71. void InsertOrUpdateUserConfigItem(UserConfigItem userConfigItem);
  72. /// <summary>
  73. /// Delete a userConfigItem
  74. /// </summary>
  75. /// <param name="userConfigItem">UserConfigItem.</param>
  76. void DeleteUserConfigItem(UserConfigItem userConfigItem);
  77. #endregion
  78. #region Casting
  79. /// <summary>
  80. /// Trys to convert the config items value type and returns its actual value, otherwise NULL
  81. /// </summary>
  82. /// <typeparam name="T">The actual type.</typeparam>
  83. /// <param name="configItem">ConfigItem.</param>
  84. /// <param name="defaultValue">Value, when conversion fails.</param>
  85. T TryGetConfigItemValue<T>(ConfigItem configItem, T defaultValue);
  86. /// <summary>
  87. /// Trys to convert the config items value type and returns its actual value, otherwise NULL
  88. /// </summary>
  89. /// <typeparam name="T">The actual type.</typeparam>
  90. /// <param name="configItemName">ConfigItem name.</param>
  91. /// <param name="defaultValue">Value, when conversion fails.</param>
  92. T TryGetConfigItemValue<T>(string configItemName, T defaultValue);
  93. #endregion
  94. }
  95. }