/// <summary> /// IsExistsAsync /// </summary> /// <param name="userId"></param> /// <param name="status"></param> /// <returns></returns> public async Task <bool> IsExistsAsync(int userId, XM.UserStatus?status = null) { var query = _context.User.Where(m => m.UserId == userId); query = query.WhereIf(status.HasValue, m => m.Status == status); return(await query.AnyAsync()); }
/// <summary> /// GetItemByUsernameAsync /// </summary> /// <param name="username"></param> /// <param name="status"></param> /// <returns></returns> public async Task <XM.UserInfo> GetItemByUsernameAsync(string username, XM.UserStatus?status = null) { var query = _context.User.AsNoTracking().Where(m => m.Username == username); query.WhereIf(status.HasValue, m => m.Status == status.Value); var user = await query.Select(_selector).FirstOrDefaultAsync(); return(user); }
/// <summary> /// IsExistsAsync /// </summary> /// <param name="userId"></param> /// <param name="status"></param> /// <returns></returns> public async Task <bool> IsExistsAsync(int userId, XM.UserStatus?status = null) { if (status.HasValue) { return(await _context.User.AnyAsync(m => m.UserId == userId && m.Status == status)); } else { return(await _context.User.AnyAsync(m => m.UserId == userId)); } }
/// <summary> /// GetItemByUserIdAsync /// </summary> /// <param name="userId"></param> /// <param name="status"></param> /// <returns></returns> public async Task <XM.UserInfo> GetItemByUserIdAsync(int userId, XM.UserStatus?status = null) { XM.UserInfo user; if (status.HasValue) { user = await _context.User.AsNoTracking().Select(_selector).FirstOrDefaultAsync(m => m.UserId == userId && m.Status == status.Value); } else { user = await _context.User.AsNoTracking().Select(_selector).FirstOrDefaultAsync(m => m.UserId == userId); } return(user); }
public async Task <XM.UserInfo> GetItemByUsernameAsync(string username, XM.UserStatus?status = null) { XM.UserInfo user; if (status.HasValue) { user = await _tubumuContext.User.AsNoTracking().Select(_selector).FirstOrDefaultAsync(m => m.Username == username && m.Status == status.Value); } else { user = await _tubumuContext.User.AsNoTracking().Select(_selector).FirstOrDefaultAsync(m => m.Username == username); } return(user); }
/// <summary> /// GetItemByMobileAsync /// </summary> /// <param name="mobile"></param> /// <param name="mobileIsValid"></param> /// <param name="status"></param> /// <returns></returns> public async Task <XM.UserInfo> GetItemByMobileAsync(string mobile, bool mobileIsValid = true, XM.UserStatus?status = null) { XM.UserInfo user; if (status.HasValue) { user = await _context.User.AsNoTracking().Select(_selector).FirstOrDefaultAsync(m => (m.EmailIsValid == mobileIsValid && m.Mobile == mobile) && m.Status == status.Value); } else { user = await _context.User.AsNoTracking().Select(_selector).FirstOrDefaultAsync(m => (m.EmailIsValid == mobileIsValid && m.Mobile == mobile)); } return(user); }
/// <summary> /// GetItemByMobileAsync /// </summary> /// <param name="mobile"></param> /// <param name="mobileIsValid"></param> /// <param name="status"></param> /// <returns></returns> public async Task <XM.UserInfo> GetItemByMobileAsync(string mobile, bool?mobileIsValid, XM.UserStatus?status = null) { var query = _context.User.AsNoTracking().Where(m => m.Mobile == mobile); query.WhereIf(mobileIsValid.HasValue, m => m.MobileIsValid == mobileIsValid.Value); query.WhereIf(status.HasValue, m => m.Status == status.Value); var user = await query.Select(_selector).FirstOrDefaultAsync(); return(user); }
/// <summary> /// GetItemByEmailAsync /// </summary> /// <param name="email"></param> /// <param name="emailIsValid"></param> /// <param name="status"></param> /// <returns></returns> public async Task <XM.UserInfo> GetItemByEmailAsync(string email, bool?emailIsValid, XM.UserStatus?status = null) { var query = _context.User.AsNoTracking().Where(m => m.Email == email); query.WhereIf(emailIsValid.HasValue, m => m.EmailIsValid == emailIsValid.Value); query.WhereIf(status.HasValue, m => m.Status == status.Value); var user = await query.Select(_selector).FirstOrDefaultAsync(); return(user); }
public async Task <XM.UserInfo> GetItemByEmailAsync(string email, bool emailIsValid = true, XM.UserStatus?status = null) { XM.UserInfo user; if (status.HasValue) { user = await _tubumuContext.User.AsNoTracking().Select(_selector).FirstOrDefaultAsync(m => (m.EmailIsValid == emailIsValid && m.Email == email) && m.Status == status.Value); } else { user = await _tubumuContext.User.AsNoTracking().Select(_selector).FirstOrDefaultAsync(m => (m.EmailIsValid == emailIsValid && m.Email == email)); } return(user); }