public async Task <UserDTO> GetByIdAsync(long id) { using (var db = new UserCenterContext()) { var user = await db.Users.SingleOrDefaultAsync(p => p.Id == id); if (user == null) { return(null); } else { return(new UserDTO { Id = user.Id, NickName = user.NickName, PhoneNum = user.PhoneNum, }); } } }
public async Task <AppInfoDTO> GetByAppKeyAsync(string appKey) { using (var db = new UserCenterContext()) { var app = await db.AppInfos.Where(p => p.AppKey == appKey).FirstOrDefaultAsync(); if (app == null) { return(null); } else { return(new AppInfoDTO { Id = app.Id, IsEnabled = app.IsEnabled, AppKey = app.AppKey, AppSecret = app.AppSecret, Name = app.Name, }); } } }
public AppInfoService(UserCenterContext context) { this.Db = context; }