public async Task <IList <ModelMenuF1Report> > GetAllReportDataF1Async(ModelMenuF1_InterfaceData search_data)
        {
            string sql = "SELECT A.*, (B.name_thai) AS position_name_thai, " +
                         "(C.name_thai) AS faculty_name_thai, (D.name_thai) AS education_name_thai, " +
                         "(E.name_thai) AS character_name_thai " +
                         "FROM RegisterUser A " +
                         "INNER JOIN MST_Position B ON A.position = B.id " +
                         "INNER JOIN MST_Faculty C ON A.faculty = C.id " +
                         "INNER JOIN MST_Education D ON A.education = D.id " +
                         "INNER JOIN MST_Character E ON A.character = E.id " +
                         "WHERE 1=1 ";

            if (search_data != null && !string.IsNullOrEmpty(search_data.searchkey))
            {
                sql += " AND (register_id LIKE '%" + search_data.searchkey + "%' OR email LIKE '%" + search_data.searchkey + "%' OR full_name LIKE '%" + search_data.searchkey + "%') ";
            }

            sql += " ORDER BY full_name ASC ";

            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 <ModelMenuF1Report> e = new List <ModelMenuF1Report>();
                        while (await reader.ReadAsync())
                        {
                            ModelMenuF1Report item = new ModelMenuF1Report();
                            item.registerid     = reader["register_id"].ToString();
                            item.userid         = reader["userid"].ToString();
                            item.fullname       = reader["first_name"].ToString() + reader["full_name"].ToString();
                            item.email          = reader["email"].ToString();
                            item.registerdate   = Convert.ToDateTime(reader["register_date"]).ToString("dd/MM/yyyy");
                            item.registerexpire = Convert.ToDateTime(reader["register_expire"]).ToString("dd/MM/yyyy");
                            item.positionname   = reader["position_name_thai"].ToString();
                            item.facultyname    = reader["faculty_name_thai"].ToString();
                            item.educationname  = reader["education_name_thai"].ToString();
                            item.charactername  = reader["character_name_thai"].ToString();
                            item.workphone      = reader["work_phone"].ToString();
                            item.mobile         = reader["mobile"].ToString();
                            item.fax            = reader["fax"].ToString();
                            item.isactive       = reader["IsActive"].ToString();

                            e.Add(item);
                            row_count++;
                        }
                        return(e);
                    }
                }
                conn.Close();
            }
            return(null);
        }
        public async Task <ModelMenuF1_InterfaceData> MenuF1InterfaceDataAsync(string RegisterId)
        {
            ModelMenuF1_InterfaceData resp = new ModelMenuF1_InterfaceData();

            resp.listdata = await GetAllReportDataF1Async(null);

            resp.UserPermission = await _IRegisterUserRepository.GetPermissionPageAsync(RegisterId, "M023");

            return(resp);
        }
        public async Task <IActionResult> GetAllReportDataF1(ModelMenuF1_InterfaceData SearchData)
        {
            IList <ModelMenuF1Report> e = await _IDocMenuFService.GetAllReportDataF1Async(SearchData);

            if (e != null)
            {
                return(Ok(e));
            }
            else
            {
                return(BadRequest());
            }
        }
        public async Task <IActionResult> MenuF1InterfaceData(string RegisterId)
        {
            ModelMenuF1_InterfaceData e = await _IDocMenuFService.MenuF1InterfaceDataAsync(RegisterId);

            if (e != null)
            {
                return(Ok(e));
            }
            else
            {
                return(BadRequest());
            }
        }
        public async Task<IActionResult> GetAllReportDataF1(ModelMenuF1_InterfaceData SearchData)
        {
            var requestUri = $"{_WebApiModel.BaseURL}/{"PrivateDocMenuF"}/{"GetAllReportDataF1"}";
            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, SearchData);
            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);
            }

        }
Example #6
0
 public async Task <IList <ModelMenuF1Report> > GetAllReportDataF1Async(ModelMenuF1_InterfaceData search_data)
 {
     return(await _IDocMenuF1Repository.GetAllReportDataF1Async(search_data));
 }