当前位置: 首页>>代码示例>>C#>>正文


C# GenericRepository.First方法代码示例

本文整理汇总了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;
 }
开发者ID:yigityesilpinar,项目名称:Web-Based-Application-of-Carpooling,代码行数:10,代码来源:MembershipController.cs

示例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;
        }
开发者ID:yigityesilpinar,项目名称:Web-Based-Application-of-Carpooling,代码行数:11,代码来源:MembershipController.cs

示例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 ;
        }
开发者ID:TEGUHRI,项目名称:messagingtoolkit-smartgateway,代码行数:17,代码来源:SecurityHelper.cs

示例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();
        }
开发者ID:yigityesilpinar,项目名称:Web-Based-Application-of-Carpooling,代码行数:46,代码来源:TripController.cs


注:本文中的GenericRepository.First方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。