aboutsummaryrefslogtreecommitdiff
path: root/Models
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2020-12-08 17:51:29 +0200
committertranstrike <transtrike@gmail.com>2020-12-08 17:51:29 +0200
commit1505ff4d46ac3937b5b402a5adfea7bae903d31d (patch)
tree1dfd16c93a00bcc59815f6c6941f2a037c18eb01 /Models
parentabd57e8d5b19a3d6e42a3f549d6b4079686f893f (diff)
parentc61d3c8cfaa6ec9143eb752efffbc7df0940bf75 (diff)
downloadDevHive-1505ff4d46ac3937b5b402a5adfea7bae903d31d.tar
DevHive-1505ff4d46ac3937b5b402a5adfea7bae903d31d.tar.gz
DevHive-1505ff4d46ac3937b5b402a5adfea7bae903d31d.zip
Merged user-class with dev
Diffstat (limited to 'Models')
-rw-r--r--Models/Classes/User.cs128
1 files changed, 64 insertions, 64 deletions
diff --git a/Models/Classes/User.cs b/Models/Classes/User.cs
index 4903679..70f9c59 100644
--- a/Models/Classes/User.cs
+++ b/Models/Classes/User.cs
@@ -6,76 +6,76 @@ using System.Collections.Generic;
namespace Models.Classes
{
- [Table("Users")]
+ [Table("Users")]
public class User<T> : IdentityUser<int>
{
- private string firstName;
- private string lastName;
- private string profilePicture;
-
- [Required]
- [Range(3, 50)]
- [Display(Name = "Username")]
- public override string UserName {
- get => base.UserName;
- set {
- ValidateString("Username", 3, 50, value, true);
- base.UserName = value;
- }
- }
-
- [Required]
- [Range(3, 30)]
- public string FirstName {
- get => this.firstName;
- set {
- ValidateString("FirstName", 3, 30, value, false);
- this.firstName = value;
- }
- }
+ private string firstName;
+ private string lastName;
+ private string profilePicture;
- [Required]
- [Range(3, 30)]
- public string LastName {
- get => this.lastName;
- set {
- ValidateString("LastName", 3, 30, value, false);
- this.lastName = value;
- }
- }
+ [Required]
+ [Range(3, 50)]
+ [Display(Name = "Username")]
+ public override string UserName {
+ get => base.UserName;
+ set {
+ ValidateString("Username", 3, 50, value, true);
+ base.UserName = value;
+ }
+ }
+
+ [Required]
+ [Range(3, 30)]
+ public string FirstName {
+ get => this.firstName;
+ set {
+ ValidateString("FirstName", 3, 30, value, false);
+ this.firstName = value;
+ }
+ }
+
+ [Required]
+ [Range(3, 30)]
+ public string LastName {
+ get => this.lastName;
+ set {
+ ValidateString("LastName", 3, 30, value, false);
+ this.lastName = value;
+ }
+ }
- public string ProfilePicture {
- get => this.profilePicture;
- set {
- ValidateURL(value);
- this.profilePicture = value;
- }
- }
+ public string ProfilePicture {
+ get => this.profilePicture;
+ set {
+ ValidateURL(value);
+ this.profilePicture = value;
+ }
+ }
+
+ public List<User<T>> Friends { get; set; }
- public List<User<T>> Friends { get; set; }
-
- /// <summary>
- /// 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) {
- if (value.Length < minLength || value.Length > maxLength)
- throw new ArgumentException($"{name} length cannot be less than {minLength} and more than {maxLength}.");
+ /// <summary>
+ /// 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) {
+ 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
- if (!Char.IsLetter(character) || (canBeDigit && !Char.IsDigit(character)))
- throw new ArgumentException($"{name} contains invalid characters.");
- }
- }
+ foreach (char character in value) { // more efficient than Linq
+ if (!Char.IsLetter(character) || (canBeDigit && !Char.IsDigit(character)))
+ throw new ArgumentException($"{name} contains invalid characters.");
+ }
+ }
- /// <summary>
- /// Throws an exception if the absolute url isn't valid.
- /// Does nothing otherwise.
- /// </summary>
- private static void ValidateURL(string urlValue) {
- // Throws an error is URL is invalid
- Uri validatedUri;
- Uri.TryCreate(urlValue, UriKind.Absolute, out validatedUri);
- }
+ /// <summary>
+ /// Throws an exception if the absolute url isn't valid.
+ /// Does nothing otherwise.
+ /// </summary>
+ private static void ValidateURL(string urlValue) {
+ // Throws an error is URL is invalid
+ Uri validatedUri;
+ Uri.TryCreate(urlValue, UriKind.Absolute, out validatedUri);
+ }
}
}