public ShowComponentsViewModel()
        {
            // I just want this here to be able to use LabelFor
            Component = new ComponentViewModel();

            Components = new List<ComponentViewModel>();
        }
Exemple #2
0
        public ShowComponentsViewModel()
        {
            // I just want this here to be able to use LabelFor
            Component = new ComponentViewModel();

            Components = new List <ComponentViewModel>();
        }
 public ActionResult AddComponent()
 {
     var result = new ComponentViewModel
     {
         AvailableTypes = AutoMapper.Mapper.Map<List<ComponentTypeViewModel>>(_typeRepo.Get())
     };
     return View(result);
 }
 public ActionResult AddComponent(ComponentViewModel model)
 {
     var newEntity = AutoMapper.Mapper.Map<Component>(model);
     _componentRepo.Insert(newEntity);
     return RedirectToAction("ShowComponents");
 }
 public ActionResult SearchComponent(ComponentViewModel model)
 {
     var comp = _componentRepo.Get().FirstOrDefault(x => x.ComponentNumber == model.ComponentNumber);
     var result = AutoMapper.Mapper.Map<ComponentViewModel>(comp);
     if (result != null)
     {
         return View("Details", result);
     }
     ViewBag.Message = "Component could not be found.";
     return RedirectToAction("Error");
 }
 public ActionResult EditComponent(ComponentViewModel model)
 {
     var updatedEntity = AutoMapper.Mapper.Map<Component>(model);
     _componentRepo.Update(updatedEntity);
     return RedirectToAction("ShowComponents");
 }