Beispiel #1
0
        public async Task <ModelMenuA3_FileDownload> GetA3DownloadFileByIdAsync(int DocId, int Id)
        {
            string sql = "SELECT TOP(1) file1name FROM Doc_MenuA3 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)
                    {
                        ModelMenuA3_FileDownload e = new ModelMenuA3_FileDownload();
                        while (await reader.ReadAsync())
                        {
                            if (Id == 1)
                            {
                                e.filebase64 = ServerDirectorys.ReadFileToBase64(_IEnvironmentConfig.PathDocument, FolderDocument.menuA3, reader["file1name"].ToString());
                                e.filename   = "เอกสารรายงานความก้าวหน้าโครงการ";
                            }
                        }
                        return(e);
                    }
                }
                conn.Close();
            }
            return(null);
        }
Beispiel #2
0
        public async Task <IActionResult> GetA3DownloadFileById(int DocId, int Id)
        {
            ModelMenuA3_FileDownload e = await _IDocMenuAService.GetA3DownloadFileByIdAsync(DocId, Id);

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