Ejemplo n.º 1
0
        public ActionResult Details(int id)
        {
            var product = _context.GetProduct(id);

            if (product != null)
            {
                ProductsItemsViewModel model = new ProductsItemsViewModel
                {
                    Name        = product.Name,
                    Discription = product.Discription,
                    Price       = product.Price,
                    ImagePath   = product.Image,
                    DateCreate  = product.CreateDate,
                    LastChange  = product.LastChange,
                    Category    = product.Categories.Select(x => new CategoriesItemViewModel
                    {
                        Discription = x.Discription,
                        Name        = x.Name
                    }).ToList(),
                    CategoryId   = product.Categories.Select(x => x.Id),
                    CategoryList = _context2.Get_All().Select
                                       (x => new SelectItemViewModel
                    {
                        Id   = x.Id,
                        Name = x.Name
                    }
                                       ).ToList()
                };

                return(View(model));
            }
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Category(string Category)
        {
            var model = category.Get_All().Select
                        (
                item => new CategoriesItemViewModel
            {
                Id          = item.Id,
                Discription = item.Discription,
                Name        = item.Name
            }
                        ).ToList();

            return(PartialView(model));
        }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            var model = _context.Get_All().Select
                        (
                item => new CategoriesItemViewModel
            {
                Id          = item.Id,
                Discription = item.Discription,
                Name        = item.Name,
                //Products = item.Products.Select
                //(
                //    x => new ProductsItemsViewModel
                //    {
                //        DateCreate = x.CreateDate,
                //        Discription = x.Discription,
                //        Id = x.Id,
                //        LastChange = x.LastChange,
                //        Name = x.Name,
                //        Price = x.Price
                //    }
                //).ToList()
            }
                        ).ToList();

            return(View(model));
        }