예제 #1
0
 /// <summary>
 /// Function that inserts a attendee into the attendance table
 /// </summary>
 /// <param name="eventId">Event id attendee is joining</param>
 /// <param name="userId">User id of the attendee</param>
 /// <returns>A string based on what happended</returns>
 public string JoinEvent(int eventId, string jwt)
 {
     var eventJoinedMessage = "Joined Event";
     var userID = _jWTService.GetUserIDFromToken(jwt);
     var hasClaims = _jWTService.CheckUserClaims(jwt, joinEventClaims);
     if(hasClaims.Equals("Authorized"))
     {
         var isEventandUserValid = _attendeeService.DoesEventandUserExist(eventId, userID);
         if (isEventandUserValid == false)
         {
             return eventJoinedMessage = "Event or User does not exist";
         }
         var doesAttendeeExist = _attendeeService.DoesAttendeeExist(eventId, userID);
         if (doesAttendeeExist)
         {
             return eventJoinedMessage = "You have already joined the event";
         }
         var attendeeJoined = _attendeeService.InsertAttendee(eventId, userID);
         if (attendeeJoined == false)
         {
             return eventJoinedMessage = "Uh Oh something went wrong";
         }
     }
     else
     {
         eventJoinedMessage = "Sorry you are not allowed to join events";
     }
     return eventJoinedMessage;
 }
예제 #2
0
 public HttpResponseMessage IsAttendee(int eventId, int userId)
 {
     try
     {
         var IsAttending = _attendeeService.DoesAttendeeExist(eventId, userId);
         if (IsAttending)
         {
             var httpResponse = new HttpResponseMessage(HttpStatusCode.OK)
             {
                 Content = new StringContent("true")
             };
             return(httpResponse);
         }
         var httpResponseFail = new HttpResponseMessage(HttpStatusCode.BadRequest)
         {
             Content = new StringContent("false")
         };
         return(httpResponseFail);
     }
     catch
     {
         //log
         var httpResponse = new HttpResponseMessage(HttpStatusCode.InternalServerError);
         return(httpResponse);
     }
 }