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" }); } }
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 = "个人说明可以让学者更多人了解你哦..." }); } } }
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()); } } }