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 = "admin", Password = "admin", Roles = new string[] { "User", "Admin" } }, new User { Id = 1, Username = "user", Password = "user", Roles = new string[] { "User"} } }; public User Authenticate(string username, string password) { return _users.FirstOrDefault(user => user.Username == username && user.Password == password); } } }