From fdc51c9e4ac225311e4e14923e6b48efbd05a6e1 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 4 Feb 2019 23:25:33 +0800 Subject: Init commit. --- Timeline/Services/UserService.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Timeline/Services/UserService.cs (limited to 'Timeline/Services/UserService.cs') 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 + { + /// + /// Try to anthenticate with the given username and password. + /// + /// The username of the user to be anthenticated. + /// The password of the user to be anthenticated. + /// null if anthentication failed. + /// An instance of if anthentication succeeded. + User Authenticate(string username, string password); + } + + public class UserService : IUserService + { + private readonly IList _users = new List{ + 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); + } + } +} -- cgit v1.2.3