Ejemplo n.º 1
0
        // GET: Component/Create
        public ActionResult Create(int id)
        {
            var vm = new ComponentViewModel();
            vm.ComponentCategoryId = id;

            return View(vm);
        }
Ejemplo n.º 2
0
        public ActionResult Create(ComponentViewModel model)
        {
            try
            {

                var category = _componentCategoryRepo.GetByID(model.ComponentCategoryId);
                if(category.Components == null)
                    category.Components = new List<ComponentModel>();
                category.Components.Add(Mapper.Map<ComponentModel>(model));
                _componentCategoryRepo.Update(category);
                //_componentRepo.Insert(Mapper.Map<ComponentModel>(model));

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }