public ActionResult Index(CreateGroupViewModel model) { var chosenPlace = this.Db.PlaceRepository.All().FirstOrDefault(x => x.Name == model.PlacePlaceholder); var userId = User.Identity.GetUserId(); var user = this.Db.UsersRepository.All().FirstOrDefault(x => x.Id == userId); var newGroup = new HungryGroup { Creator = user, Place = chosenPlace, StartingTime = model.StartingTime, EatTime = chosenPlace.EatTime }; this.Db.HungryGroupRepository.Add(newGroup); this.Db.SaveChanges(); return View(); }
public ActionResult CreateGroup(CreateGroupViewModel model) { if (!ModelState.IsValid) { return PartialView("_CreateGroupForm", model); } return View(); }