aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Services/UserService.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-02-04 23:25:33 +0800
committercrupest <crupest@outlook.com>2019-02-04 23:25:33 +0800
commitfdc51c9e4ac225311e4e14923e6b48efbd05a6e1 (patch)
tree387fa924f0fbdd7b40a25029d5e7c3955764272b /Timeline/Services/UserService.cs
downloadtimeline-fdc51c9e4ac225311e4e14923e6b48efbd05a6e1.tar.gz
timeline-fdc51c9e4ac225311e4e14923e6b48efbd05a6e1.tar.bz2
timeline-fdc51c9e4ac225311e4e14923e6b48efbd05a6e1.zip
Init commit.
Diffstat (limited to 'Timeline/Services/UserService.cs')
-rw-r--r--Timeline/Services/UserService.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/Timeline/Services/UserService.cs b/Timeline/Services/UserService.cs
new file mode 100644
index 00000000..b3d76e3e
--- /dev/null
+++ b/Timeline/Services/UserService.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Timeline.Entities;
+
+namespace Timeline.Services
+{
+ public interface IUserService
+ {
+ /// <summary>
+ /// Try to anthenticate with the given username and password.
+ /// </summary>
+ /// <param name="username">The username of the user to be anthenticated.</param>
+ /// <param name="password">The password of the user to be anthenticated.</param>
+ /// <returns><c>null</c> if anthentication failed.
+ /// An instance of <see cref="User"/> if anthentication succeeded.</returns>
+ User Authenticate(string username, string password);
+ }
+
+ public class UserService : IUserService
+ {
+ private readonly IList<User> _users = new List<User>{
+ new User { Id = 0, Username = "hello", Password = "crupest" },
+ new User { Id = 1, Username = "test", Password = "test"}
+ };
+
+ public User Authenticate(string username, string password)
+ {
+ return _users.FirstOrDefault(user => user.Username == username && user.Password == password);
+ }
+ }
+}