Esempio n. 1
0
 private async void ProcessLogForIntervention(SubmissionRequest request)
 {
     using (InterventionController intervention = new InterventionController())
     {
         intervention.ProcessActivityEvent(
             EventCollectionControllerHelper.GetActivityEvent(
                 new EventPostRequest
         {
             AuthToken   = request.AuthToken,
             SubmitEvent = request.SubmitEvent
         }
                 ));
     }
 }
Esempio n. 2
0
        public HttpResponseMessage Post(EventPostRequest request)
        {
            var auth = new Authentication();

            if (!auth.IsValidKey(request.AuthToken))
            {
                return new HttpResponseMessage {
                           StatusCode = HttpStatusCode.Forbidden
                }
            }
            ;

            var log = EventCollectionControllerHelper.GetActivityEvent(request);

            log.SenderId = auth.GetActiveUserId(request.AuthToken);

            var result = Posts.SaveEvent(log);

            //For now we're only pushing these events to the hub
            if (log.EventType.ToString() == "AskForHelpEvent" || log.EventType.ToString() == "SubmitEvent")
            {
                //post to feed hub here.
                NotifyHub(result, log.SenderId, log.EventType.ToString(), log.CourseId ?? 0);
            }

            //we've processed the log, now process for intervention.
            ProcessLogForIntervention(log);


            //push suggestion changes (it will only do so if suggestions need refreshing)
            NotifyNewSuggestion(log.SenderId, log.CourseId ?? 0, request.AuthToken);

            return(new HttpResponseMessage
            {
                StatusCode = result > 0 ? HttpStatusCode.OK : HttpStatusCode.InternalServerError,
                Content = new StringContent(result.ToString())
            });
        }