Example #1
0
        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));
        }
Example #2
0
        public async Task <IActionResult> GetQueryFAQ(int deptId = 0)
        {
            if (deptId < 1)
            {
                return(null);
            }

            // Check for Dept Id
            if (!commonContext.DeptExists(deptId))
            {
                return(BadRequest("Invalid or Department doesn't exists."));
            }

            List <QueryFAQViewModel> faqList = new List <QueryFAQViewModel>();

            // Get QueryMasters of specific Dept
            List <QueryMaster> queryMasters = await queryContext.GetResolvedQuerysOfDeptAsync(deptId);

            if (queryMasters.Count > 0)
            {
                // From QueryAssign, get the Resolved assign
                foreach (QueryMaster qm in queryMasters)
                {
                    if (qm.QueryAssigns != null && (qm.QueryAssigns != null && qm.QueryAssigns.Count > 0))
                    {
                        QueryAssign qa = qm.QueryAssigns.OrderByDescending(q => q.ResponseDate).FirstOrDefault();
                        if (qa != null)
                        {
                            faqList.Add(new QueryFAQViewModel(deptId, qm.Message, qa.Message));
                        }
                    }
                }

                queryMasters = null;
                return(Ok(faqList));
            }
            else
            {
                return(NotFound("No Query's found for provided Department"));
            }
        }