Example #1
0
        public List <CUSTOMER> Search(CUSTOMER Customer, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.CUSTOMER.AsQueryable();

            if (Customer != null)
            {
                if (!String.IsNullOrWhiteSpace(Customer.Name))
                {
                    result = result.Where(c => (c.Name + " " + c.Surname).Contains(Customer.Name));
                }

                if (!String.IsNullOrWhiteSpace(Customer.Email))
                {
                    result = result.Where(c => c.Email.ToLower().Contains(Customer.Email.ToLower()));
                }

                if (Customer.Newsletter.HasValue)
                {
                    result = result.Where(c => c.Newsletter == Customer.Newsletter.Value);
                }
            }

            TotalRecords = result.Count();

            GenericSorterCaller <CUSTOMER> sorter = new GenericSorterCaller <CUSTOMER>();

            result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);

            return(result.Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
        public List<INVITATION> Search(INVITATION Entity, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
        {
            var result = Context.INVITATION.AsQueryable();
            if (Entity != null)
            {
                if (Entity.ID != 0)
                {
                    result = result.Where(b => b.ID == Entity.ID);
                }

                if (Entity.CustomerID.HasValue)
                {
                    result = result.Where(i => i.CustomerID == Entity.CustomerID);
                }

                if (!String.IsNullOrEmpty(Entity.InvitedMail))
                {
                    result = result.Where(i => i.InvitedMail.Contains(Entity.InvitedMail));
                }

                if (Entity.RegistrationDate != null)
                {
                    result = result.Where(i => i.RegistrationDate == (Entity.RegistrationDate));
                }
            }
            TotalRecords = result.Count();

            GenericSorterCaller<INVITATION> sorter = new GenericSorterCaller<INVITATION>();
            result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? DEFAULT_ORDER_EXP : OrderExp, SortDirection);

            // pagination
            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
Example #3
0
        public List <ORDER_BONUS> SearchOrderBonuses(int BonusID, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.ORDER_BONUS.AsQueryable().Where(b => b.BonusID == BonusID);

            TotalRecords = result.Count();

            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("Date"))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(c => c.ORDERS.DateCreated);
                }
                else
                {
                    result = result.OrderByDescending(c => c.ORDERS.DateCreated);
                }
            }
            else
            {
                GenericSorterCaller <ORDER_BONUS> sorter = new GenericSorterCaller <ORDER_BONUS>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "OrderID" : OrderExp, SortDirection);
            }
            // pagination
            return(result.Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Example #4
0
        public List <BRAND> Search(BRAND Brand, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.BRAND.AsQueryable();

            if (Brand != null)
            {
                if (!String.IsNullOrEmpty(Brand.Name))
                {
                    result = result.Where(b => b.Name.Contains(Brand.Name));
                }

                if (!String.IsNullOrEmpty(Brand.ShowName))
                {
                    result = result.Where(b => b.ShowName.Contains(Brand.ShowName));
                }

                if (!String.IsNullOrEmpty(Brand.Description))
                {
                    result = result.Where(b => b.Description.Contains(Brand.Description));
                }

                if (!String.IsNullOrEmpty(Brand.Email))
                {
                    result = result.Where(b => b.Email.Contains(Brand.Email));
                }
            }
            TotalRecords = result.Count();

            GenericSorterCaller <BRAND> sorter = new GenericSorterCaller <BRAND>();

            result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? DEFAULT_ORDER_EXP : OrderExp, SortDirection);

            // pagination
            return(result.Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
        public List<CUSTOMER> Search(CUSTOMER Customer, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.CUSTOMER.AsQueryable();
            if (Customer != null)
            {
                if (!String.IsNullOrWhiteSpace(Customer.Name))
                {
                    result = result.Where(c => (c.Name + " " + c.Surname).Contains(Customer.Name));
                }

                if (!String.IsNullOrWhiteSpace(Customer.Email))
                {
                    result = result.Where(c => c.Email.ToLower().Contains(Customer.Email.ToLower()));
                }

                if (Customer.Newsletter.HasValue)
                {
                    result = result.Where(c => c.Newsletter == Customer.Newsletter.Value);
                }
            }

            TotalRecords = result.Count();

            GenericSorterCaller<CUSTOMER> sorter = new GenericSorterCaller<CUSTOMER>();
            result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);

            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
Example #6
0
        public List <INVITATION> Search(INVITATION Entity, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
        {
            var result = Context.INVITATION.AsQueryable();

            if (Entity != null)
            {
                if (Entity.ID != 0)
                {
                    result = result.Where(b => b.ID == Entity.ID);
                }

                if (Entity.CustomerID.HasValue)
                {
                    result = result.Where(i => i.CustomerID == Entity.CustomerID);
                }

                if (!String.IsNullOrEmpty(Entity.InvitedMail))
                {
                    result = result.Where(i => i.InvitedMail.Contains(Entity.InvitedMail));
                }

                if (Entity.RegistrationDate != null)
                {
                    result = result.Where(i => i.RegistrationDate == (Entity.RegistrationDate));
                }
            }
            TotalRecords = result.Count();

            GenericSorterCaller <INVITATION> sorter = new GenericSorterCaller <INVITATION>();

            result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? DEFAULT_ORDER_EXP : OrderExp, SortDirection);

            // pagination
            return(result.Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Example #7
0
        public List <BONUS> Search(BONUS Bonus, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
        {
            var result = Context.BONUS.AsQueryable();

            if (Bonus != null)
            {
                if (Bonus.ID != 0)
                {
                    result = result.Where(b => b.ID == Bonus.ID);
                }

                if (!String.IsNullOrEmpty(Bonus.Description))
                {
                    result = result.Where(b => b.Description.Contains(Bonus.Description));
                }

                if (Bonus.CustomerID.HasValue)
                {
                    result = result.Where(b => b.CustomerID == Bonus.CustomerID.Value);
                }

                if (!String.IsNullOrWhiteSpace(Bonus.CustomerFullName))
                {
                    result = result.Where(s => (s.CUSTOMER.Name + " " + s.CUSTOMER.Surname).Contains(Bonus.CustomerFullName));
                }

                // useful for filtering expired bonuses
                if (Bonus.Validity.HasValue)
                {
                    result = result.Where(b => b.Validity >= Bonus.Validity);
                }

                if (Bonus.CustomerID.HasValue)
                {
                    result = result.Where(b => b.CustomerID == Bonus.CustomerID);
                }
            }
            TotalRecords = result.Count();
            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("CustomerFullName"))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(c => c.CUSTOMER.Name).ThenBy(c => c.CUSTOMER.Surname);
                }
                else
                {
                    result = result.OrderByDescending(c => c.CUSTOMER.Name).ThenBy(c => c.CUSTOMER.Surname);
                }
            }
            else
            {
                GenericSorterCaller <BONUS> sorter = new GenericSorterCaller <BONUS>();
                result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? DEFAULT_ORDER_EXP : OrderExp, SortDirection);
            }

            // pagination
            return(result.Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Example #8
0
        public List <CAMPAIGN> Search(CAMPAIGN Campaign, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.CAMPAIGN.Include("BRAND").AsQueryable();

            if (Campaign != null)
            {
                if (!String.IsNullOrWhiteSpace(Campaign.Name))
                {
                    result = result.Where(c => c.Name.Contains(Campaign.Name));
                }

                if (!String.IsNullOrWhiteSpace(Campaign.BrandName))
                {
                    result = result.Where(c => c.BRAND.Name.Contains(Campaign.Name));
                }

                if (Campaign.SearchStartDate.HasValue)
                {
                    result = result.Where(c => c.StartDate >= Campaign.SearchStartDate.Value);
                }

                if (Campaign.SearchEndDate.HasValue)
                {
                    result = result.Where(c => c.StartDate <= Campaign.SearchEndDate.Value);
                }

                if (Campaign.Active)
                {
                    result = result.Where(c => c.Active);
                }
                if (Campaign.Approved.HasValue)
                {
                    result = result.Where(c => c.Approved == Campaign.Approved.Value);
                }
            }

            TotalRecords = result.Count();

            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("BrandName"))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(c => c.BRAND.ShowName);
                }
                else
                {
                    result = result.OrderByDescending(c => c.BRAND.ShowName);
                }
            }
            else
            {
                var sorter = new GenericSorterCaller <CAMPAIGN>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);
            }
            // pagination
            return(result.Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Example #9
0
        public List <PRODUCT> Search(PRODUCT Product, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            // creating a graph with category and campaign to have the related campign for this product
            var result = Context.PRODUCT.Include("CATEGORY.CAMPAIGN").Include("PROD_IMAGES").AsQueryable();

            if (Product != null)
            {
                if (!String.IsNullOrWhiteSpace(Product.Name))
                {
                    result = result.Where(p => p.Name.Contains(Product.Name));
                }

                if (!String.IsNullOrWhiteSpace(Product.Description))
                {
                    result = result.Where(p => p.Description.Contains(Product.Description));
                }

                if (!String.IsNullOrWhiteSpace(Product.Code))
                {
                    result = result.Where(p => p.Code.Contains(Product.Code));
                }

                if (Product.CampaignID.HasValue)
                {
                    result = result.Where(p => p.CATEGORY.FirstOrDefault().CampaignID == Product.CampaignID);
                }

                if (Product.Closed.HasValue)
                {
                    result = result.Where(p => p.CATEGORY.FirstOrDefault().CAMPAIGN.Active == !Product.Closed.Value);
                }
            }
            TotalRecords = result.Count();
            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("Remaining"))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(c => c.PRODUCT_ATTRIBUTE.Select(p => p.Availability).Sum());
                }
                else
                {
                    result = result.OrderByDescending(c => c.PRODUCT_ATTRIBUTE.Select(p => p.Availability).Sum());
                }
            }
            else
            {
                GenericSorterCaller <PRODUCT> sorter = new GenericSorterCaller <PRODUCT>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "Name" : OrderExp, SortDirection);
            }
            result = result.Skip(PageIndex * PageSize).Take(PageSize);
            var SQL = (result as ObjectQuery).ToTraceString();

            return(result.ToList());
        }
Example #10
0
        public List<BONUS> Search(BONUS Bonus, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
        {
            var result = Context.BONUS.AsQueryable();
            if (Bonus != null)
            {
                if (Bonus.ID != 0)
                {
                    result = result.Where(b => b.ID == Bonus.ID);
                }

                if (!String.IsNullOrEmpty(Bonus.Description))
                {
                    result = result.Where(b => b.Description.Contains(Bonus.Description));
                }

                if (Bonus.CustomerID.HasValue)
                {
                    result = result.Where(b => b.CustomerID == Bonus.CustomerID.Value);
                }

                if (!String.IsNullOrWhiteSpace(Bonus.CustomerFullName))
                {
                    result = result.Where(s => (s.CUSTOMER.Name + " " + s.CUSTOMER.Surname).Contains(Bonus.CustomerFullName));
                }

                // useful for filtering expired bonuses
                if (Bonus.Validity.HasValue)
                {
                    result = result.Where(b => b.Validity >= Bonus.Validity);
                }

                if (Bonus.CustomerID.HasValue)
                {
                    result = result.Where(b => b.CustomerID == Bonus.CustomerID);
                }
            }
            TotalRecords = result.Count();
            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("CustomerFullName"))
            {
                if (SortDirection == SortDirection.Ascending)
                    result = result.OrderBy(c => c.CUSTOMER.Name).ThenBy(c => c.CUSTOMER.Surname);
                else
                    result = result.OrderByDescending(c => c.CUSTOMER.Name).ThenBy(c => c.CUSTOMER.Surname);
            }
            else
            {
                GenericSorterCaller<BONUS> sorter = new GenericSorterCaller<BONUS>();
                result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? DEFAULT_ORDER_EXP : OrderExp, SortDirection);
            }

            // pagination
            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
Example #11
0
        public List <ORDERS> Search(ORDERS Order, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.ORDERS.Include("CUSTOMER").Include("D_ORDER_STATUS").AsQueryable();

            if (Order != null)
            {
                if (!String.IsNullOrWhiteSpace(Order.CustomerName))
                {
                    result = result.Where(o => (o.CUSTOMER.Name + " " + o.CUSTOMER.Surname).Contains(Order.CustomerName));
                }

                if (Order.ID != 0)
                {
                    result = result.Where(o => o.ID == Order.ID);
                }

                if (Order.SearchStartDate.HasValue)
                {
                    result = result.Where(o => o.DateCreated >= Order.SearchStartDate.Value);
                }

                if (Order.SearchEndDate.HasValue)
                {
                    result = result.Where(o => o.DateCreated <= Order.SearchEndDate.Value);
                }

                if (Order.Status.HasValue)
                {
                    result = result.Where(o => o.Status == Order.Status.Value);
                }
            }

            TotalRecords = result.Count();

            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("CustomerName"))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(c => c.CUSTOMER.Name).ThenBy(c => c.CUSTOMER.Surname);
                }
                else
                {
                    result = result.OrderByDescending(c => c.CUSTOMER.Name).ThenBy(c => c.CUSTOMER.Surname);
                }
            }
            else
            {
                GenericSorterCaller <ORDERS> sorter = new GenericSorterCaller <ORDERS>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);
            }
            // pagination
            return(result.Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Example #12
0
        public List<PRODUCT> Search(PRODUCT Product, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            // creating a graph with category and campaign to have the related campign for this product
            var result = Context.PRODUCT.Include("CATEGORY.CAMPAIGN").Include("PROD_IMAGES").AsQueryable();
            if (Product != null)
            {
                if (!String.IsNullOrWhiteSpace(Product.Name))
                {
                    result = result.Where(p => p.Name.Contains(Product.Name));
                }

                if (!String.IsNullOrWhiteSpace(Product.Description))
                {
                    result = result.Where(p => p.Description.Contains(Product.Description));
                }

                if (!String.IsNullOrWhiteSpace(Product.Code))
                {
                    result = result.Where(p => p.Code.Contains(Product.Code));
                }

                if (Product.CampaignID.HasValue)
                {
                    result = result.Where(p => p.CATEGORY.FirstOrDefault().CampaignID == Product.CampaignID);
                }

                if (Product.Closed.HasValue)
                {
                    result = result.Where(p => p.CATEGORY.FirstOrDefault().CAMPAIGN.Active == !Product.Closed.Value);
                }
            }
            TotalRecords = result.Count();
            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("Remaining"))
            {
                if (SortDirection == SortDirection.Ascending)
                    result = result.OrderBy(c => c.PRODUCT_ATTRIBUTE.Select(p => p.Availability).Sum());
                else
                    result = result.OrderByDescending(c => c.PRODUCT_ATTRIBUTE.Select(p => p.Availability).Sum());
            }
            else
            {
                GenericSorterCaller<PRODUCT> sorter = new GenericSorterCaller<PRODUCT>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "Name" : OrderExp, SortDirection);
            }
            result = result.Skip(PageIndex * PageSize).Take(PageSize);
            var SQL = (result as ObjectQuery).ToTraceString();

            return result.ToList();
        }
Example #13
0
        public List<ORDERS> Search(ORDERS Order, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.ORDERS.Include("CUSTOMER").Include("D_ORDER_STATUS").AsQueryable();

            if (Order != null)
            {
                if (!String.IsNullOrWhiteSpace(Order.CustomerName))
                {
                    result = result.Where(o => (o.CUSTOMER.Name + " " + o.CUSTOMER.Surname).Contains(Order.CustomerName));
                }

                if (Order.ID != 0)
                {
                    result = result.Where(o => o.ID == Order.ID);
                }

                if (Order.SearchStartDate.HasValue)
                {
                    result = result.Where(o => o.DateCreated >= Order.SearchStartDate.Value);
                }

                if (Order.SearchEndDate.HasValue)
                {
                    result = result.Where(o => o.DateCreated <= Order.SearchEndDate.Value);
                }

                if (Order.Status.HasValue)
                {
                    result = result.Where(o => o.Status == Order.Status.Value);
                }
            }

            TotalRecords = result.Count();

            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("CustomerName"))
            {
                if (SortDirection == SortDirection.Ascending)
                    result = result.OrderBy(c => c.CUSTOMER.Name).ThenBy(c => c.CUSTOMER.Surname);
                else
                    result = result.OrderByDescending(c => c.CUSTOMER.Name).ThenBy(c => c.CUSTOMER.Surname);
            }
            else
            {
                GenericSorterCaller<ORDERS> sorter = new GenericSorterCaller<ORDERS>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);
            }
            // pagination
            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
        public List<D_ATTRIBUTE> Search(D_ATTRIBUTE Attribute, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.D_ATTRIBUTE.AsQueryable();
            if (Attribute != null)
            {
                if (!String.IsNullOrWhiteSpace(Attribute.Name))
                {
                    result = result.Where(p => p.Name.Contains(Attribute.Name));
                }
            }

            TotalRecords = result.Count();

            GenericSorterCaller<D_ATTRIBUTE> sorter = new GenericSorterCaller<D_ATTRIBUTE>();
            result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "Name" : OrderExp, SortDirection);

            result = result.Skip(PageIndex * PageSize).Take(PageSize);
            var SQL = (result as ObjectQuery).ToTraceString();

            return result.ToList();
        }
Example #15
0
        public List <USER> Search(USER User, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.USER.AsQueryable();

            if (User != null)
            {
                if (!String.IsNullOrWhiteSpace(User.Email))
                {
                    result = result.Where(o => o.Email.Contains(User.Email));
                }
                if (!String.IsNullOrWhiteSpace(User.Login))
                {
                    result = result.Where(o => o.Login.Contains(User.Login));
                }
                if (!String.IsNullOrWhiteSpace(User.Name))
                {
                    result = result.Where(o => o.Name.Contains(User.Name));
                }
                if (User.RoleID.HasValue)
                {
                    result = result.Where(o => o.RoleID == User.RoleID.Value);
                }

                if (User.Enabled)
                {
                    result = result.Where(o => o.Enabled == User.Enabled);
                }
            }

            TotalRecords = result.Count();

            GenericSorterCaller <USER> sorter = new GenericSorterCaller <USER>();

            result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);

            // pagination
            return(result.Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Example #16
0
        public List <D_ATTRIBUTE> Search(D_ATTRIBUTE Attribute, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.D_ATTRIBUTE.AsQueryable();

            if (Attribute != null)
            {
                if (!String.IsNullOrWhiteSpace(Attribute.Name))
                {
                    result = result.Where(p => p.Name.Contains(Attribute.Name));
                }
            }

            TotalRecords = result.Count();

            GenericSorterCaller <D_ATTRIBUTE> sorter = new GenericSorterCaller <D_ATTRIBUTE>();

            result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "Name" : OrderExp, SortDirection);

            result = result.Skip(PageIndex * PageSize).Take(PageSize);
            var SQL = (result as ObjectQuery).ToTraceString();

            return(result.ToList());
        }
Example #17
0
        public List<USER> Search(USER User, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
                var result = Context.USER.AsQueryable();
                if (User != null)
                {
                    if (!String.IsNullOrWhiteSpace(User.Email))
                    {
                        result = result.Where(o => o.Email.Contains(User.Email));
                    }
                    if (!String.IsNullOrWhiteSpace(User.Login))
                    {
                        result = result.Where(o => o.Login.Contains(User.Login));
                    }
                    if (!String.IsNullOrWhiteSpace(User.Name))
                    {
                        result = result.Where(o => o.Name.Contains(User.Name));
                    }
                    if (User.RoleID.HasValue)
                    {
                        result = result.Where(o => o.RoleID == User.RoleID.Value);
                    }

                    if (User.Enabled)
                    {
                        result = result.Where(o => o.Enabled == User.Enabled);
                    }
                }

                TotalRecords = result.Count();

                GenericSorterCaller<USER> sorter = new GenericSorterCaller<USER>();
                result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);

                // pagination
                return result.Skip( PageIndex * PageSize).Take(PageSize).ToList();
        }
Example #18
0
        public List <RETURN> Search(RETURN Return, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.RETURN.Include("ORDERS").Include("ORDERS.CUSTOMER").AsQueryable();

            if (Return != null)
            {
                if (Return.ID != 0)
                {
                    result = result.Where(b => b.ID == Return.ID);
                }

                if (!String.IsNullOrEmpty(Return.Comments))
                {
                    result = result.Where(b => b.Comments.Contains(Return.Comments));
                }

                if (Return.OrderID.HasValue)
                {
                    result = result.Where(b => b.OrderID == Return.OrderID.Value);
                }

                if (Return.ORDERS != null)
                {
                    result = result.Where(b => b.ORDERS == Return.ORDERS);
                }

                if (Return.ReceivedDate.HasValue)
                {
                    result = result.Where(b => b.ReceivedDate == Return.ReceivedDate);
                }

                if (Return.RequestDate.HasValue)
                {
                    result = result.Where(b => b.RequestDate == Return.RequestDate);
                }

                if (!string.IsNullOrEmpty(Return.CustomerName))
                {
                    result = result.Where(r => (r.ORDERS.CUSTOMER.Name + " " + r.ORDERS.CUSTOMER.Surname).Contains(Return.CustomerName));
                }

                if (!string.IsNullOrEmpty(Return.VerificationNumber))
                {
                    result = result.Where(r => r.VerificationNumber == Return.VerificationNumber);
                }
            }

            TotalRecords = result.Count();
            if (!String.IsNullOrEmpty(OrderExp))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(c => c.ID).ThenBy(c => c.OrderID);
                }
                else
                {
                    result = result.OrderByDescending(c => c.ID).ThenBy(c => c.OrderID);
                }
            }
            else
            {
                var sorter = new GenericSorterCaller <RETURN>();
                result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? DEFAULT_ORDER_EXP : OrderExp, SortDirection);
            }

            // pagination
            return(result.Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
Example #19
0
        public List<RETURN> Search(RETURN Return, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.RETURN.Include("ORDERS").Include("ORDERS.CUSTOMER").AsQueryable();
            if (Return != null)
            {
                if (Return.ID != 0)
                {
                    result = result.Where(b => b.ID == Return.ID);
                }

                if (!String.IsNullOrEmpty(Return.Comments))
                {
                    result = result.Where(b => b.Comments.Contains(Return.Comments));
                }

                if (Return.OrderID.HasValue)
                {
                    result = result.Where(b => b.OrderID == Return.OrderID.Value);
                }

                if (Return.ORDERS != null)
                {
                    result = result.Where(b => b.ORDERS == Return.ORDERS);
                }

                if (Return.ReceivedDate.HasValue)
                {
                    result = result.Where(b => b.ReceivedDate == Return.ReceivedDate);
                }

                if (Return.RequestDate.HasValue)
                {
                    result = result.Where(b => b.RequestDate == Return.RequestDate);
                }

                if (!string.IsNullOrEmpty(Return.CustomerName))
                {
                    result = result.Where(r => (r.ORDERS.CUSTOMER.Name + " " + r.ORDERS.CUSTOMER.Surname).Contains(Return.CustomerName));
                }

                if (!string.IsNullOrEmpty(Return.VerificationNumber))
                {
                    result = result.Where(r => r.VerificationNumber == Return.VerificationNumber);
                }
            }

            TotalRecords = result.Count();
            if (!String.IsNullOrEmpty(OrderExp))
            {
                if (SortDirection == SortDirection.Ascending)
                    result = result.OrderBy(c => c.ID).ThenBy(c => c.OrderID);
                else
                    result = result.OrderByDescending(c => c.ID).ThenBy(c => c.OrderID);
            }
            else
            {
                var sorter = new GenericSorterCaller<RETURN>();
                result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? DEFAULT_ORDER_EXP : OrderExp, SortDirection);
            }

            // pagination
            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
Example #20
0
        public List<ORDER_BONUS> SearchOrderBonuses(int BonusID, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.ORDER_BONUS.AsQueryable().Where(b => b.BonusID == BonusID);

            TotalRecords = result.Count();

            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("Date"))
            {
                if (SortDirection == SortDirection.Ascending)
                    result = result.OrderBy(c => c.ORDERS.DateCreated);
                else
                    result = result.OrderByDescending(c => c.ORDERS.DateCreated);
            }
            else
            {
                GenericSorterCaller<ORDER_BONUS> sorter = new GenericSorterCaller<ORDER_BONUS>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "OrderID" : OrderExp, SortDirection);
            }
            // pagination
            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
Example #21
0
        public List <SHOPPING_CART> Search(SHOPPING_CART Entity, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
        {
            var result = Context.SHOPPING_CART.AsQueryable();

            if (Entity != null)
            {
                if (!String.IsNullOrWhiteSpace(Entity.ProductName))
                {
                    result = result.Where(s => s.PRODUCT_ATTRIBUTE.PRODUCT.Name.Contains(Entity.ProductName));
                }

                if (!String.IsNullOrWhiteSpace(Entity.CampaignName))
                {
                    result = result.Where(s => s.CAMPAIGN.Name.Contains(Entity.CampaignName));
                }

                if (!String.IsNullOrWhiteSpace(Entity.CustomerName))
                {
                    result = result.Where(s => (s.CUSTOMER.Name + " " + s.CUSTOMER.Surname).Contains(Entity.CustomerName));
                }

                if (Entity.SearchStartDate.HasValue)
                {
                    result = result.Where(s => s.DateAdded >= Entity.SearchStartDate.Value);
                }

                if (Entity.CampaignID != 0)
                {
                    result = result.Where(s => s.CampaignID == Entity.CampaignID);
                }

                if (!String.IsNullOrWhiteSpace(Entity.ID))
                {
                    result = result.Where(s => s.ID == Entity.ID);
                }
            }

            TotalRecords = result.Count();

            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("ProductName"))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(s => s.PRODUCT_ATTRIBUTE.PRODUCT.Name);
                }
                else
                {
                    result = result.OrderByDescending(s => s.PRODUCT_ATTRIBUTE.PRODUCT.Name);
                }
            }
            else if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("CustomerName"))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(s => s.CUSTOMER.Name).ThenBy(s => s.CUSTOMER.Surname);
                }
                else
                {
                    result = result.OrderByDescending(s => s.CUSTOMER.Name).ThenBy(s => s.CUSTOMER.Surname);
                }
            }
            else if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("CampaignName"))
            {
                if (SortDirection == SortDirection.Ascending)
                {
                    result = result.OrderBy(s => s.CAMPAIGN.Name);
                }
                else
                {
                    result = result.OrderByDescending(s => s.CAMPAIGN.Name);
                }
            }
            else
            {
                GenericSorterCaller <SHOPPING_CART> sorter = new GenericSorterCaller <SHOPPING_CART>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);
            }
            // pagination
            return(result.Skip(PageIndex * PageSize).Take(PageSize).ToList());
        }
        public List<SHOPPING_CART> Search(SHOPPING_CART Entity, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
        {
            var result = Context.SHOPPING_CART.AsQueryable();

            if (Entity != null)
            {
                if (!String.IsNullOrWhiteSpace(Entity.ProductName))
                {
                    result = result.Where(s => s.PRODUCT_ATTRIBUTE.PRODUCT.Name.Contains(Entity.ProductName));
                }

                if (!String.IsNullOrWhiteSpace(Entity.CampaignName))
                {
                    result = result.Where(s => s.CAMPAIGN.Name.Contains(Entity.CampaignName));
                }

                if (!String.IsNullOrWhiteSpace(Entity.CustomerName))
                {
                    result = result.Where(s => (s.CUSTOMER.Name + " " + s.CUSTOMER.Surname).Contains(Entity.CustomerName));
                }

                if (Entity.SearchStartDate.HasValue)
                {
                    result = result.Where(s => s.DateAdded >= Entity.SearchStartDate.Value);
                }

                if (Entity.CampaignID != 0)
                {
                    result = result.Where(s => s.CampaignID == Entity.CampaignID);
                }

                if (!String.IsNullOrWhiteSpace(Entity.ID))
                {
                    result = result.Where(s => s.ID == Entity.ID);
                }
            }

            TotalRecords = result.Count();

            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("ProductName"))
            {
                if (SortDirection == SortDirection.Ascending)
                    result = result.OrderBy(s => s.PRODUCT_ATTRIBUTE.PRODUCT.Name);
                else
                    result = result.OrderByDescending(s => s.PRODUCT_ATTRIBUTE.PRODUCT.Name);
            }
            else if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("CustomerName"))
            {
                if (SortDirection == SortDirection.Ascending)
                    result = result.OrderBy(s => s.CUSTOMER.Name).ThenBy(s => s.CUSTOMER.Surname);
                else
                    result = result.OrderByDescending(s => s.CUSTOMER.Name).ThenBy(s => s.CUSTOMER.Surname);
            }
            else if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("CampaignName"))
            {
                if (SortDirection == SortDirection.Ascending)
                    result = result.OrderBy(s => s.CAMPAIGN.Name);
                else
                    result = result.OrderByDescending(s => s.CAMPAIGN.Name);
            }
            else
            {
                GenericSorterCaller<SHOPPING_CART> sorter = new GenericSorterCaller<SHOPPING_CART>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);
            }
            // pagination
            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
Example #23
0
        public List<CAMPAIGN> Search(CAMPAIGN Campaign, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.CAMPAIGN.Include("BRAND").AsQueryable();

            if (Campaign != null)
            {
                if (!String.IsNullOrWhiteSpace(Campaign.Name))
                {
                    result = result.Where(c => c.Name.Contains(Campaign.Name));
                }

                if (!String.IsNullOrWhiteSpace(Campaign.BrandName))
                {
                    result = result.Where(c => c.BRAND.Name.Contains(Campaign.Name));
                }

                if (Campaign.SearchStartDate.HasValue)
                {
                    result = result.Where(c => c.StartDate >= Campaign.SearchStartDate.Value);
                }

                if (Campaign.SearchEndDate.HasValue)
                {
                    result = result.Where(c => c.StartDate <= Campaign.SearchEndDate.Value);
                }

                if (Campaign.Active)
                {
                    result = result.Where(c => c.Active);
                }
                if (Campaign.Approved.HasValue)
                {
                    result = result.Where(c => c.Approved == Campaign.Approved.Value);
                }
            }

            TotalRecords = result.Count();

            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("BrandName"))
            {
                if (SortDirection == SortDirection.Ascending)
                    result = result.OrderBy(c => c.BRAND.ShowName);
                else
                    result = result.OrderByDescending(c => c.BRAND.ShowName);
            }
            else
            {
                var sorter = new GenericSorterCaller<CAMPAIGN>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);
            }
            // pagination
            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
Example #24
0
        public List<BRAND> Search(BRAND Brand, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.BRAND.AsQueryable();
            if (Brand != null)
            {
                if (!String.IsNullOrEmpty(Brand.Name))
                {
                    result = result.Where(b => b.Name.Contains(Brand.Name));
                }

                if (!String.IsNullOrEmpty(Brand.ShowName))
                {
                    result = result.Where(b => b.ShowName.Contains(Brand.ShowName));
                }

                if (!String.IsNullOrEmpty(Brand.Description))
                {
                    result = result.Where(b => b.Description.Contains(Brand.Description));
                }

                if (!String.IsNullOrEmpty(Brand.Email))
                {
                    result = result.Where(b => b.Email.Contains(Brand.Email));
                }
            }
            TotalRecords = result.Count();

            GenericSorterCaller<BRAND> sorter = new GenericSorterCaller<BRAND>();
            result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? DEFAULT_ORDER_EXP : OrderExp, SortDirection);

            // pagination
            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }