forked from MDCPS/DamageAssessment_Backend
		
	added active and in active survey endpoints
This commit is contained in:
		| @ -101,6 +101,43 @@ namespace DamageAssesment.Api.Surveys.Providers | ||||
|                 return SurveyStatus.INACTIVE.ToString(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Method to get surveys asynchronously with multi-language support | ||||
|         public async Task<(bool IsSuccess, IEnumerable<Models.MultiLanSurvey> Surveys, string ErrorMessage)> GetActiveSurveysAsync(bool IsActive,string language) | ||||
|         { | ||||
|             IEnumerable<Models.MultiLanSurvey> surveysList = null; | ||||
|             try | ||||
|             { | ||||
|                 string status = SurveyStatus.ACTIVE.ToString(); | ||||
|                 if(!IsActive) status = SurveyStatus.INACTIVE.ToString(); | ||||
|                 logger?.LogInformation("Get all Surveys from DB"); | ||||
|                 //checking is enabled in survey response  | ||||
|                 var surveys = await surveyDbContext.Surveys.ToListAsync();//Where(s => s.IsEnabled == true) | ||||
|  | ||||
|                 if (surveys != null) | ||||
|                 { | ||||
|                     surveysList = from s in surveys | ||||
|                                   select new Models.MultiLanSurvey | ||||
|                                   { | ||||
|                                       Id = s.Id, | ||||
|                                       StartDate = s.StartDate, | ||||
|                                       EndDate = s.EndDate, | ||||
|                                       IsEnabled = s.IsEnabled, | ||||
|                                       CreatedDate = s.CreatedDate, | ||||
|                                       Status = GetStatus(s.StartDate, s.EndDate), | ||||
|                                       Titles = CreateMultiLanguageObject(GetSurveyTranslations(s.Id, null, language)) | ||||
|                                   }; | ||||
|                     logger?.LogInformation($"{surveys.Count} Items(s) found"); | ||||
|                     return (true, surveysList.Where(a=>a.Status==status).OrderByDescending(a=>a.Id), null); | ||||
|                 } | ||||
|                 return (false, null, "Not found"); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger?.LogError(ex.ToString()); | ||||
|                 return (false, null, ex.Message); | ||||
|             } | ||||
|         } | ||||
|         // Method to get surveys asynchronously with multi-language support | ||||
|         public async Task<(bool IsSuccess, IEnumerable<Models.MultiLanSurvey> Surveys, string ErrorMessage)> GetSurveysAsync(string language) | ||||
|         { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user