public async Task <ActionResult <Event> > GetHelpAsInterviewer(int interviewerID, string choice) { var interviewers = _context.Interviewer.ToArray(); var interviewer = interviewers.First(i => i.UserID.Equals(interviewerID)); if (choice == "come") { var booths = _context.Booth.ToArray(); var boothLink = booths.First(b => b.InterviewerID.Equals(interviewer.UserID)).Payload; var notificationsController = new NotificationsController(_context); var notificationRequest = new NotificationRequest { RequestRole = "Event Organiser", RequesterID = interviewerID, Message = interviewer.Name + " has requested help in their room", Payload = boothLink }; await notificationsController.PostNotification(notificationRequest); return(Ok()); } if (choice == "go") { var events = _context.Event.ToArray(); var helpLink = events.First(e => e.EventID.Equals(interviewer.EventID))?.HelpLink; if (helpLink == null) { return(NotFound()); } return(Ok(helpLink)); } return(BadRequest()); }
public async Task <ActionResult <Event> > GetHelpAsUser(int userID) { var user = await _context.User.FindAsync(userID); if (user != null) { NotificationsController notificationsController = new NotificationsController(_context); NotificationRequest notificationRequest = new NotificationRequest { RequestRole = "Event Organiser", RequesterID = userID, Message = $"{user.Name} has requested help in their room", Payload = string.Empty }; await notificationsController.PostNotification(notificationRequest); return(Ok()); } return(NotFound()); }