Example #1
0
 public async Task UserDelete(Guid id)
 {
     using (IDAL.IUserService userService = new DAL.UserService())
     {
         await userService.RemoveAsync(id);
     }
 }
Example #2
0
 public async Task <UserInformation> GetById(Guid userid)
 {
     using (IDAL.IUserService userSvc = new DAL.UserService())
     {
         if (await userSvc.GetAllAsync().AnyAsync(m => m.Id == userid))
         {
             return(await userSvc.GetAllAsync().Where(m => m.Id == userid).Select(m => new Dto.UserInformation()
             {
                 Id = m.Id,
                 Eamil = m.Eamil,
                 Password = m.Password,
                 NickName = m.NickName,
                 ImagePath = m.ImagePath,
                 FansCount = m.FansCount,
                 FocusCount = m.FocusCount,
                 PersonalDescription = m.PersonalDescription,
                 CreateTime = m.CreateTime,
                 IsFreeze = m.IsFreeze
             }).FirstAsync());
         }
         else
         {
             throw new ArgumentException("邮箱地址不存在");
         }
     }
 }
Example #3
0
 public async Task <bool> LoginAsync(string email, string pwd)
 {
     using (DAL.UserService userSvc = new DAL.UserService())
     {
         return(await userSvc.Login(email, pwd));
     }
 }
Example #4
0
 //业务逻辑层,一个按钮一个方法。
 public async Task Regist(string email, string pwd)
 {
     using (DAL.UserService userSvc = new DAL.UserService())
     {
         await userSvc.CreatAsync(new Models.User {
             Email = email, Password = pwd, LastLoginTime = DateTime.Now
         });
     }
 }
Example #5
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());
     }
 }
Example #6
0
        public async Task ChangeUserImagePathById(Guid id, string ImagePath)  //用户修改头像
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                var user = await userSvc.GetAllAsync().FirstAsync(m => m.Id == id);

                user.ImagePath = ImagePath;
                await userSvc.EditAsync(user);
            }
        }
Example #7
0
        public async Task ChangeUserFanscunt(Guid id, int focus, int fans)
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                var data = await userSvc.GetAllAsync().FirstOrDefaultAsync(m => m.Id == id);

                data.FocusCount = focus;
                data.FansCount  = fans;
                await userSvc.EditAsync(data);
            }
        }
Example #8
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
                });
            }
        }
Example #9
0
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="email"></param>
        /// <param name="siteName"></param>
        /// <param name="imagePath"></param>
        /// <returns></returns>
        public async Task ChangeUserInformation(string email, string siteName, string imagePath)
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                var user = await userSvc.GetAllAsync().FirstAsync(m => m.Email == email);

                user.SiteName  = siteName;
                user.ImagePath = imagePath;
                await userSvc.EditAsync(user);
            }
        }
Example #10
0
        public async Task ChangeUserInformation(string email, string nickname, string ImagePath, string psersonDesc)  //修改个人信息
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                var user = await userSvc.GetAllAsync().FirstAsync(m => m.Eamil == email);

                user.NickName            = nickname;
                user.ImagePath           = ImagePath;
                user.PersonalDescription = psersonDesc;
                await userSvc.EditAsync(user);
            }
        }
Example #11
0
        public async Task ChangeUserInformationById(Guid id, string email, string nickname, string psersonDesc)
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                var setuser = await userSvc.GetAllAsync().FirstAsync(m => m.Id == id);

                setuser.Eamil               = email;
                setuser.NickName            = nickname;
                setuser.PersonalDescription = psersonDesc;
                await userSvc.EditAsync(setuser);
            }
        }
Example #12
0
 public async Task Register(string email, string password)
 {
     using (IDAL.IUserService userSvc = new DAL.UserService())
     {
         await userSvc.CreateAsync(new UserModel()
         {
             Email     = email,
             Password  = password,
             SiteName  = "默认的小站",
             ImagePath = "default.png"
         });
     }
 }
Example #13
0
        public async Task ChangePassword(string email, string oldPwd, string newPwd)
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                if (await userSvc.GetAllAsync().AnyAsync(m => m.Email == email && m.Password == oldPwd))
                {
                    var user = await userSvc.GetAllAsync().FirstAsync(m => m.Email == email);

                    user.Password = newPwd;
                    await userSvc.EditAsync(user);
                }
            }
        }
Example #14
0
        public async Task UserEdit(Guid userid, string email, string imagepath, string sitename, int type)
        {
            using (IDAL.IUserService userService = new DAL.UserService())
            {
                var user = await userService.GetOneByIdAsync(userid);

                user.Email     = email;
                user.ImagePath = imagepath;
                user.SiteName  = sitename;
                user.Type      = type;
                await userService.EditAsync(user);
            }
        }
Example #15
0
 public async Task <List <UserInformation> > GetAllUserlike(string email, string nickname)
 {
     using (IDAL.IUserService userSvc = new DAL.UserService())
     {
         return(await userSvc.GetAllAsync().Where(m => m.Eamil == email || m.NickName == nickname).
                Select(m => new UserInformation()
         {
             Eamil = m.Eamil,
             NickName = m.NickName,
             Password = m.Password,
             ImagePath = m.ImagePath,
             PersonalDescription = m.PersonalDescription,
             CreateTime = m.CreateTime
         }).ToListAsync());
     }
 }
Example #16
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);
         }
     }
 }
Example #18
0
        public async Task <UserInformationDto> GetOneUserById(Guid id)
        {
            using (IDAL.IUserService userService = new DAL.UserService())
            {
                var user = await userService.GetOneByIdAsync(id);

                return(new UserInformationDto()
                {
                    Id = user.Id,
                    Email = user.Email,
                    ImagePath = user.ImagePath,
                    SiteName = user.SiteName,
                    FansCount = user.FansCount,
                    FocusCount = user.FocusCount,
                    Type = user.Type
                });
            }
        }
Example #19
0
        public async Task Register(string email, string nickname, string password)  //注册
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                var data = await userSvc.GetAllAsync().FirstOrDefaultAsync(m => m.Eamil == email);

                if (data == null)     //为 null 说明该邮箱未注册过
                {
                    await userSvc.CreateAsync(new User()
                    {
                        Eamil               = email,
                        NickName            = nickname,
                        Password            = password,
                        ImagePath           = "0.png",
                        PersonalDescription = "个人说明可以让学者更多人了解你哦..."
                    });
                }
            }
        }
Example #20
0
 public bool Login(string email, string password, out Guid userid)
 {
     using (IDAL.IUserService userSvc = new DAL.UserService())
     {
         var user = userSvc.GetAllAsync().FirstOrDefaultAsync(m => m.Email == email && m.Password == password);
         user.Wait();
         var data = user.Result;
         if (data == null)
         {
             userid = new Guid();
             return(false);
         }
         else
         {
             userid = data.ID;
             return(true);
         }
     }
 }
Example #21
0
        public async Task ChangePassword(string email, string newPwd, string oldPwd)  //修改密码
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                var data = await userSvc.GetAllAsync().AnyAsync(m => m.Eamil == email && m.Password == oldPwd); //判断是否存在该用户

                if (data)
                {
                    //找到对应的用户修改密码
                    var user = await userSvc.GetAllAsync().FirstAsync(m => m.Eamil == email);

                    user.Password = newPwd;
                    await userSvc.EditAsync(user);
                }
                else
                {
                    throw new ArgumentException("旧密码错误");
                }
            }
        }
Example #22
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());
                }
            }
        }
Example #23
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);
            }
        }
Example #24
0
        public async Task <List <UserInformation> > GetAllUserByAdmin(string email, string nickname, string desc, string isfreeze)      //管理员查询用户
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                var data = await userSvc.GetAllAsync()
                           .Where(m => string.IsNullOrEmpty(email) & string.IsNullOrEmpty(nickname) & string.IsNullOrEmpty(desc) & string.IsNullOrEmpty(isfreeze) || m.Eamil.Contains(email) & m.NickName.Contains(nickname) & m.PersonalDescription.Contains(desc) & m.IsFreeze.ToString().Contains(isfreeze))
                           .Select(m => new UserInformation()
                {
                    Id                  = m.Id,
                    Eamil               = m.Eamil,
                    NickName            = m.NickName,
                    Password            = m.Password,
                    ImagePath           = m.ImagePath,
                    PersonalDescription = m.PersonalDescription,
                    CreateTime          = m.CreateTime,
                    IsFreeze            = m.IsFreeze
                }).ToListAsync();

                return(data);
            }
        }
Example #25
0
 public async Task <UserInformationDto> GetUserByEmail(string email)
 {
     using (IDAL.IUserService userSvc = new DAL.UserService())
     {
         if (await userSvc.GetAllAsync().AnyAsync(m => m.Email == email))
         {
             return(await userSvc.GetAllAsync().Where(m => m.Email == email).Select(m => new Dto.UserInformationDto()
             {
                 ID = m.ID,
                 Email = m.Email,
                 ImagePath = m.ImagePath,
                 SiteName = m.SiteName,
                 FansCount = m.FocusCount,
                 FocusCount = m.FocusCount
             }).FirstAsync());
         }
         else
         {
             throw new ArgumentException("邮箱地址不存在");
         }
     }
 }
Example #26
0
 public bool Login(string email, string password, out Guid userid, out string nickname, out string imagepath)  //抛出登录用户id
 {
     using (IDAL.IUserService userSvc = new DAL.UserService())
     {
         var user = userSvc.GetAllAsync().FirstOrDefaultAsync(m => m.Eamil == email && m.Password == password);
         user.Wait();
         var data = user.Result;
         if (data == null)
         {
             userid    = new Guid(); //null 创建新的用户id
             nickname  = "";
             imagepath = "";
             return(false);
         }
         else
         {
             userid    = data.Id; //获得用户id
             nickname  = data.NickName;
             imagepath = data.ImagePath;
             return(true);
         }
     }
 }
Example #27
0
        public async Task <List <UserInformation> > GetAllUserByAdmin()        //管理员查询所有用户
        {
            using (IDAL.IUserService userSvc = new DAL.UserService())
            {
                var data = await userSvc
                           .GetAllAsync()
                           .OrderByDescending(m => m.FansCount)
                           .Select(m => new UserInformation()
                {
                    Id                  = m.Id,
                    Eamil               = m.Eamil,
                    NickName            = m.NickName,
                    Password            = m.Password,
                    ImagePath           = m.ImagePath,
                    PersonalDescription = m.PersonalDescription,
                    CreateTime          = m.CreateTime,
                    FansCount           = m.FansCount,
                    FocusCount          = m.FocusCount
                }).ToListAsync();

                return(data);
            }
        }
Example #28
0
 public async Task <UserInformation> GetByEmail(string email)   //查询用户,将Dto数据显示在页面
 {
     using (IDAL.IUserService userSvc = new DAL.UserService())
     {
         if (await userSvc.GetAllAsync().AnyAsync(m => m.Eamil == email))
         {
             return(await userSvc.GetAllAsync().Where(m => m.Eamil == email).Select(m => new Dto.UserInformation()  //通过Select,这里从Models数据转到Dto
             {
                 Id = m.Id,
                 Eamil = m.Eamil,
                 NickName = m.NickName,   //昵称
                 ImagePath = m.ImagePath,
                 FansCount = m.FansCount,
                 FocusCount = m.FocusCount,
                 PersonalDescription = m.PersonalDescription, //个人说明
                 CreateTime = m.CreateTime
             }).FirstAsync());                                //select获取的是集合, 这里取其中一个
         }
         else
         {
             return(null);
         }
     }
 }