public AnnouncementQnAQueryResult GetAnnouncementQnA(AnnouncementQnAQuery announcementQnAQuery)
        {
            var qnas = AnnouncementQnAStorage.GetData().Select(x => x.Value);

            if (announcementQnAQuery.Id.HasValue)
            {
                qnas = qnas.Where(x => x.Id == announcementQnAQuery.Id);
            }
            if (announcementQnAQuery.AskerId.HasValue)
            {
                qnas = qnas.Where(x => x.AskerRef == announcementQnAQuery.AskerId);
            }


            if (announcementQnAQuery.AnnouncementId.HasValue)
            {
                qnas = qnas.Where(x => x.AnnouncementRef == announcementQnAQuery.AnnouncementId);
            }

            if (announcementQnAQuery.AnswererId.HasValue)
            {
                //TODO : implement this later
                //var announcementQnAComplexs = qnas as IList<AnnouncementQnAComplex> ?? qnas.ToList();
                //var announcementIds = announcementQnAComplexs.Select(x => x.AnnouncementRef);
                //var personIds = announcementIds.Select(annId => ServiceLocator.AnnouncementService.GetAnnouncementById(annId))
                //    .Select(announcement => announcement.PrimaryTeacherRef).ToList();
                //qnas = announcementQnAComplexs.Where(x => personIds.Contains(x.AskerRef));
            }

            return(new AnnouncementQnAQueryResult
            {
                AnnouncementQnAs = qnas.ToList(),
                Query = announcementQnAQuery
            });
        }
        public IList <AnnouncementQnAComplex> GetAnnouncementQnAs(int announcementId)
        {
            var query = new AnnouncementQnAQuery {
                AnnouncementId = announcementId
            };

            return(GetAnnouncmentQnAs(query).AnnouncementQnAs);
        }
        private AnnouncementQnAQueryResult GetAnnouncmentQnAs(AnnouncementQnAQuery query)
        {
            if (!(Context.PersonId.HasValue && Context.SchoolLocalId.HasValue))
            {
                throw new UnassignedUserException();
            }

            query.CallerId = Context.PersonId;
            query.SchoolId = Context.SchoolLocalId.Value;
            using (var uow = Read())
            {
                return(new AnnouncementQnADataAccess(uow).GetAnnouncementQnA(query));
            }
        }
Example #4
0
        public AnnouncementQnAQueryResult GetAnnouncementQnA(AnnouncementQnAQuery query)
        {
            var parameter = new Dictionary <string, object>
            {
                { ANNOUNCEMENT_QNA_ID_PARAM, query.Id },
                { ANNOUNCEMENT_ID_PARAM, query.AnnouncementId },
                { ASKER_ID_PARAM, query.AskerId },
                { ANSWERER_ID_PARAM, query.AnswererId },
                { CALLER_ID_PARAM, query.CallerId },
                { SCHOOL_ID_PARAM, query.SchoolId }
            };

            using (var reader = ExecuteStoredProcedureReader(GET_ANNOUNCEMENT_QNA_PROCEDURE, parameter))
            {
                var res = ReadAnnouncementQnAComplexes(reader);
                return(new AnnouncementQnAQueryResult
                {
                    AnnouncementQnAs = res,
                    Query = query
                });
            }
        }
 private AnnouncementQnAQueryResult GetAnnouncmentQnAs(AnnouncementQnAQuery query)
 {
     query.CallerId = Context.PersonId;
     return(GetAnnouncementQnA(query));
 }