aboutsummaryrefslogtreecommitdiff
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
parentabd57e8d5b19a3d6e42a3f549d6b4079686f893f (diff)
parentc61d3c8cfaa6ec9143eb752efffbc7df0940bf75 (diff)
downloadDevHive-1505ff4d46ac3937b5b402a5adfea7bae903d31d.tar
DevHive-1505ff4d46ac3937b5b402a5adfea7bae903d31d.tar.gz
DevHive-1505ff4d46ac3937b5b402a5adfea7bae903d31d.zip
Merged user-class with dev
-rw-r--r--API/API.code-workspace19
-rw-r--r--DevHive.code-workspace6
-rw-r--r--Models/Classes/User.cs128
-rw-r--r--Web/Web.code-workspace19
4 files changed, 69 insertions, 103 deletions
diff --git a/API/API.code-workspace b/API/API.code-workspace
deleted file mode 100644
index 875e3c8..0000000
--- a/API/API.code-workspace
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "folders": [
- {
- "path": "."
- }
- ],
- "settings": {
- "files.exclude": {
- "**/.vscode": true,
- "**/bin": true,
- "**/obj": true,
- ".gitignore" : true,
- "**/README.md" : true,
- "**/LICENSE" : true,
- "**/Properties" : true,
- "**/*.code-workspace" : true
- }
- }
-} \ No newline at end of file
diff --git a/DevHive.code-workspace b/DevHive.code-workspace
index 5679111..539adda 100644
--- a/DevHive.code-workspace
+++ b/DevHive.code-workspace
@@ -7,7 +7,11 @@
{
"name": "Web",
"path": "./Web"
- }
+ },
+ {
+ "name": "Models",
+ "path": "./Models"
+ }
],
"settings": {
"files.exclude": {
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);
+ }
}
}
diff --git a/Web/Web.code-workspace b/Web/Web.code-workspace
deleted file mode 100644
index 875e3c8..0000000
--- a/Web/Web.code-workspace
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "folders": [
- {
- "path": "."
- }
- ],
- "settings": {
- "files.exclude": {
- "**/.vscode": true,
- "**/bin": true,
- "**/obj": true,
- ".gitignore" : true,
- "**/README.md" : true,
- "**/LICENSE" : true,
- "**/Properties" : true,
- "**/*.code-workspace" : true
- }
- }
-} \ No newline at end of file