public IEnumerable <DalLot> GetByPredicateMany(Expression <Func <DalLot, bool> > expression)
        {
            var visitor = new ParameterTypeVisitor <DalLot, Lot>(expression);
            var expr    = visitor.Convert();
            var lots    = _dbContext.Set <Lot>().Where(expr);

            return(lots.Select(lot => new DalLot()
            {
                Id = lot.LotId,
                IsBlocked = lot.IsBlocked,
                CategoryName = lot.Category.CategoryName,
                CategoryRefId = lot.CategoryRefId,
                IsConfirm = lot.IsConfirm,
                Discription = lot.Discription,
                BlockReason = lot.BlockReason,
                LotName = lot.LotName,
                SellerRefId = lot.SellerRefId,
                EndDate = lot.EndDate,
                IsSold = lot.IsSold,
                SellerEmail = lot.Seller.Email,
                SellerLogin = lot.Seller.Login,
                StartDate = lot.StartDate,
                StartingBid = lot.StartingBid
            }));
        }
 public DalCategory GetByPredicate(Expression<Func<DalCategory, bool>> expression)
 {
     var visitor = new ParameterTypeVisitor<DalCategory, Category>(expression);
     var expr = visitor.Convert();
     var category = _dbContext.Set<Category>().FirstOrDefault(expr);
     var dalCategory = category?.ToDalCategory();
     return dalCategory;
 }
        public DalCategory GetByPredicate(Expression <Func <DalCategory, bool> > expression)
        {
            var visitor     = new ParameterTypeVisitor <DalCategory, Category>(expression);
            var expr        = visitor.Convert();
            var category    = _dbContext.Set <Category>().FirstOrDefault(expr);
            var dalCategory = category?.ToDalCategory();

            return(dalCategory);
        }
 public DalUser GetByPredicate(Expression<Func<DalUser, bool>> expression)
 {
     var visitor = new ParameterTypeVisitor<DalUser, User>(expression);
     var expr = visitor.Convert();
     var user = _dbContext.Set<User>().FirstOrDefault(expr);
     var dalUser = user?.ToDalUser();
     if (dalUser == null)
     {
         return null;
     }
     dalUser.Roles = _roleRepository.GetRolesByUserId(user.UserId);
     return dalUser;
 }
Beispiel #5
0
        public DalUser GetByPredicate(Expression <Func <DalUser, bool> > expression)
        {
            var visitor = new ParameterTypeVisitor <DalUser, User>(expression);
            var expr    = visitor.Convert();
            var user    = _dbContext.Set <User>().FirstOrDefault(expr);
            var dalUser = user?.ToDalUser();

            if (dalUser == null)
            {
                return(null);
            }
            dalUser.Roles = _roleRepository.GetRolesByUserId(user.UserId);
            return(dalUser);
        }
 public IEnumerable<DalLot> GetByPredicateMany(Expression<Func<DalLot, bool>> expression)
 {
     var visitor = new ParameterTypeVisitor<DalLot, Lot>(expression);
     var expr = visitor.Convert();
     var lots = _dbContext.Set<Lot>().Where(expr);
     return lots.Select(lot => new DalLot()
     {
         Id = lot.LotId,
         IsBlocked = lot.IsBlocked,
         CategoryName = lot.Category.CategoryName,
         CategoryRefId = lot.CategoryRefId,
         IsConfirm = lot.IsConfirm,
         Discription = lot.Discription,
         BlockReason = lot.BlockReason,
         LotName = lot.LotName,
         SellerRefId = lot.SellerRefId,
         EndDate = lot.EndDate,
         IsSold = lot.IsSold,
         SellerEmail = lot.Seller.Email,
         SellerLogin = lot.Seller.Login,
         StartDate = lot.StartDate,
         StartingBid = lot.StartingBid
     });
 }