예제 #1
0
        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();
            }
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        // GET: Loaner/Create
        public ActionResult Create(int id)
        {
            var vm = new LoanerViewModel(){Id = id};

            return View(vm);
        }
예제 #4
0
        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();
            }
        }