Example #1
0
        public IList<ProductTypeInfo> GetProductTypesBySerach(int pageIndex, int pageSize, out int Total, string name)
        {
            using (MyContext db = new MyContext())
            {
                Total = (from c in db.ProductType
                         where (!string.IsNullOrEmpty(name) ? c.ProductTypeName.Contains(name) : true)
                         orderby c.ID
                         select c).Count();
                var items = (from c in db.ProductType
                             where (!string.IsNullOrEmpty(name) ? c.ProductTypeName.Contains(name) : true)
                             orderby c.ID
                             select c).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();

                IList<ProductTypeInfo> ProductTypeInfos = new List<ProductTypeInfo>();
                foreach (var item in items)
                {
                    ProductTypeInfo info = new ProductTypeInfo();
                    info.ID = item.ID;
                    info.ProductTypeName = item.ProductTypeName;
                    info.Description = item.Description;

                    ProductTypeInfos.Add(info);
                }

                return ProductTypeInfos;
            }
        }
Example #2
0
        public IList<ProductTypeInfo> GetProductTypesList()
        {
            using (MyContext db = new MyContext())
            {

                var items = db.ProductType.ToList();
                IList<ProductTypeInfo> ProductTypeInfos = new List<ProductTypeInfo>();
                foreach (var item in items)
                {
                    ProductTypeInfo info = new ProductTypeInfo();
                    info.ID = item.ID;
                    info.ProductTypeName = item.ProductTypeName;
                    info.Description = item.Description;

                    ProductTypeInfos.Add(info);
                }

                return ProductTypeInfos;

            }
        }
Example #3
0
        public IList<ProductTypeInfo> GetProductTypesList(int pageIndex, int pageSize, out int Total)
        {
            using (MyContext db = new MyContext())
            {
                Total = (from c in db.ProductType
                         orderby c.ID
                         select c).Count();
                var items = (from c in db.ProductType
                             orderby c.ID
                             select c).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
                IList<ProductTypeInfo> ProductTypeInfos = new List<ProductTypeInfo>();
                foreach (var item in items)
                {
                    ProductTypeInfo info = new ProductTypeInfo();
                    info.ID = item.ID;
                    info.ProductTypeName = item.ProductTypeName;
                    info.Description = item.Description;

                    ProductTypeInfos.Add(info);
                }

                return ProductTypeInfos;
            }
        }