public Customer FindByEmailAddress(string emailAddress) { return(_sessionFactory.GetCurrentSession().CreateCriteria <Customer>() .CreateAlias(PropertyNameHelper.ResolvePropertyName <Customer>(c => c.UserLogin), "user") .Add(Restrictions.Eq("user.Username", emailAddress)) .UniqueResult <Customer>()); }
public static Criterion Create <T>(Expression <Func <T, object> > expression, object value, CriteriaOperator criteriaOperator) { string propertyName = PropertyNameHelper.ResolvePropertyName <T>(expression); Criterion myCriterion = new Criterion(propertyName, value, criteriaOperator); return(myCriterion); }
public bool Exists(string firstName, string lastName, string emailAddress) { return(_sessionFactory.GetCurrentSession().CreateCriteria <Customer>() .Add(Restrictions.Eq(PropertyNameHelper.ResolvePropertyName <Customer>(c => c.FirstName), firstName)) .Add(Restrictions.Eq(PropertyNameHelper.ResolvePropertyName <Customer>(c => c.LastName), lastName)) .CreateAlias(PropertyNameHelper.ResolvePropertyName <Customer>(c => c.UserLogin), "user") .Add(Restrictions.Eq("user.Username", emailAddress)) .UniqueResult <Customer>() != null); }
public Customer FindBy(string identityToken) { ICriteria criteriaQuery = SessionFactory.GetCurrentSession().CreateCriteria(typeof(Customer)) .Add(Expression.Eq(PropertyNameHelper.ResolvePropertyName <Customer>(c => c.IdentityToken), identityToken)); IList <Customer> customers = criteriaQuery.List <Customer>(); Customer customer = customers.FirstOrDefault(); return(customer); }
public GetFeaturedProductsResponse GetFeaturedProducts() { GetFeaturedProductsResponse response = new GetFeaturedProductsResponse(); Query productQuery = new Query(); productQuery.OrderByProperty = new OrderByClause() { Desc = true, PropertyName = PropertyNameHelper.ResolvePropertyName <ProductTitle>(pt => pt.Price) }; response.Products = _productTitleRepository.FindBy(productQuery, 0, 6).ConvertToProductViews(); return(response); }
//Returns all the pseudo SKUs public async Task <GetAllPseudoSkusResponse> GetAllPseudoSkus() { GetAllPseudoSkusResponse response = new GetAllPseudoSkusResponse(); Query pseudoSkuQuery = new Query(); pseudoSkuQuery.OrderByProperty = new OrderByClause() { Desc = true, PropertyName = PropertyNameHelper.ResolvePropertyName <PseudoSkuTitle>(pt => pt.Price) }; var pseudoSkus = await _pseudoSkuTitleRepository.FindByAsync(pseudoSkuQuery, 0, 6); response.Products = _mapper.Map <IEnumerable <PseudoSkuSummaryView> >(pseudoSkus); return(response); }
public IEnumerable <Order> FindAllCustomersOrdersWithInOrderDateBy(Guid customerId, DateTime orderDate) { IEnumerable <Order> customerOrders = new List <Order>(); Query query = new Query(); //query.Add(new Criterion("CustomerId", customerId, CriteriaOperator.Equal)); query.Add(Criterion.Create <Order>(x => x.CustomerId, customerId, CriteriaOperator.Equal)); query.QueryOperator = QueryOperator.And; //query.Add(new Criterion("OrderDate", orderDate, CriteriaOperator.LessThanOrEqual)); query.Add(Criterion.Create <Order>(x => x.OrderDate, orderDate, CriteriaOperator.LessThanOrEqual)); //query.OrderByProperty = new OrderByClause { PropertyName = "OrderDate", Desc = true }; query.OrderByProperty = new OrderByClause { PropertyName = PropertyNameHelper.ResolvePropertyName <Order>(x => x.OrderDate), Desc = true }; customerOrders = _orderRepository.FindBy(query); return(customerOrders); }