Example #1
0
        // GET: Component/Create
        public ActionResult Create(int id)
        {
            var vm = new ComponentUploadViewModel();
            vm.ComponentCategoryId = id;

            return View(vm);
        }
Example #2
0
        public ActionResult Create(ComponentUploadViewModel 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();
            }
        }
Example #3
0
        public ActionResult Edit(int id, ComponentUploadViewModel model)
        {
            try
            {
                _componentRepo.Update(Mapper.Map<ComponentModel>(model));

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