public static EmployeeWithComment GetDoctor(string docId)
        {
            string sqlStr = string.Format(
                @"select employee.avatar_path, identity.name, identity.sex, employee.clinic_name, employee.post, employee.profile
                  from employee natural join identity
                  where employee.employee_id = '{0}'", docId);
            OracleCommand       cmd = new OracleCommand(sqlStr, DatabaseHelper.GetInstance().conn);
            EmployeeWithComment employeeWithComment = new EmployeeWithComment();

            try
            {
                OracleDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    employeeWithComment.pic_url = reader[0].ToString();
                    employeeWithComment.name    = reader[1].ToString();
                    employeeWithComment.sex     = reader[2].ToString();
                    employeeWithComment.clinic  = reader[3].ToString();
                    employeeWithComment.post    = reader[4].ToString();
                    employeeWithComment.profile = reader[5].ToString();
                    return(employeeWithComment);
                }
                return(null);
            }
            catch (Exception e)
            {
                return(null);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage GetSingleEmployee(string employeeId)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            EmployeeWithComment employeeWithComment = PatientHelper.GetDoctor(employeeId);

            if (employeeWithComment == null)
            {
                response.Content    = new StringContent("未找到医生");
                response.StatusCode = HttpStatusCode.NotFound;
            }
            else
            {
                employeeWithComment.comment = PatientHelper.GetCommentByDocId(employeeId);
                if (employeeWithComment.comment == null)
                {
                    response.Content    = new StringContent("查询失败");
                    response.StatusCode = HttpStatusCode.NotFound;
                }
                else if (employeeWithComment.comment.Count == 0)
                {
                    response.Content    = new StringContent("评论列表空");
                    response.StatusCode = HttpStatusCode.OK;
                }
                else
                {
                    response.Content    = new StringContent(JsonObjectConverter.ObjectToJson(employeeWithComment));
                    response.StatusCode = HttpStatusCode.OK;
                }
            }

            return(response);
        }