public ActionResult Create(UserViewModel userViewModel) { var isViewValid = userViewModel.Validate(); if (isViewValid) { return RedirectToAction("List"); } else { ModelState.AddModelError("_FORM", "Opa! Deu erro!"); return View(); } }
public ActionResult List(UserViewModel viewModel) { var users = new GenericService<User>(new GenericRepository<User>(new NHibernateRepositoryContext())).Select(null, viewModel.MyGrid); viewModel.MyGrid.Columns = GridColumn.Create("Name", "Nome completo", "Salary", "Salário", "BirthDate", "Data de nascimento"); viewModel.MyGrid.DataSource = users; viewModel.MyGrid.DataBind(); var blogs = new GenericService<WebLog>(new GenericRepository<WebLog>(new NHibernateRepositoryContext())).Select(null, viewModel.MyGrid2); viewModel.MyGrid2.Columns = GridColumn.Create("Title", "Título", "Creator", "Criador", "CreatedAt", "Criado em"); viewModel.MyGrid2.DataSource = blogs; viewModel.MyGrid2.DataBind(); return View("List", viewModel); }