public async Task <IActionResult> GetSurveysForDept(int deptId = 0) { if (!commonContext.DeptExists(deptId)) { return(BadRequest("Invalid. Department Id doesn't exists !")); } List <Survey> surveys = await surveyContext.GetDepartmentSurveys(deptId); // Convert all Survey Ent to SurveyViewModels List <SurveyViewModel> surveyVMList = surveys.ConvertAll <SurveyViewModel>(s => new SurveyViewModel(s)); surveys = null; return(Ok(surveyVMList)); }