Example #1
0
        public UserModel DoLoginAdmin(LoginModel model)
        {
            try
            {
                model.Password = CommonFunc.CalculateMD5Hash(model.Password);
                var user = _context.Users.Where(x => (x.Email == model.Email || x.UserName == model.UserName ||
                                                      x.UserName == model.Email) && x.Password == model.Password)
                           .Where(x => x.IsActive == true)
                           .Where(x => (x.Role == UserRole.Admin || x.Role == UserRole.Master))
                           .Select(x => new UserModel
                {
                    Id              = x.Id,
                    UserName        = x.UserName,
                    FullName        = x.FullName,
                    Password        = x.Password,
                    ConfirmPassword = x.ConfirmPassword,
                    Email           = x.Email,
                    Address         = x.Address,
                    Address1        = x.Address1,
                    PhoneNumber     = x.PhoneNumber,
                    DateOfBirth     = x.DateOfBirth,
                    Role            = x.Role,
                    Point           = x.Point
                }).FirstOrDefault();

                return(user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }