public ActionResult Create(MeetingCreateViewModel model) { model.Creator = UserRepository.Get(Convert.ToInt32(User.Identity.GetUserId())); if (ModelState.IsValid) { bool timesAdded = false; Meeting meeting = new Meeting(); meeting.Creator = model.Creator; meeting.Description = model.Description; meeting.Title = model.Title; meeting.Invitations = new HashSet <Invitation>(); meeting.Times = new HashSet <Time>(); int id = MeetingRepository.Add(meeting); if (id != 0) { foreach (string stringDate in model.Dates) { Time newDate = new Time(); DateTime dateAndTime = new DateTime(); if (DateTime.TryParse(stringDate, out dateAndTime)) { newDate.Date = dateAndTime; newDate.Meeting = MeetingRepository.Get(id); if (TimeRepository.add(newDate) != 0) { timesAdded = true; } } } if (timesAdded) { return(RedirectToAction("Profile", new { id = id })); } } } return(View()); }