예제 #1
0
        public async Task <ActionResult> UpdateSurvey(int id, [FromBody] SurveyOptionsViewModel soptions)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                DAL.Models.Survey surveyobj = new DAL.Models.Survey();
                surveyobj.SurveyId          = id;
                surveyobj.Survey_Name       = soptions.survey_Name;
                surveyobj.Survey_Active     = soptions.survey_Active;
                surveyobj.CalAddressScore   = soptions.CalAddressScore;
                surveyobj.CalSocialScore    = soptions.CalSocialScore;
                surveyobj.CalTwoFactorScore = soptions.CalTwoFactorScore;
                surveyobj.CalAgeScore       = soptions.CalAgeScore;
                var status = await _unitOfWork.SurveyRepository.UpdateSurveyAsync(surveyobj);

                if (!status)
                {
                    return(BadRequest());
                }
                return(Ok());
            }
            catch (Exception exp)
            {
                _logger.LogError(exp.Message);
                return(BadRequest());
            }
        }
예제 #2
0
        // [ValidateAntiForgeryToken]

        public async Task <ActionResult> CreateSurvey([FromBody] SurveyOptionsViewModel soptions)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                DAL.Models.Survey CalSurvey = new DAL.Models.Survey();
                CalSurvey.Survey_Name       = soptions.survey_Name;
                CalSurvey.Survey_Active     = soptions.survey_Active;
                CalSurvey.CalAddressScore   = soptions.CalAddressScore;
                CalSurvey.CalSocialScore    = soptions.CalSocialScore;
                CalSurvey.CalTwoFactorScore = soptions.CalTwoFactorScore;
                CalSurvey.CalAgeScore       = soptions.CalAgeScore;
                var newSurvey = await _unitOfWork.SurveyRepository.InsertSurveyAsync(CalSurvey);

                if (CalSurvey == null)
                {
                    return(BadRequest("Itsnull"));
                }
                return(Ok());
                // return CreatedAtRoute("GetCustomerRoute", new { id = newSurvey.SurveyId });
            }
            catch (Exception exp)
            {
                _logger.LogError(exp.Message);
                return(BadRequest(exp.Message));
            }
        }
예제 #3
0
        //-------------------------------------------------------------------------------------------------------------------------



        //--------------------------------------------------------------------------------------------------------------------------

        public void storetoDB(ViewModels.ParticipantViewModel Participantvalues, ScoreModel score, GeoLocProps geo, UserAgent.UserAgent useragent, MapPoint mapCoords)
        {
            ParticipantDBViewModel dbModel = CertifyParticipant.storingtoDB(Participantvalues, score, geo, useragent, mapCoords);

            Participant participant = Mapper.Map <Participant>(dbModel);


            SurveyOptionsDBModel surveymodel = CalculateScore.getthesurveyObject();

            DAL.Models.Survey surveydal = new DAL.Models.Survey();
            //defining the survey object
            surveydal.Survey_Name       = surveymodel.Survey_Name;
            surveydal.Survey_Active     = surveymodel.Survey_Active;
            surveydal.SurveyId          = surveymodel.SurveyId;
            surveydal.CalAddressScore   = surveymodel.CalAddressScore;
            surveydal.CalAgeScore       = surveymodel.CalAgeScore;
            surveydal.CalSocialScore    = surveymodel.CalSocialScore;
            surveydal.CalTwoFactorScore = surveymodel.CalTwoFactorScore;

            _unitOfWork.ParticipantRepository.InsertSurveyParticipant(participant);

            _unitOfWork.ParticipantRepository.InsertSurveyParticipantTable(participant, surveydal);
        }