private void AddUsersToPositions(Event dbEvent) { if (dbEvent.Positions.Count == 0) { foreach (var position in dbEvent.Sport.Positions) { var newPos = new EventAttendeesToBeApproved(); newPos.Position = new Position(); newPos.PositionId = position.Id; newPos.Position.Id = position.Id; newPos.Position.Name = position.Name; dbEvent.Positions.Add(newPos); } } var atendees = attendanceService.GetAllEventAttendeesForEvent(dbEvent.Id).ToList(); foreach (var atendee in atendees) { var position = dbEvent.Positions.First(p => p.PositionId == atendee.PositionId); position.Position.EventAttendees.Add(atendee); } var atendeesForAprooving = attendanceService.GetAllEventAttendeesToBeApprovedForEvent(dbEvent.Id).ToList(); foreach (var atendee in atendeesForAprooving) { var position = dbEvent.Positions.First(p => p.PositionId == atendee.PositionId); position.Position.EventAttendeesToBeApproved.Add(atendee); } }
public IActionResult JoinUser(IDictionary <string, string> rv) { int eventId = int.Parse(rv["eventId"]); int positionId = int.Parse(rv["positionId"]); string joinID = this.userManager.GetUserId(User); if (!attendanceService.GetAllEventAttendeesForEvent(eventId).Any(a => a.UserId == joinID)) { attendanceService.RegisterUserForEvent(joinID, eventId, positionId).Wait(); } return(RedirectToAction("HomePageView", "HomePage")); }
public IActionResult JoinUser(JoinUserModel model) { int eventId = model.EventId; int positionId = model.PositionId; string joinId = this.userManager.GetUserId(User); if (!attendanceService.GetAllEventAttendeesForEvent(eventId).Any(a => a.UserId == joinId)) { attendanceService.RegisterUserForEvent(joinId, eventId, positionId).Wait(); } return(RedirectToAction("DetermineEventView", "HomePage", new { Id = eventId })); }