Esempio n. 1
0
        public async Task ChangePassword(string email, string oldPwd, string newPwd)
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                if (await userSvc.GetAll(m => m.Email == email && m.Password == oldPwd).AnyAsync())
                {
                    var user = await userSvc.GetAll().FirstAsync(m => m.Email == email);

                    user.Password = newPwd;
                    await userSvc.EditAsync(user);
                }
            }
        }
Esempio n. 2
0
 public async Task <List <Dto.UserDto> > GetAllUser()
 {
     using (DAL.UserService userService = new DAL.UserService())
     {
         return(await userService.GetAll().Select(m => new Dto.UserDto {
             Email = m.Email, Password = m.Password, LastLoginTime = m.LastLoginTime, UserId = m.Id
         }).ToListAsync());
     }
 }
Esempio n. 3
0
        public async Task ChangeUserInformation(string email, string siteName, string imagePath)
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                var user = await userSvc.GetAll().FirstAsync(m => m.Email == email);

                user.SiteName  = siteName;
                user.ImagePath = imagePath;
                await userSvc.EditAsync(user);
            }
        }
Esempio n. 4
0
        public async Task <Dto.UserDto> GetUserByEmailAsync(string email)
        {
            using (DAL.UserService userService = new DAL.UserService())
            {
                var result = await userService.GetAll().FirstAsync(m => m.Email == email);

                return(new Dto.UserDto {
                    Email = result.Email, Password = result.Password, LastLoginTime = result.LastLoginTime, UserId = result.Id
                });
            }
        }
Esempio n. 5
0
        public async Task <UserInformationDto> GetUserByOpenId(string openid, Dictionary <string, string> userInfo)
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                if (await userSvc.GetAll(m => m.OpenId == openid).AnyAsync())
                {
                    return(await userSvc.GetAll().Where(m => m.OpenId == openid).Select(m => new UserInformationDto()
                    {
                        Id = m.Id,
                        Email = m.Email,
                        FansCount = m.FansCount,
                        ImagePath = m.ImagePath,
                        SiteName = m.SiteName,
                        FocusCount = m.FocusCount,
                        Type = m.Type
                    }).FirstAsync());
                }
                else
                {
                    await userSvc.CreateAsync(new User()
                    {
                        Email     = "*****@*****.**",
                        Password  = "******",
                        SiteName  = userInfo["nickname"],
                        ImagePath = userInfo["figureurl_qq_1"],
                        OpenId    = openid
                    });

                    return(await userSvc.GetAll().Where(m => m.OpenId == openid).Select(m => new UserInformationDto()
                    {
                        Id = m.Id,
                        Email = m.Email,
                        FansCount = m.FansCount,
                        ImagePath = m.ImagePath,
                        SiteName = m.SiteName,
                        FocusCount = m.FocusCount,
                        Type = m.Type
                    }).FirstAsync());
                }
            }
        }
Esempio n. 6
0
        public async Task <UserInformationDto> GetUserByEmail(string email)
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                if (await userSvc.GetAll(m => m.Email == email).AnyAsync())
                {
                    return(await userSvc.GetAll().Where(m => m.Email == email).Select(m => new UserInformationDto()
                    {
                        Id = m.Id,
                        Email = m.Email,
                        FansCount = m.FansCount,
                        ImagePath = m.ImagePath,
                        SiteName = m.SiteName,
                        FocusCount = m.FocusCount,
                        Type = m.Type
                    }).FirstAsync());
                }

                return(null);
            }
        }
Esempio n. 7
0
 public async Task <List <UserInformationDto> > GetAllUsers()
 {
     using (IDAL.IUserService userService = new DAL.UserService())
     {
         return(await userService.GetAll().Select(m => new UserInformationDto()
         {
             Id = m.Id,
             Email = m.Email,
             ImagePath = m.ImagePath,
             SiteName = m.SiteName,
             FansCount = m.FansCount,
             FocusCount = m.FocusCount,
             Type = m.Type
         }).ToListAsync());
     }
 }
 public static bool Login(string email, string password, out Guid userId)
 {
     using (UserService userService = new DAL.UserService())
     {
         User user = userService.GetAll(m => m.Email == email && m.Password == password).FirstOrDefault();
         if (user == null)
         {
             userId = Guid.Empty;
             return(false);
         }
         else
         {
             userId = user.Id;
             return(true);
         }
     }
 }
Esempio n. 9
0
 public bool Login(string email, string password, out Guid userid)
 {
     using (IDAL.IUserService userSvc = new DAL.UserService())
     {
         var user = userSvc.GetAll(m => m.Email == email && m.Password == password).FirstOrDefaultAsync();
         user.Wait();
         var data = user.Result;
         if (data == null)
         {
             userid = new Guid();
             return(false);
         }
         else
         {
             userid = data.Id;
             return(true);
         }
     }
 }