public ActionResult Create(LoanerViewModel loanerViewModel) { try { var Component = _componentRepository.GetByID(loanerViewModel.Id); loanerViewModel.Id = 0; Component.Loaner = Mapper.Map<LoanerModel>(loanerViewModel); _componentRepository.Update(Component); //_loanerRepository.Insert(Mapper.Map<LoanerModel>(loanerViewModel)); return RedirectToAction("Index","Component"); } catch { return View(); } }
public ActionResult Delete(int id, LoanerViewModel model) { try { var vm = _componentRepository.Get(x => x.Loaner.Id == id).First(); vm.Loaner = null; vm.LoanerId = null; _componentRepository.Update(vm); _loanerRepository.Delete(Mapper.Map<LoanerModel>(model)); // TODO: Add delete logic here return RedirectToAction("Index","Component"); } catch { return View(); } }
// GET: Loaner/Create public ActionResult Create(int id) { var vm = new LoanerViewModel(){Id = id}; return View(vm); }
public ActionResult Edit(int id, LoanerViewModel loanerViewModel) { try { _loanerRepository.Update(Mapper.Map<LoanerModel>(loanerViewModel)); // TODO: Add update logic here return RedirectToAction("Index","Component"); } catch { return View(); } }