Ejemplo n.º 1
0
        public async Task <ModelMenuA5_FileDownload> GetA5DownloadFileByIdAsync(int DocId, int Id)
        {
            string sql = "SELECT TOP(1) file1name FROM Doc_MenuA5 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)
                    {
                        ModelMenuA5_FileDownload e = new ModelMenuA5_FileDownload();
                        while (await reader.ReadAsync())
                        {
                            if (Id == 1)
                            {
                                e.filebase64 = ServerDirectorys.ReadFileToBase64(_IEnvironmentConfig.PathDocument, FolderDocument.menuA5, reader["file1name"].ToString());
                                e.filename   = "เอกสารรายงานแก้ไขโครงการ";
                            }
                        }
                        return(e);
                    }
                }
                conn.Close();
            }
            return(null);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetA5DownloadFileById(int DocId, int Id)
        {
            ModelMenuA5_FileDownload e = await _IDocMenuAService.GetA5DownloadFileByIdAsync(DocId, Id);

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