public ActionResult Index(HomePageViewModel homePageViewModel) { using (var session = this.dataContext.OpenSession()) { session.Store(homePageViewModel.NewUser); session.SaveChanges(); } return this.RedirectToAction("Index"); }
/// <summary> /// </summary> /// <returns> /// </returns> public ActionResult Index() { var vm = new HomePageViewModel { Users = this.GetAllUsers(), NewUser = new UserModel(), SearchResults = Enumerable.Empty<UserModel>() }; return this.View(vm); }
public ActionResult Search(string searchTerm) { IEnumerable<UserModel> users; int age; var isAgeSearch = int.TryParse(searchTerm, out age); using (var session = this.dataContext.OpenSession()) { users = from u in session.Query<UserModel>() where u.Name.StartsWith(searchTerm) || u.Name.EndsWith(searchTerm) || u.Tags.Any(x => x == searchTerm) || u.Age == age select u; } var vm = new HomePageViewModel { Users = this.GetAllUsers(), SearchResults = users }; return this.View("Index", vm); }