예제 #1
0
        public List <ClienteModel> ObtenerCliente(int?page, int?limit, string sortBy, string direction, string searchString, out int total)
        {
            var clienteList = db.Cliente.ToList();
            var listClient  = Factory.Factory.ListClienteModels();

            //Edit Product Selected
            foreach (var item in clienteList)
            {
                var productList = Factory.Factory.CreateListProductdb();
                var pc          = db.IdClienteIdProducto.Where(x => x.IdCliente == item.IdCliente).ToList();

                foreach (var itemproduct in pc)
                {
                    var product = db.Product.Where(x => x.IdProducto == itemproduct.IdProducto).First();
                    productList.Add(product);
                }

                var map = MapperObject.CreateClienteProductModel(item, productList);
                listClient.Add(map);
            }

            if (!string.IsNullOrWhiteSpace(searchString))
            {
                listClient = listClient.Where(p => (p.Nombre.ToUpper().StartsWith(searchString.ToUpper()) || p.Nombre.ToUpper().EndsWith(searchString.ToUpper())) ||
                                              (p.Codigo.ToUpper().StartsWith(searchString.ToUpper()) || p.Codigo.ToUpper().EndsWith(searchString.ToUpper())) ||
                                              (p.Apellido.ToUpper().StartsWith(searchString.ToUpper()) || p.Apellido.ToUpper().EndsWith(searchString.ToUpper()))).ToList();
            }

            total = clienteList.Count();
            var clienteQueryable = listClient.AsQueryable();

            if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction))
            {
                if (direction.Trim().ToLower() == "asc")
                {
                    clienteQueryable = SortHelper.OrderBy(clienteQueryable, sortBy);
                }
                else
                {
                    clienteQueryable = SortHelper.OrderByDescending(clienteQueryable, sortBy);
                }
            }

            if (page.HasValue && limit.HasValue)
            {
                int start = (page.Value - 1) * limit.Value;
                clienteQueryable = clienteQueryable.Skip(start).Take(limit.Value);
            }

            return(clienteQueryable.ToList());
        }
예제 #2
0
        public List <ProductModels> GetProductNotSelectedProvider(Guid?idProvider, int?page, int?limit, string sortBy, string direction, string searchString, out int total)
        {
            total = 0;
            var map = new List <ProductModels>();

            map = MapProduct();

            if (idProvider != null)
            {
                var productList = db.IdProveedorProducto.Where(x => x.IdProveedor == idProvider).ToList();



                foreach (var item in productList)
                {
                    var deleteProduct = map.Where(x => x.IdProducto == item.IdProducto).First();
                    map.Remove(deleteProduct);
                }
            }


            if (!string.IsNullOrWhiteSpace(searchString))
            {
                map = GetProductListQuery(map, searchString);
            }

            total = map.Count();

            var productQueryable = map.AsQueryable();

            if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction))
            {
                if (direction.Trim().ToLower() == "asc")
                {
                    productQueryable = SortHelper.OrderBy(productQueryable, sortBy);
                }
                else
                {
                    productQueryable = SortHelper.OrderByDescending(productQueryable, sortBy);
                }
            }
            if (page.HasValue && limit.HasValue)
            {
                int start = (page.Value - 1) * limit.Value;
                productQueryable = productQueryable.Skip(start).Take(limit.Value);
            }

            return(productQueryable.ToList());
        }
예제 #3
0
        public List <ProductModels> GetProductList(int?page, int?limit, string sortBy, string direction, string searchString, string searchStringSub, out int total)
        {
            var map = new List <ProductModels>();

            map = MapProduct();

            if (!string.IsNullOrWhiteSpace(searchString))
            {
                map = map.Where(p => (p.CodigoBarra != null) ?(((p.CodigoBarra.ToUpper().StartsWith(searchString.ToUpper()) || p.CodigoBarra.ToUpper().EndsWith(searchString.ToUpper())) || (p.Codigo.ToString().ToUpper().StartsWith(searchString.ToUpper()) || p.Codigo.ToString().ToUpper().EndsWith(searchString.ToUpper())) ||
                                                                (p.Descripcion1.ToUpper().StartsWith(searchString.ToUpper()) || p.Descripcion1.ToUpper().EndsWith(searchString.ToUpper())) ||
                                                                (p.Marca.ToUpper().StartsWith(searchString.ToUpper()) || p.Marca.ToUpper().EndsWith(searchString.ToUpper())) ||
                                                                (p.Descripcion2.ToUpper().StartsWith(searchString.ToUpper()) || p.Descripcion2.ToUpper().EndsWith(searchString.ToUpper())))): ((p.Codigo.ToString().StartsWith(searchString.ToUpper()) || p.Codigo.ToString().ToUpper().EndsWith(searchString.ToUpper())) ||
                                                                                                                                                                                               (p.Descripcion1.ToUpper().StartsWith(searchString.ToUpper()) || p.Descripcion1.ToUpper().EndsWith(searchString.ToUpper())) ||
                                                                                                                                                                                               (p.Marca.ToUpper().StartsWith(searchString.ToUpper()) || p.Marca.ToUpper().EndsWith(searchString.ToUpper())) ||
                                                                                                                                                                                               (p.Descripcion2.ToUpper().StartsWith(searchString.ToUpper()) || p.Descripcion2.ToUpper().EndsWith(searchString.ToUpper())))).ToList();
            }

            if (!string.IsNullOrWhiteSpace(searchStringSub))
            {
                map = map.Where(p => (p.Descripcion2.ToUpper().StartsWith(searchStringSub.ToUpper()) || p.Descripcion2.ToUpper().EndsWith(searchStringSub.ToUpper()))).ToList();
            }


            total = map.Count();

            var productQueryable = map.AsQueryable();


            if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction))
            {
                if (direction.Trim().ToLower() == "asc")
                {
                    productQueryable = SortHelper.OrderBy(productQueryable, sortBy);
                }
                else
                {
                    productQueryable = SortHelper.OrderByDescending(productQueryable, sortBy);
                }
            }
            if (page.HasValue && limit.HasValue)
            {
                int start = (page.Value - 1) * limit.Value;
                productQueryable = productQueryable.Skip(start).Take(limit.Value);
            }

            return(productQueryable.ToList());
        }
예제 #4
0
        public List <ProductModels> GetProductListByIdProvider(Guid?idProvider, int?page, int?limit, string sortBy, string direction, string searchString, out int total)
        {
            total = 0;
            var productList = new List <ProductModels>();

            if (idProvider != null)
            {
                var pc = db.IdProveedorProducto.Where(x => x.IdProveedor == idProvider).ToList();

                foreach (var itemproduct in pc)
                {
                    var product = GetProductById(itemproduct.IdProducto.Value);
                    productList.Add(product);
                }


                total = productList.Count();

                var productQueryable = productList.AsQueryable();

                if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction))
                {
                    if (direction.Trim().ToLower() == "asc")
                    {
                        productQueryable = SortHelper.OrderBy(productQueryable, sortBy);
                    }
                    else
                    {
                        productQueryable = SortHelper.OrderByDescending(productQueryable, sortBy);
                    }
                }
                if (page.HasValue && limit.HasValue)
                {
                    int start = (page.Value - 1) * limit.Value;
                    productQueryable = productQueryable.Skip(start).Take(limit.Value);
                }
                return(productQueryable.ToList());
            }

            return(new List <ProductModels>());
        }
예제 #5
0
        public List <ProductModels> GetProduct(int?page, int?limit, string sortBy, string direction, string searchString, out int total)
        {
            var productList      = db.Product.ToList();
            var categoriaList    = db.Category.ToList();
            var subCategoriaList = db.SubCategory.ToList();
            var tamanoList       = db.TamanoMascota.ToList();

            var product = MapperObject.CreateProductList(productList, categoriaList, subCategoriaList, tamanoList);

            if (!string.IsNullOrWhiteSpace(searchString))
            {
                product = product.Where(p => p.Descripcion1.Contains(searchString) || p.Codigo.ToString().Contains(searchString)).ToList();
            }

            total = product.Count();

            var productQueryable = product.AsQueryable();

            if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction))
            {
                if (direction.Trim().ToLower() == "asc")
                {
                    productQueryable = SortHelper.OrderBy(productQueryable, sortBy);
                }
                else
                {
                    productQueryable = SortHelper.OrderByDescending(productQueryable, sortBy);
                }
            }

            if (page.HasValue && limit.HasValue)
            {
                int start = (page.Value - 1) * limit.Value;
                productQueryable = productQueryable.Skip(start).Take(limit.Value);
            }

            return(productQueryable.ToList());
        }
예제 #6
0
        public List <ProductModels> GetProductList(int?page, int?limit, string sortBy, string direction, string searchString, out int total)
        {
            var    map           = new List <ProductModels>();
            var    listCode      = new List <ProductModels>();
            var    listCodeBarra = new List <ProductModels>();
            double codigo        = 0;

            map = MapProduct();

            if (!string.IsNullOrWhiteSpace(searchString))
            {
                try
                {
                    codigo = double.Parse(searchString);
                }
                catch (FormatException e)
                {
                    codigo = 0;
                }

                if (codigo != 0)
                {
                    listCode      = map.Where(p => (p.Codigo == codigo)).ToList();
                    listCodeBarra = map.Where(p => (p.CodigoBarra == searchString)).ToList();
                }

                else
                {
                    map = GetProductListQuery(map, searchString);
                }
            }

            if (listCode.Count != 0)
            {
                map = listCode;
            }

            if (listCodeBarra.Count != 0)
            {
                map = listCodeBarra;
            }

            total = map.Count();

            var productQueryable = map.AsQueryable();


            if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction))
            {
                if (direction.Trim().ToLower() == "asc")
                {
                    productQueryable = SortHelper.OrderBy(productQueryable, sortBy);
                }
                else
                {
                    productQueryable = SortHelper.OrderByDescending(productQueryable, sortBy);
                }
            }
            if (page.HasValue && limit.HasValue)
            {
                int start = (page.Value - 1) * limit.Value;
                productQueryable = productQueryable.Skip(start).Take(limit.Value);
            }

            return(productQueryable.ToList());
        }
예제 #7
0
        public List <ProductModels> GetProductList(int?page, int?limit, string sortBy, string direction, string searchString, string idCategory, string idSubCategory, string idTamañoMascota, out int total)
        {
            try
            {
                int category      = 0;
                int subCategory   = 0;
                int tamañoMascota = 0;

                var map = new List <ProductModels>();

                map = MapProduct();

                if (!String.IsNullOrEmpty(idCategory) && idCategory != "0")
                {
                    category = Convert.ToInt16(idCategory);
                    map      = map.Where(x => x.IdCategory == category).ToList();
                }

                if (!String.IsNullOrEmpty(idSubCategory) && idSubCategory != "0")
                {
                    subCategory = Convert.ToInt16(idSubCategory);
                    map         = map.Where(x => x.IdSubCategory == subCategory).ToList();
                }

                if (!String.IsNullOrEmpty(idTamañoMascota) && idTamañoMascota != "0")
                {
                    tamañoMascota = Convert.ToInt16(idTamañoMascota);
                    map           = map.Where(x => x.IdTamanoMascota == tamañoMascota).ToList();
                }

                if (!string.IsNullOrWhiteSpace(searchString))
                {
                    map = GetProductListQuery(map, searchString);
                }

                total = map.Count();


                var productQueryable = map.AsQueryable();


                if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction))
                {
                    if (direction.Trim().ToLower() == "asc")
                    {
                        productQueryable = SortHelper.OrderBy(productQueryable, sortBy);
                    }
                    else
                    {
                        productQueryable = SortHelper.OrderByDescending(productQueryable, sortBy);
                    }
                }
                if (page.HasValue && limit.HasValue)
                {
                    int start = (page.Value - 1) * limit.Value;
                    productQueryable = productQueryable.Skip(start).Take(limit.Value);
                }

                return(productQueryable.ToList());
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }