Engage.Survey.Entities.SurveyRepository.GetModuleIdForSurvey C# (CSharp) Method

GetModuleIdForSurvey() public method

Gets the ID of the module that the given survey belongs to.
public GetModuleIdForSurvey ( int surveyId ) : int
surveyId int The survey's ID.
return int
        public int GetModuleIdForSurvey(int surveyId)
        {
            var moduleId = (from survey in this.Context.Surveys
                            where survey.SurveyId == surveyId
                            select survey.ModuleId).SingleOrDefault();

            return moduleId == default(int) ? Null.NullInteger : moduleId;
        }

Usage Example

        public void DeleteSurvey(int surveyId)
        {
            var surveyRepository = new SurveyRepository();
            var moduleId = surveyRepository.GetModuleIdForSurvey(surveyId);
            if (!this.CanEditModule(moduleId))
            {
                this.DenyAccess();
            }

            surveyRepository.DeleteSurvey(surveyId, moduleId);
        }
All Usage Examples Of Engage.Survey.Entities.SurveyRepository::GetModuleIdForSurvey