public IActionResult Index() { var id = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier)?.Value); Users user = userDatabaseRepository.getUserById(id); user.listOfEvents = eventDatabaseRepository.getEventsByUserId(id); user.listOfDetails = paymentsDatabaseRepository.getPaymentsByUserId(id); return(View(user)); }
public IActionResult Registration(int eventId) { var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; int userId = int.Parse(id); var checkIfRegistered = eventDatabaseRepository.getEventsByUserId(userId); var check = checkIfRegistered.Any(x => x.eventId == eventId); if (User.IsInRole("user")) { if (!check) { var numberOfpositions = eventDatabaseRepository.getEventByEventId(eventId).numOfParticipants; if (numberOfpositions > 0) { eventDatabaseRepository.eventRegistration(userId, eventId); return(RedirectToAction("Index", new { message = "Successfully registered" })); } return(RedirectToAction("Index", new { message = "There are no positions left in this event" })); } return(RedirectToAction("Index", new { message = "Only members can register" })); } return(RedirectToAction("Index", new { message = "You are already registered to this event" })); }