本文整理汇总了C#中GenericRepository.First方法的典型用法代码示例。如果您正苦于以下问题:C# GenericRepository.First方法的具体用法?C# GenericRepository.First怎么用?C# GenericRepository.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericRepository
的用法示例。
在下文中一共展示了GenericRepository.First方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckUserName
public object CheckUserName(RegisterModel model)
{
GenericRepository<User> userRepo = new GenericRepository<User>();
User user = userRepo.First(u => u.Username == model.Username);
if (user == null)
{
return true;
}
return false;
}
示例2: CheckMail
public object CheckMail(RegisterModel model)
{
GenericRepository<User> userRepo = new GenericRepository<User>();
User user = userRepo.First(u => u.Email == model.Email);
if (user == null)
{
return true;
}
return false;
}
示例3: VerifyUser
/// <summary>
/// Verifies the user.
/// </summary>
/// <param name="userName">Name of the user.</param>
/// <param name="password">The password.</param>
/// <returns></returns>
public static bool VerifyUser(string userName, string password)
{
if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) return false;
IRepository repository = new GenericRepository(new SmartGatewayEntities());
User user = repository.First<User>(u=>u.LoginName.ToLower() == userName.ToLower() && u.Password == password);
if (user != null) return true;
return false ;
}
示例4: Search
public List<Trip> Search(string username, string depDate, int? depLocId, int? arrLocId, double? price, int? seatNum, int? estHour, int? hour)
{
GenericRepository<Trip> tripRepo = new GenericRepository<Trip>();
GenericRepository<User> userRepo = new GenericRepository<User>();
DateTime departDate;
List<Expression<Func<Trip, bool>>> filters = new List<Expression<Func<Trip, bool>>>();
if (!string.IsNullOrEmpty(depDate))
{
if (DateTime.TryParse(depDate, out departDate))
{
filters.Add(t => t.DepartDate >= departDate);
}
}
if (!string.IsNullOrEmpty(username))
{
User user = userRepo.First(u => u.Username.Contains(username));
filters.Add(t => t.UserId == user.UserId);
}
if (seatNum != -1)
{
filters.Add(t => t.AvailableSeatNumber >= seatNum);
}
if (depLocId != -1)
{
filters.Add(t => t.DepartLocationId == depLocId);
}
if (arrLocId != -1)
{
filters.Add(t => t.ArrivalLocationId == arrLocId);
}
if (hour != 0)
{
filters.Add(t => t.DepHour >= hour);
}
if (estHour != 0)
{
filters.Add(t => t.EstimatedHour < estHour);
}
if (price!= null)
{
filters.Add(t => t.Price <= price);
}
return tripRepo.GetByMultipleConditions(filters).ToList();
}