コード例 #1
0
        public async Task <IActionResult> MenuE1InterfaceReportData([FromBody] ModelMenuE1_InterfaceReportData model)
        {
            var    requestUri = $"{_WebApiModel.BaseURL}/{"PrivateDocMenuE"}/{"MenuE1InterfaceReportData"}";
            string authHeader = HttpContext.Request?.Headers["Authorization"];

            if (authHeader != null && authHeader.StartsWith("Bearer"))
            {
                BearerToken = authHeader.Substring("Bearer ".Length).Trim();
            }
            var response = await HttpRequestFactory.Post(requestUri, BearerToken, model);

            switch (response.StatusCode)
            {
            case HttpStatusCode.Unauthorized:
                return(Unauthorized(response.ContentAsString()));

            case HttpStatusCode.BadRequest:
                return(BadRequest(response.ContentAsString()));

            case HttpStatusCode.OK:
                return(Ok(response.ContentAsString()));

            default:
                return(StatusCode(500));
            }
        }
コード例 #2
0
        public async Task <ModelMenuE1_InterfaceReportData> MenuE1InterfaceReportDataAsync(ModelMenuE1_InterfaceReportData search)
        {
            ModelMenuE1_InterfaceReportData resp = new ModelMenuE1_InterfaceReportData();

            resp.listfaculty = await GetAllFacultyAsync();

            resp.listreportdata = await GetAllReportDataE1Async(search);

            return(resp);
        }
コード例 #3
0
        private async Task <IList <ModelMenuE1Report> > GetAllReportDataE1Async(ModelMenuE1_InterfaceReportData search)
        {
            string sql = "SELECT A.*, " +
                         "B.name_thai as group_1_risk_human_name,  " +
                         "C.name_thai as group_1_risk_animal_name,  " +
                         "D.name_thai as group_1_pathogens_name,  " +
                         "E.name_thai as group_2_risk_human_name,  " +
                         "F.name_thai as group_2_risk_animal_name,  " +
                         "G.name_thai as group_2_pathogens_name, " +
                         "H.name_thai as faculty_name " +
                         "FROM Doc_MenuE1 A " +
                         "LEFT OUTER JOIN MST_Risk_Human B ON A.group_1_risk_human = B.id " +
                         "LEFT OUTER JOIN MST_Risk_Animal C ON A.group_1_risk_animal = C.id " +
                         "LEFT OUTER JOIN MST_Risk_Pathogens D ON A.group_1_pathogens = D.id " +
                         "LEFT OUTER JOIN MST_Risk_Human E ON A.group_2_risk_human = E.id " +
                         "LEFT OUTER JOIN MST_Risk_Animal F ON A.group_2_risk_animal = F.id " +
                         "LEFT OUTER JOIN MST_Risk_Pathogens G ON A.group_2_pathogens = G.id " +
                         "LEFT OUTER JOIN MST_Faculty H ON A.faculty = H.id " +
                         "WHERE 1=1 ";

            if (search != null)
            {
                if (!string.IsNullOrEmpty(search.docnumber))
                {
                    sql += " AND A.doc_number LIKE '%" + search.docnumber + "%'";
                }

                if (!string.IsNullOrEmpty(search.sectionname))
                {
                    sql += " AND A.section_name LIKE '%" + search.sectionname + "%'";
                }

                if (!string.IsNullOrEmpty(search.faculty))
                {
                    sql += " AND A.faculty LIKE '%" + search.faculty + "%'";
                }

                if (!string.IsNullOrEmpty(search.group1riskhuman))
                {
                    sql += " AND A.group_1_risk_human ='" + search.group1riskhuman + "'";
                }

                if (!string.IsNullOrEmpty(search.group1riskanimal))
                {
                    sql += " AND A.group_1_risk_animal ='" + search.group1riskanimal + "'";
                }

                if (!string.IsNullOrEmpty(search.group1pathogens))
                {
                    sql += " AND A.group_1_pathogens ='" + search.group1pathogens + "'";
                }

                if (!string.IsNullOrEmpty(search.group2riskhuman))
                {
                    sql += " AND A.group_2_risk_human ='" + search.group2riskhuman + "'";
                }

                if (!string.IsNullOrEmpty(search.group2riskanimal))
                {
                    sql += " AND A.group_2_risk_animal ='" + search.group2riskanimal + "'";
                }

                if (!string.IsNullOrEmpty(search.group2pathogens))
                {
                    sql += " AND A.group_2_pathogens ='" + search.group2pathogens + "'";
                }
            }

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand command = new SqlCommand(sql, conn))
                {
                    SqlDataReader reader = await command.ExecuteReaderAsync();

                    if (reader.HasRows)
                    {
                        int row_count = 1;
                        IList <ModelMenuE1Report> e = new List <ModelMenuE1Report>();
                        while (await reader.ReadAsync())
                        {
                            ModelMenuE1Report item = new ModelMenuE1Report();
                            item.docDate              = Convert.ToDateTime(reader["doc_date"]).ToString("dd/MM/yyyy");
                            item.docNumber            = reader["doc_number"].ToString();
                            item.sectionName          = reader["section_name"].ToString();
                            item.facultyName          = reader["faculty_name"].ToString();
                            item.departmentName       = reader["department_name"].ToString();
                            item.phone                = reader["phone"].ToString();
                            item.fax                  = reader["fax"].ToString();
                            item.email                = reader["email"].ToString();
                            item.group1genus          = reader["group_1_genus"].ToString();
                            item.group1species        = reader["group_1_species"].ToString();
                            item.group1riskHumanName  = reader["group_1_risk_human_name"].ToString();
                            item.group1riskAnimalName = reader["group_1_risk_animal_name"].ToString();
                            item.group1pathogensName  = reader["group_1_pathogens_name"].ToString();
                            item.group1virus          = reader["group_1_virus"].ToString();
                            item.group1bacteria       = reader["group_1_bacteria"].ToString();
                            item.group1paraSit        = reader["group_1_paraSit"].ToString();
                            item.group1mold           = reader["group_1_mold"].ToString();
                            item.group1protein        = reader["group_1_protein"].ToString();
                            item.group2genus          = reader["group_2_genus"].ToString();
                            item.group2species        = reader["group_2_species"].ToString();
                            item.group2riskHumanName  = reader["group_2_risk_human_name"].ToString();
                            item.group2riskAnimalName = reader["group_2_risk_animal_name"].ToString();
                            item.group2pathogensName  = reader["group_2_pathogens_name"].ToString();
                            item.group2virus          = reader["group_2_virus"].ToString();
                            item.group2bacteria       = reader["group_2_bacteria"].ToString();
                            item.group2paraSit        = reader["group_2_paraSit"].ToString();
                            item.group2mold           = reader["group_2_mold"].ToString();
                            item.group2protein        = reader["group_2_protein"].ToString();
                            e.Add(item);
                            row_count++;
                        }
                        return(e);
                    }
                }
                conn.Close();
            }
            return(null);
        }
コード例 #4
0
 public async Task <ModelMenuE1_InterfaceReportData> MenuE1InterfaceReportDataAsync(ModelMenuE1_InterfaceReportData search)
 {
     return(await _IDocMenuE1Repository.MenuE1InterfaceReportDataAsync(search));
 }
コード例 #5
0
        public async Task <IActionResult> MenuE1InterfaceReportData([FromBody] ModelMenuE1_InterfaceReportData model)
        {
            ModelMenuE1_InterfaceReportData e = await _IDocMenuEService.MenuE1InterfaceReportDataAsync(model);

            return(Ok(e));
        }