diff --git a/OutOfSchool/OutOfSchool.WebApi/Common/Resources/Codes/ImagesOperationErrorCode.cs b/OutOfSchool/OutOfSchool.WebApi/Common/Resources/Codes/ImagesOperationErrorCode.cs
index 92765f5cdd..843e7d55d3 100644
--- a/OutOfSchool/OutOfSchool.WebApi/Common/Resources/Codes/ImagesOperationErrorCode.cs
+++ b/OutOfSchool/OutOfSchool.WebApi/Common/Resources/Codes/ImagesOperationErrorCode.cs
@@ -1,43 +1,85 @@
namespace OutOfSchool.WebApi.Common.Resources.Codes
{
+ ///
+ /// Contains error codes of all operations with images.
+ ///
public enum ImagesOperationErrorCode
{
+ ///
+ /// The default error.
+ ///
[ResourcesKey(nameof(DefaultError))]
DefaultError = 0,
+ ///
+ /// The error that can be used when something wrong has happened while uploading images.
+ ///
[ResourcesKey(nameof(UploadingError))]
UploadingError = 1,
+ ///
+ /// The error that can be used when something wrong has happened while removing images.
+ ///
[ResourcesKey(nameof(RemovingError))]
RemovingError = 2,
+ ///
+ /// The error that can be used when unable to make some operation because of an image storage.
+ ///
[ResourcesKey(nameof(ImageStorageError))]
ImageStorageError = 3,
+ ///
+ /// The error that can be used when some image has not found.
+ ///
[ResourcesKey(nameof(ImageNotFoundError))]
ImageNotFoundError = 4,
+ ///
+ /// The error that can be used when some image hasn't passed the validation process because of unexpected factors.
+ ///
[ResourcesKey(nameof(UnexpectedValidationError))]
UnexpectedValidationError = 5,
+ ///
+ /// The error that can be used when some image hasn't passed the validation process because of the invalid image size.
+ ///
[ResourcesKey(nameof(InvalidSizeError))]
InvalidSizeError = 6,
+ ///
+ /// The error that can be used when some image hasn't passed the validation process because of the invalid image format.
+ ///
[ResourcesKey(nameof(InvalidFormatError))]
InvalidFormatError = 7,
+ ///
+ /// The error that can be used when some image hasn't passed the validation process because of the invalid image resolution.
+ ///
[ResourcesKey(nameof(InvalidResolutionError))]
InvalidResolutionError = 8,
+ ///
+ /// The error that can be used when cannot find the entity for operations with images.
+ ///
[ResourcesKey(nameof(EntityNotFoundError))]
EntityNotFoundError = 9,
+ ///
+ /// The error that can be used when no images were given for making operations.
+ ///
[ResourcesKey(nameof(NoGivenImagesError))]
NoGivenImagesError = 10,
+ ///
+ /// The error that can be used when something wrong has happened while updating the entity with changed images.
+ ///
[ResourcesKey(nameof(UpdateEntityError))]
UpdateEntityError = 11,
+ ///
+ /// The error that can be used when count of images is more than allowed for this type of entity.
+ ///
[ResourcesKey(nameof(ExceedingCountOfImagesError))]
ExceedingCountOfImagesError = 12,
}
diff --git a/OutOfSchool/OutOfSchool.WebApi/Extensions/OperationExtensions.cs b/OutOfSchool/OutOfSchool.WebApi/Extensions/OperationExtensions.cs
index 50653b6052..d98f0ad06a 100644
--- a/OutOfSchool/OutOfSchool.WebApi/Extensions/OperationExtensions.cs
+++ b/OutOfSchool/OutOfSchool.WebApi/Extensions/OperationExtensions.cs
@@ -6,13 +6,28 @@
namespace OutOfSchool.WebApi.Extensions
{
+ ///
+ /// Extensions for app service operations.
+ ///
public static class OperationExtensions
{
+ ///
+ /// Returns the localized for the specified culture by the code.
+ ///
+ /// The code.
+ /// The localized for the specified culture.
public static OperationError GetOperationError(this ImagesOperationErrorCode code)
{
return CreateOperationError(code.ToString(), code.GetResourceValue());
}
+ ///
+ /// Creates a new instance of .
+ ///
+ /// Code of the error.
+ /// Error's description.
+ /// The instance of .
+ /// When code is null.
public static OperationError CreateOperationError(string code, string description)
{
if (string.IsNullOrEmpty(code))
diff --git a/OutOfSchool/OutOfSchool.WebApi/Extensions/RetrievingResourcesExtensions.cs b/OutOfSchool/OutOfSchool.WebApi/Extensions/RetrievingResourcesExtensions.cs
index fbaf286f4f..bee914cf32 100644
--- a/OutOfSchool/OutOfSchool.WebApi/Extensions/RetrievingResourcesExtensions.cs
+++ b/OutOfSchool/OutOfSchool.WebApi/Extensions/RetrievingResourcesExtensions.cs
@@ -9,8 +9,17 @@
namespace OutOfSchool.WebApi.Extensions
{
+ ///
+ /// Extensions for receiving essential data from app resources.
+ ///
public static class RetrievingResourcesExtensions
{
+ ///
+ /// Returns the value of the string resource localized for the specified culture by the code.
+ ///
+ /// The code.
+ /// The culture you wanna try to get resource value.
+ /// The value of the resource localized for the specified culture, or null if a resource key cannot be found in a resource set.
public static string GetResourceValue(this ImagesOperationErrorCode code, CultureInfo culture = null)
{
var resourceKey = TryGetResourceKey(code);
@@ -18,8 +27,21 @@ public static string GetResourceValue(this ImagesOperationErrorCode code, Cultur
return GetStringFromResources(ResourceManagers.ImageResourceManager, resourceKey, culture);
}
+ ///
+ /// Returns the value of the resource key by the code.
+ ///
+ /// The code.
+ /// The value of the resource key, or null if a resource key cannot be found in an set.
public static string GetResourceKey(this ImagesOperationErrorCode code) => TryGetResourceKey(code);
+ ///
+ /// Returns the value of the string resource localized for the specified culture.
+ ///
+ /// The resource manager.
+ /// The key to find resource value.
+ /// The culture you wanna try to get resource value.
+ /// The value of the resource localized for the specified culture, or null if a resource key cannot be found in a resource set.
+ /// When resourceManager is null.
internal static string GetStringFromResources(ResourceManager resourceManager, string resourceKey, CultureInfo culture = null)
{
_ = resourceManager ?? throw new ArgumentNullException(nameof(resourceManager));