diff options
author | crupest <crupest@outlook.com> | 2019-02-04 23:25:33 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-02-04 23:25:33 +0800 |
commit | 4fea4164fad943eebc1850042994fdbaad3682f9 (patch) | |
tree | 36522d986769b0520afd53a791674644305a1dd1 /Timeline/Services/UserService.cs | |
download | timeline-4fea4164fad943eebc1850042994fdbaad3682f9.tar.gz timeline-4fea4164fad943eebc1850042994fdbaad3682f9.tar.bz2 timeline-4fea4164fad943eebc1850042994fdbaad3682f9.zip |
Init commit.
Diffstat (limited to 'Timeline/Services/UserService.cs')
-rw-r--r-- | Timeline/Services/UserService.cs | 33 |
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); + } + } +} |