public Survey GetSurveyByTenantAndSlugName(string tenant, string slugName, bool getQuestions) { Func <Survey> resolver = () => { var surveyRow = GetSurveyRowByTenantAndSlugName(this.surveyTable, tenant, slugName); if (surveyRow == null) { return(null); } var survey = new Survey(surveyRow.SlugName) { Tenant = surveyRow.PartitionKey, Title = surveyRow.Title, CreatedOn = surveyRow.CreatedOn, UserDefinedFields = surveyRow.UserDefinedFields }; if (getQuestions) { var surveyQuestionRows = GetSurveyQuestionRowsByTenantAndSlugName(this.questionTable, tenant, slugName); foreach (var questionRow in surveyQuestionRows) { survey.Questions.Add( new Question { Text = questionRow.Text, Type = (QuestionType)Enum.Parse(typeof(QuestionType), questionRow.Type), PossibleAnswers = questionRow.PossibleAnswers }); } } return(survey); }; return(this.CacheEnabled ? TenantCacheHelper.GetFromCache(tenant, slugName, resolver) : resolver()); }
public Tenant GetTenant(string tenant) { Func<Tenant> resolver = () => this.tenantBlobContainer.Get(tenant.ToLowerInvariant()); return this.CacheEnabled ? TenantCacheHelper.GetFromCache(tenant, TenantAccountTag, resolver) : resolver(); }