Beispiel #1
0
        public List <ChatMessagesDto> GetDoctorAndPatientAnswers(AnswerInputDto input)
        {
            List <ChatMessagesDto> Resultlist = new List <ChatMessagesDto>();

            var problemName = _doContext.Problems.FirstOrDefault(x => x.Id == input.ProblemId);

            if (problemName != null)
            {
                Resultlist.Add(new ChatMessagesDto()
                {
                    Id      = problemName == null ? 0 : problemName.Id,
                    Content = problemName == null ? "" : problemName.Title,
                    Type    = 1,
                    Pic     = "/static/hm/images/6.jpg"
                });
            }

            var querys = from answers in _doContext.Answers.ToList()
                         .Where(x => x.ProblemId == input.ProblemId)
                         join problems in _doContext.Problems.ToList()
                         on answers.ProblemId equals problems.Id
                         into JoinedEmpProblem
                         from problem in JoinedEmpProblem.DefaultIfEmpty()
                         select new ChatMessagesDto
            {
                Id      = answers.Id,
                Content = answers.Content,
                Type    = answers.Type,
                Pic     = answers.Type == 1? "/static/hm/images/6.jpg" : "/static/hm/images/yishen.jpg"
            };

            var list = querys.OrderBy(x => x.Id).ToList();

            Resultlist.AddRange(list);

            return(Resultlist);
        }
Beispiel #2
0
        public OutputList GetAnswers([FromBody] AnswerInput input)
        {
            var querys = from answers in _doContext.Answers.ToList()
                         join users in _doContext.Users.ToList() on answers.UserId equals users.Id
                         into JoinedEmpUser
                         from user in JoinedEmpUser.DefaultIfEmpty()
                         join problems in _doContext.Problems.ToList()
                         .Where(x => x.Id == input.ProbliemId)
                         on answers.ProblemId equals problems.Id
                         into JoinedEmpProblem
                         from problem in JoinedEmpProblem.DefaultIfEmpty()
                         select new ProblemListDto
            {
                Id        = answers.Id,
                Title     = problem == null ? "" : problem.Title,
                Info      = answers.Content,
                Another   = user == null ? "" : user.UserName,
                UserId    = user == null ? 0 : user.Id,
                ProblemId = problem == null ? 0 : problem.Id,
            };


            var totel = querys.Count();

            querys = querys.Where(x => x.ProblemId == input.ProbliemId);

            var result = _mapper.Map <List <ProblemListDto> >(querys);

            OutputList outputList = new OutputList
            {
                Totel = totel,
                Data  = result
            };

            return(outputList);
        }