vendredi 31 juillet 2015

Check user Login using Repository pattern c#

I'm new at design patterns and I'm trying to make some example using repository pattern (Maybe I'll ask some stupid question using stupid example and if it's so please tell me)

I have this repository in my BusinessLogicLayer

public interface IUserRepository
{
   LogIn GetByUsernameAndPassword(LogIn user);
}

and in my data access layer

class UserRepository : IUserRepository
    {
        ChatAppDBContext _db = new ChatAppDBContext();
        public LogIn GetByUsernameAndPassword(LogIn login)
        {
            return _db.Users.Where(u => u.Email == login.Email & u.Password == login.UserPassword).FirstOrDefault();
        }
    }

but it throws an error that Error:

Cannot implicitly convert type 'DataAccessLayer.User' to 'BusinessLogicLayer.Model.LogIn'

How can I solve that?

Aucun commentaire:

Enregistrer un commentaire