コード例 #1
0
        public IEnumerable <UserDataModel> GetEmployeesData()
        {
            IEnumerable <AspNetUsers>   aspuserData = db.AspNetUsers;
            IEnumerable <UserDataModel> result      = db.AspNetUsers.Select(c => new UserDataModel
            {
                UserName           = c.UserName,
                Name               = c.Name,
                BirthDay           = c.BirthDay,
                Country            = c.Country,
                Email              = c.Email,
                IdentityCardNumber = c.IdentityCardNumber,
                MailingAddress     = c.MailingAddress,
                PhoneNumber        = c.PhoneNumber,
                ResidenceAddress   = c.ResidenceAddress,
                Telephone          = c.Telephone,
                Title              = c.Title,
                IsEmp              = false
            }).ToList();

            foreach (UserDataModel u in result)
            {
                IsEmployee x = db.IsEmployee.Where(c => c.UserId == u.UserName).FirstOrDefault();
                if (x != null)
                {
                    u.IsEmp = true;
                }
            }
            result = result.Where(c => c.IsEmp == true);
            return(result);
        }
コード例 #2
0
        public UserDataModel GetUserByID(string UserName)
        {
            AspNetUsers   aspuserData = db.AspNetUsers.Where(u => u.UserName == UserName).First();
            UserDataModel result      = new UserDataModel
            {
                UserName           = aspuserData.UserName,
                Name               = aspuserData.Name,
                BirthDay           = aspuserData.BirthDay,
                Country            = aspuserData.Country,
                Email              = aspuserData.Email,
                IdentityCardNumber = aspuserData.IdentityCardNumber,
                MailingAddress     = aspuserData.MailingAddress,
                PhoneNumber        = aspuserData.PhoneNumber,
                ResidenceAddress   = aspuserData.ResidenceAddress,
                Telephone          = aspuserData.Telephone,
                Title              = aspuserData.Title,
                IsEmp              = false
            };
            IsEmployee x = db.IsEmployee.Where(c => c.UserId == UserName).FirstOrDefault();

            if (x != null)
            {
                result.IsEmp = true;
            }
            return(result);
        }