aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Services
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-10-25 18:36:02 +0800
committer杨宇千 <crupest@outlook.com>2019-10-25 18:36:02 +0800
commit2528710897c6995eaa6b04a63c1daa8cdffbf29d (patch)
treec6ec0a916c78a02b36113fb62f0e919019df6cfc /Timeline/Services
parent20089ee8a29f9c59a28779baadf5560bca9f7be1 (diff)
downloadtimeline-2528710897c6995eaa6b04a63c1daa8cdffbf29d.tar.gz
timeline-2528710897c6995eaa6b04a63c1daa8cdffbf29d.tar.bz2
timeline-2528710897c6995eaa6b04a63c1daa8cdffbf29d.zip
Add NeutralResourcesLanguage. Conform to best practices.
Diffstat (limited to 'Timeline/Services')
-rw-r--r--Timeline/Services/DatabaseExtensions.cs5
-rw-r--r--Timeline/Services/UserAvatarService.cs6
-rw-r--r--Timeline/Services/UserService.cs10
3 files changed, 10 insertions, 11 deletions
diff --git a/Timeline/Services/DatabaseExtensions.cs b/Timeline/Services/DatabaseExtensions.cs
index 62b22f00..8cbc8fef 100644
--- a/Timeline/Services/DatabaseExtensions.cs
+++ b/Timeline/Services/DatabaseExtensions.cs
@@ -1,6 +1,5 @@
using Microsoft.EntityFrameworkCore;
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Timeline.Entities;
@@ -22,9 +21,9 @@ namespace Timeline.Services
{
if (username == null)
throw new ArgumentNullException(nameof(username));
- var (result, messageGenerator) = validator.Validate(username);
+ var (result, message) = validator.Validate(username);
if (!result)
- throw new UsernameBadFormatException(username, messageGenerator(null));
+ throw new UsernameBadFormatException(username, message);
var userId = await userDbSet.Where(u => u.Name == username).Select(u => u.Id).SingleOrDefaultAsync();
if (userId == 0)
diff --git a/Timeline/Services/UserAvatarService.cs b/Timeline/Services/UserAvatarService.cs
index ff80003c..2afe9093 100644
--- a/Timeline/Services/UserAvatarService.cs
+++ b/Timeline/Services/UserAvatarService.cs
@@ -219,7 +219,7 @@ namespace Timeline.Services
{
if (!LanguageHelper.AreSame(avatarEntity.Data == null, avatarEntity.Type == null))
{
- var message = Resources.Services.UserAvatarService.DatabaseCorruptedDataAndTypeNotSame;
+ var message = Resources.Services.UserAvatarService.ExceptionDatabaseCorruptedDataAndTypeNotSame;
_logger.LogCritical(message);
throw new DatabaseCorruptedException(message);
}
@@ -248,9 +248,9 @@ namespace Timeline.Services
if (avatar != null)
{
if (avatar.Data == null)
- throw new ArgumentException(Resources.Services.UserAvatarService.ArgumentAvatarDataNull, nameof(avatar));
+ throw new ArgumentException(Resources.Services.UserAvatarService.ExceptionAvatarDataNull, nameof(avatar));
if (string.IsNullOrEmpty(avatar.Type))
- throw new ArgumentException(Resources.Services.UserAvatarService.ArgumentAvatarTypeNullOrEmpty, nameof(avatar));
+ throw new ArgumentException(Resources.Services.UserAvatarService.ExceptionAvatarTypeNullOrEmpty, nameof(avatar));
}
var userId = await DatabaseExtensions.CheckAndGetUser(_database.Users, _usernameValidator, username);
diff --git a/Timeline/Services/UserService.cs b/Timeline/Services/UserService.cs
index 8f354fc7..4012539f 100644
--- a/Timeline/Services/UserService.cs
+++ b/Timeline/Services/UserService.cs
@@ -164,15 +164,15 @@ namespace Timeline.Services
_logger.LogInformation(Log.Format(Resources.Services.UserService.LogCacheRemove, ("Key", key)));
}
- private void CheckUsernameFormat(string username, string? message = null)
+ private void CheckUsernameFormat(string username, string? additionalMessage = null)
{
- var (result, messageGenerator) = _usernameValidator.Validate(username);
+ var (result, message) = _usernameValidator.Validate(username);
if (!result)
{
- if (message == null)
- throw new UsernameBadFormatException(username, messageGenerator(null));
+ if (additionalMessage == null)
+ throw new UsernameBadFormatException(username, message);
else
- throw new UsernameBadFormatException(username, message + messageGenerator(null));
+ throw new UsernameBadFormatException(username, additionalMessage + message);
}
}