aboutsummaryrefslogtreecommitdiff
path: root/Models/Classes/User.cs
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-12-08 18:30:49 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-12-08 18:30:49 +0200
commitab0430b95cc440ed671beaf642c5749862e3b6b4 (patch)
tree81c5d0823c4907210bb1850b0d93cf932506967a /Models/Classes/User.cs
parent1505ff4d46ac3937b5b402a5adfea7bae903d31d (diff)
downloadDevHive-ab0430b95cc440ed671beaf642c5749862e3b6b4.tar
DevHive-ab0430b95cc440ed671beaf642c5749862e3b6b4.tar.gz
DevHive-ab0430b95cc440ed671beaf642c5749862e3b6b4.zip
Fixed opening curly brackets in User class
Diffstat (limited to 'Models/Classes/User.cs')
-rw-r--r--Models/Classes/User.cs33
1 files changed, 22 insertions, 11 deletions
diff --git a/Models/Classes/User.cs b/Models/Classes/User.cs
index 70f9c59..bbc05bf 100644
--- a/Models/Classes/User.cs
+++ b/Models/Classes/User.cs
@@ -16,9 +16,11 @@ namespace Models.Classes
[Required]
[Range(3, 50)]
[Display(Name = "Username")]
- public override string UserName {
+ public override string UserName
+ {
get => base.UserName;
- set {
+ set
+ {
ValidateString("Username", 3, 50, value, true);
base.UserName = value;
}
@@ -26,9 +28,11 @@ namespace Models.Classes
[Required]
[Range(3, 30)]
- public string FirstName {
+ public string FirstName
+ {
get => this.firstName;
- set {
+ set
+ {
ValidateString("FirstName", 3, 30, value, false);
this.firstName = value;
}
@@ -36,17 +40,21 @@ namespace Models.Classes
[Required]
[Range(3, 30)]
- public string LastName {
+ public string LastName
+ {
get => this.lastName;
- set {
+ set
+ {
ValidateString("LastName", 3, 30, value, false);
this.lastName = value;
}
}
- public string ProfilePicture {
+ public string ProfilePicture
+ {
get => this.profilePicture;
- set {
+ set
+ {
ValidateURL(value);
this.profilePicture = value;
}
@@ -58,11 +66,13 @@ namespace Models.Classes
/// Throws an argument exception if the given value is not composed only of letters, and if specified, also of digits.
/// Does nothing otherwise.
/// </summary>
- private static void ValidateString(string name, int minLength, int maxLength, string value, bool canBeDigit) {
+ private static void ValidateString(string name, int minLength, int maxLength, string value, bool canBeDigit)
+ {
if (value.Length < minLength || value.Length > maxLength)
throw new ArgumentException($"{name} length cannot be less than {minLength} and more than {maxLength}.");
- foreach (char character in value) { // more efficient than Linq
+ foreach (char character in value) // more efficient than Linq
+ {
if (!Char.IsLetter(character) || (canBeDigit && !Char.IsDigit(character)))
throw new ArgumentException($"{name} contains invalid characters.");
}
@@ -72,7 +82,8 @@ namespace Models.Classes
/// Throws an exception if the absolute url isn't valid.
/// Does nothing otherwise.
/// </summary>
- private static void ValidateURL(string urlValue) {
+ private static void ValidateURL(string urlValue)
+ {
// Throws an error is URL is invalid
Uri validatedUri;
Uri.TryCreate(urlValue, UriKind.Absolute, out validatedUri);