public ActionResult ListAdmin(int page = 1, string sort = "Nombre", string sortdir = "asc", string tiendaid = "")
        {
            int pageSize    = 5;
            int totalRecord = 0;

            if (page < 1)
            {
                page = 1;
            }
            int skip = (page * pageSize) - pageSize;
            var data = GetMascotas(tiendaid, sort, sortdir, skip, pageSize, out totalRecord);

            ViewBag.TotalRows = totalRecord;
            //ViewBag.search = search;

            var model = new HomeClientViewModel();

            model.MascotasModel.LoadModelList(data);

            if (sort != null)
            {
                if (sortdir.ToLower() == "asc")
                {
                    model.MascotasModel.ToGrid = model.MascotasModel.ToGrid.OrderBy(x => GetPropertyValue(x, sort)).Skip(skip).Take(pageSize).ToList();
                }
                else
                {
                    model.MascotasModel.ToGrid = model.MascotasModel.ToGrid.OrderByDescending(x => GetPropertyValue(x, sort)).Skip(skip).Take(pageSize).ToList();
                }
            }

            ViewBag.TiendaId = new SelectList(db.Tiendas, "Id", "Nombre", tiendaid);

            return(View(model));
        }
Example #2
0
        // GET: client/home
        public ActionResult index(HomeClientViewModel homeViewModel)
        {
            try
            {
                homeViewModel.ProductsBestSelling = productService.GetBestSelling();
                if (homeViewModel.ProductsBestSelling != null && homeViewModel.ProductsBestSelling.Count > 0)
                {
                    for (int i = 0; i < homeViewModel.ProductsBestSelling.Count; i++)
                    {
                        homeViewModel.ProductsBestSelling[i].Variants = variantService.GetByProductID(homeViewModel.ProductsBestSelling[i].ProductID);
                        homeViewModel.ProductsBestSelling[i].Images   = imageService.GetByProductID(homeViewModel.ProductsBestSelling[i].ProductID);
                    }
                }
                homeViewModel.ProductsCreateDESC = productService.GetAll("CreatedDateTime");
                if (homeViewModel.ProductsCreateDESC != null && homeViewModel.ProductsCreateDESC.Count > 0)
                {
                    for (int i = 0; i < homeViewModel.ProductsCreateDESC.Count; i++)
                    {
                        homeViewModel.ProductsCreateDESC[i].Variants = variantService.GetByProductID(homeViewModel.ProductsCreateDESC[i].ProductID);
                        homeViewModel.ProductsCreateDESC[i].Images   = imageService.GetByProductID(homeViewModel.ProductsCreateDESC[i].ProductID);
                    }
                }
                List <CollectionProduct> collectionProducts = collectionProductService.GetByCollectionID(Common.CollectionID_DiscountPrice);
                if (collectionProducts != null && collectionProducts.Count > 0)
                {
                    homeViewModel.ProductsDiscountPrice = new List <Product>();
                    foreach (var item in collectionProducts)
                    {
                        Product product = productService.GetByPrimaryKey(item.ProductID);
                        homeViewModel.ProductsDiscountPrice.Add(product);
                    }
                }
                if (homeViewModel.ProductsDiscountPrice != null && homeViewModel.ProductsDiscountPrice.Count > 0)
                {
                    for (int i = 0; i < homeViewModel.ProductsDiscountPrice.Count; i++)
                    {
                        homeViewModel.ProductsDiscountPrice[i].Variants = variantService.GetByProductID(homeViewModel.ProductsDiscountPrice[i].ProductID);
                        homeViewModel.ProductsDiscountPrice[i].Images   = imageService.GetByProductID(homeViewModel.ProductsDiscountPrice[i].ProductID);
                    }
                }
            }
            catch (Exception ex)
            {
                LogService.WriteException(ex);
            }

            return(View(homeViewModel));
        }
Example #3
0
        public ActionResult HomeClient(int page = 1, string sort = "Nombre", string sortdir = "asc", string search = "", string searchoperator = "igual", int numtareas = -1)
        {
            ViewBag.Message = "Bienvenido estimado cliente.";

            int pageSize    = 5;
            int totalRecord = 0;

            if (page < 1)
            {
                page = 1;
            }
            int skip = (page * pageSize) - pageSize;
            var data = GetMascotas(search, numtareas, searchoperator, sort, sortdir, skip, pageSize, out totalRecord);

            ViewBag.TotalRows = totalRecord;
            ViewBag.search    = search;
            ViewBag.numtareas = numtareas < 0 ? "" : numtareas.ToString();

            var model = new HomeClientViewModel();

            model.Cliente = db.Users.First();
            model.MascotasModel.LoadModelList(data);

            if (sort != null)
            {
                if (sortdir.ToLower() == "asc")
                {
                    model.MascotasModel.ToGrid = model.MascotasModel.ToGrid.OrderBy(x => GetPropertyValue(x, sort)).Skip(skip).Take(pageSize).ToList();
                }
                else
                {
                    model.MascotasModel.ToGrid = model.MascotasModel.ToGrid.OrderByDescending(x => GetPropertyValue(x, sort)).Skip(skip).Take(pageSize).ToList();
                }
            }
            model.TotalPagarHoy = (from tarea in db.TareasMascotas where tarea.Fecha_ejec == DateTime.Today select tarea.Tarea.Costo).Concat(new[] { 0 }).Sum(x => x);

            return(View(model));
        }