예제 #1
0
        public async Task <ModelMenuA6_FileDownload> GetA6DownloadFileByIdAsync(int DocId, int Id)
        {
            string sql = "SELECT TOP(1) file1name FROM Doc_MenuA6 WHERE doc_id='" + DocId + "' ";

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

                    if (reader.HasRows)
                    {
                        ModelMenuA6_FileDownload e = new ModelMenuA6_FileDownload();
                        while (await reader.ReadAsync())
                        {
                            if (Id == 1)
                            {
                                e.filebase64 = ServerDirectorys.ReadFileToBase64(_IEnvironmentConfig.PathDocument, FolderDocument.menuA6, reader["file1name"].ToString());
                                e.filename   = "เอกสารรายงานขอต่ออายุโครงการ";
                            }
                        }
                        return(e);
                    }
                }
                conn.Close();
            }
            return(null);
        }
예제 #2
0
        public async Task <IActionResult> GetA6DownloadFileById(int DocId, int Id)
        {
            ModelMenuA6_FileDownload e = await _IDocMenuAService.GetA6DownloadFileByIdAsync(DocId, Id);

            if (e != null)
            {
                return(Ok(e));
            }
            else
            {
                return(BadRequest());
            }
        }