示例#1
0
        public IActionResult Edit(string id)
        {
            var categoryInput = new CategoryInput();
            var category      = _categoriesViewModel.Service.GetById(id);

            categoryInput.Set(category);
            return(View("~/Views/AdminPanel/Categories/Edit.cshtml", categoryInput));
        }
示例#2
0
        public IActionResult Create(CategoryInput category)
        {
            var specs = JsonConvert.DeserializeObject <Dictionary <string, string> >(category.specStr);

            var newCategory = new Category()
            {
                Id    = category.Id,
                Name  = category.Name,
                Image = category.Image,
                Specs = specs.Values.ToList()
            };

            _categoriesViewModel.Service.Create(newCategory);

            return(RedirectToAction("Index"));
        }
示例#3
0
        public IActionResult Edit(CategoryInput category)
        {
            var specs = JsonConvert.DeserializeObject <Dictionary <string, string> >(category.specStr);

            var newCategory = new Category()
            {
                Id    = category.Id,
                Name  = category.Name,
                Image = category.Image,
                Specs = specs.Values.ToList()
            };


            _categoriesViewModel.Service.Update(newCategory);

            return(View("~/Views/AdminPanel/Categories/Index.cshtml", _categoriesViewModel));
        }