public ActionResult AjaxAction(TrackSpendingViewModel2 viewModel2) { if (ModelState.IsValid) { if (viewModel2.Id == Guid.Empty) { //create var accountBook = new AccountBook() { Amounttt = viewModel2.Amounttt, Categoryyy = viewModel2.Categoryyy, Dateee = viewModel2.Dateee, Remarkkk = viewModel2.Remarkkk }; _trackSpendingService.Add(accountBook); _trackSpendingService.Save(); return(View("ForIndexChild", _trackSpendingService.GetAll())); } else { //edit _trackSpendingService.Edit(viewModel2); _trackSpendingService.Save(); return(View("ForIndexChild", _trackSpendingService.GetAll())); } } return(View("ForIndexChild")); }
// GET: Homework2 public ActionResult Index() { var model = new TrackSpendingViewModel2() { CategoryList = new SelectList(enumList.GetCategoryyyList(), "value", "name") }; return(View(model)); }
public void Edit(TrackSpendingViewModel2 viewModel2) { var oldData = _accountBookRep.GetSingle(x => x.Id == viewModel2.Id); if (oldData != null) { oldData.Amounttt = viewModel2.Amounttt; oldData.Categoryyy = viewModel2.Categoryyy; oldData.Dateee = viewModel2.Dateee; oldData.Remarkkk = viewModel2.Remarkkk; } }
public TrackSpendingViewModel2 GetSingle(Guid?guid) { var source = _accountBookRep.GetSingle(x => x.Id == guid); TrackSpendingViewModel2 resault = new TrackSpendingViewModel2 { Id = source.Id, Categoryyy = source.Categoryyy, Amounttt = source.Amounttt, Dateee = source.Dateee, Remarkkk = source.Remarkkk, }; return(resault); }