Exemplo n.º 1
0
        public async Task <HttpResponseMessage> Save(SurveySave survey)
        {
            if (survey == null || survey.Answers == null || survey.Answers.Count == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            var userId    = base.AuthenticatedUser.Id;
            var surveyDTO = Mapper.Map <SurveySaveDTO>(survey);

            var validation = this.surveyService.ValidateSave(userId, surveyDTO);

            if (validation.AlreadyCompleted)
            {
                return(Request.CreateResponse(HttpStatusCode.Conflict));
            }

            if (validation.ContentChanged)
            {
                return(Request.CreateResponse(HttpStatusCode.ResetContent));
            }

            this.surveyService.SaveSurvey(userId, surveyDTO);

            await OneSignalProvider.NotifyMobileDevices(
                "SURVEY-RESULTS-UPDATED",
                "Survey results updated.",
                "The survey's results has been posted recently, please reaload your content.");

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> Notify()
        {
            await OneSignalProvider.NotifyMobileDevices(
                "SURVEY-CHANGED",
                "Survey updated.",
                "The survey has been updated recently, please reaload your content.");

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Exemplo n.º 3
0
        public async Task <HttpResponseMessage> Reset()
        {
            this.surveyService.Reset();

            await OneSignalProvider.NotifyMobileDevices(
                "SURVEY-RESTART",
                "Survey reseted.",
                "The survey has been reseted recently, please reaload your content.");

            return(Request.CreateResponse(HttpStatusCode.OK));
        }