Source

main-vinayFork / Source / WebService / Web.Admin.DataLayer / AdminUserRepository.cs

Full commit
using System.Linq;

namespace DataUp.Web.Admin.DataLayer
{
    public class AdminUserRepository: RepositoryBase<AdminUser>, IAdminUserRepository
    {
        private readonly DCXLAdminEntities dcxlAdminEntities;

        public AdminUserRepository(DCXLAdminEntities dcxlEntities)
            : base(dcxlEntities)
        {
            this.dcxlAdminEntities = dcxlEntities;
        }

        public AdminUser GetAdminUser(int userId)
        {
            var users = this.dcxlAdminEntities.AdminUsers.FirstOrDefault<AdminUser>(u => u.Id == userId);
            return users;
        }

        public AdminUser GetAdminUser(string userName, string password)
        {
            var user = this.dcxlAdminEntities.AdminUsers.FirstOrDefault(q =>
                q.UserName == userName && q.Password == password && q.IsActive == (q.IsActive.HasValue ? (bool)q.IsActive : false)
            );
            return user;
        }

        public bool IsAuthenticatedUser(string userName, string password)
        {
            return this.dcxlAdminEntities.AdminUsers.Any(q =>            
                q.UserName == userName && q.Password == password && q.IsActive == (q.IsActive.HasValue ? (bool)q.IsActive : false)
            );
        }
    }
}