コード例 #1
0
        public BaseController()
        {
            var app        = new ServiceReference.ContractClient();
            var categories = app.GetAllCategories().Where(x => x.Enabled);

            var model = new List <CategoryViewModel>();

            foreach (var c in categories)
            {
                var cat = new CategoryViewModel
                {
                    Id       = c.Id,
                    Name     = c.Name,
                    Level    = c.Level,
                    Parent   = c.ParentId,
                    IsEnable = c.Enabled
                };
                cat.CountChildren = categories.Count(x => x.ParentId == cat.Id && x.Level == 1);
                model.Add(cat);
            }

            var imageFolder = ConfigurationManager.AppSettings["imageFolder"];

            ViewBag.imageFolder = imageFolder;
            ViewBag.LayoutModel = model;
        }
コード例 #2
0
        public ActionResult Add()
        {
            var app = new ServiceReference.ContractClient();

            var model         = new ProductViewModel();
            var completeModel = new ProductEditViewModel();

            completeModel.Product = model;
            var categoriesClient = app.GetAllCategories();

            completeModel.Categories = categoriesClient.Select(x => new CategoryViewModel(x)).ToList();

            foreach (var c in completeModel.Categories)
            {
                c.Children = completeModel.Categories.Where(x => x.ParentId == c.Id).ToList();
            }
            var staticList = new List <KeyValuePair <int, string> >();

            staticList.Add(new KeyValuePair <int, string>(1, "Cantidad Fija"));
            staticList.Add(new KeyValuePair <int, string>(1, "Cantidad Ilimitada"));
            staticList.Add(new KeyValuePair <int, string>(1, "Disponible en 24 hs"));


            completeModel.Inventory = staticList;
            return(View(completeModel));
        }
コード例 #3
0
        public ActionResult Edit(int id)
        {
            var app           = new ServiceReference.ContractClient();
            var productClient = app.GetProductById(id);

            var model = new ProductViewModel
            {
                Id          = productClient.Id,
                Name        = productClient.Name,
                Description = productClient.Description,
                Enabled     = productClient.Enabled,
                IsOffer     = productClient.IsOffer,
                Percent     = productClient.Percent,
                Price       = productClient.Price,
                StartDay    = productClient.StartDay,
                EndDay      = productClient.EndDay,
                Warranty    = productClient.Warranty,
                Brant       = productClient.Brant,
                Images      = productClient.Image,
                CategoryId  = productClient.CategoryId,
                TypeStock   = productClient.TypeStock,
                Stock       = productClient.Stock,
            };

            model.Feature = app.GetFeatureByProductId(model.Id).Select(x => new FeatureViewModel
            {
                Id = x.Id, Description = x.Description, Name = x.Name
            }).ToList();

            model.Images = app.GetImageByProductId(id);
            if (model.Images == null)
            {
                model.Images = new List <ServiceReference.Image>();
            }
            var completeModel = new ProductEditViewModel();

            completeModel.Product = model;
            var categoriesClient = app.GetAllCategories();

            completeModel.Categories = categoriesClient.Select(x => new CategoryViewModel(x)).ToList();

            foreach (var c in completeModel.Categories)
            {
                c.Children = completeModel.Categories.Where(x => x.ParentId == c.Id).ToList();
            }

            var staticList = new List <KeyValuePair <int, string> >();

            staticList.Add(new KeyValuePair <int, string>(1, "Cantidad Fija"));
            staticList.Add(new KeyValuePair <int, string>(1, "Cantidad Ilimitada"));
            staticList.Add(new KeyValuePair <int, string>(1, "Disponible en 24 hs"));


            completeModel.Inventory = staticList;
            return(View(completeModel));
        }
コード例 #4
0
        public ActionResult Add()
        {
            var app = new ServiceReference.ContractClient();

            var model = new CategoryViewModel();
            //obtenemso todas las categorias
            var categoriesClient = app.GetAllCategories();

            //de todas las categorias, tomamos solo las padre y por cada una generamos un categoryviewmodel
            var completeModel = categoriesClient.Where(x => x.Level == 0).Select(x => new CategoryViewModel(x)).ToList();

            model.ParentCategories = completeModel;

            return(View(model));
        }
コード例 #5
0
        public ActionResult Edit(int id)
        {
            var app            = new ServiceReference.ContractClient();
            var categoryClient = app.GetCategoryById(id);

            var model = new CategoryViewModel
            {
                Id          = categoryClient.Id,
                Name        = categoryClient.Name,
                Description = categoryClient.Description,
                Level       = categoryClient.Level,
                ParentId    = categoryClient.ParentId,
                Enabled     = categoryClient.Enabled
            };
            //obtenemso todas las categorias
            var categoriesClient = app.GetAllCategories();

            //de todas las categorias, tomamos solo las padre y por cada una generamos un categoryviewmodel
            var completeModel = categoriesClient.Where(x => x.Level == 0).Select(x => new CategoryViewModel(x)).ToList();

            model.ParentCategories = completeModel;
            return(View(model));
        }
コード例 #6
0
        public ActionResult GetAll()
        {
            var app        = new ServiceReference.ContractClient();
            var categories = app.GetAllCategories();

            var model = new List <CategoryViewModel>();

            foreach (var c in categories)
            {
                var cat = new CategoryViewModel
                {
                    Id          = c.Id,
                    Name        = c.Name,
                    Description = c.Description,
                    Enabled     = c.Enabled,
                    Level       = c.Level,
                    ParentId    = c.ParentId,
                };
                model.Add(cat);
            }

            return(View(model));
        }