Chuyển đến nội dung chính

Bài đăng

Đang hiển thị bài đăng từ Tháng 11, 2022

ASP.NET Core: Upload file

Trong bài viết này, mình sẽ hướng dẫn bạn cách upload 1 file, upload nhiều file. Upload 1 file Bạn tạo controller với 2 action như sau: public IActionResult Index() { return View(); } [HttpPost] public IActionResult Index(IFormFile file) { return View(); } Thẻ form sẽ gồm có 3 thành phần cần lưu ý: Method = post Enctype ="multipart/form-data": Thuộc tính enctype chỉ định cách mã hóa dữ liệu biểu mẫu khi gửi nó đến máy chủ. Input type= "file"  <form method="post" enctype="multipart/form-data" asp-controller="Home" asp-action="Index" enctype="multipart/form-data"> <div class="mb-3"> <label for="exampleInputEmail1" class="form-label">Upload one file using this form:</label> <input type="file" name="file" class="form-control" /> </div> <button type="submit" class="btn b

Repository Pattern và Unit of Work

Trong bài viết này, mình sẽ hướng dẫn các bạn sử dụng Repository Pattern với Unit Of Work trong ASP.NET Core. Repository Pattern là gì? Martin Fowler định nghĩa Repository Pattern như sau: A Repository mediates between the domain and data mapping layers, acting like an in-memory domain object collection. Client objects construct query specifications declaratively and submit them to Repository for satisfaction. Objects can be added to and removed from the Repository, as they can from a simple collection of objects, and the mapping code encapsulated by the Repository will carry out the appropriate operations behind the scenes. Conceptually, a Repository encapsulates the set of objects persisted in a data store and the operations performed over them, providing a more object-oriented view of the persistence layer. Repository also supports the objective of achieving a clean separation and one-way dependency between the domain and data mapping layers. Trong mô hình 3 lớp (Presentation, Busin

Angular: Sử dụng highlight.js

Trong bài viết này, mình sẽ hướng dẫn các bạn tích hợp Syntax Highlight.js vào trong dự án Github: https://github.com/MurhafSousli/ngx-highlightjs How to setup: https://ngx-highlight.netlify.app/ Phần setup khá đơn giản, nhưng có 1 vấn đề là linenumber package bị báo lỗi khi import Setup Angular Highlight.js Cài đặt ngx-highlight-js: npm install --save ngx-highlight-js Thêm 2 dòng sau đây vào file html của component hoặc template của dự án: <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/atom-one-dark.min.css" /> <script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/highlight.min.js"></script> Mở file app.module.ts, thêm HighlightModel: //.... import { HttpClientModule } from '@angular/common/http'; import { HighlightModule, HIGHLIGHT_OPTIONS, HighlightOptions, } from 'ngx-highlightjs'; //... @NgModule({ imports: [ BrowserModule, FormsModule, App

Sử dụng bxSlider cho Blogger

Trong số các plugin về slider, mình thấy bxSlider là đơn giản nhất. Mặc dù mình rất thích Bootstrap nhưng do template không thể sử dụng Bootstrap nên đành kiếm thư viện jQuery Hướng dẫn cài đặt Link hướng dẫn cài đặt: https://bxslider.com/install/ Mở Blogger -> Theme -> Customize -> Edit as HTML Bạn kéo xuống cuối trang, thêm đoạn code này trước thẻ body <link rel="stylesheet" href="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.css" /> <script src="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.min.js"></script> <script type='text/javascript'> $(document).ready(function(){ $('.bxslider').bxSlider({ mode: 'fade', captions: true, slideWidth: 600 }); }); </script> Thêm slideshow vào bài viết Để thêm slideshow vào trong bài viết, bạn thêm 1 bài viết mới, mở HTML view Thêm đoạn code ví dụ như sau: <div class="bxslider"> <div><img src="

BA: ERD là gì - Part 1

Một dạo mình đọc về C4 Model hay quá, mà kiến thức về phân tích hệ thống của mình bị hỏng hơi bị nhiều. Nên mình sẽ tập hợp lại kiến thức môn Phân tích thiết kế hệ thống thông tin, Phân tích thiết kế đối tượng, UML, rồi sẽ tìm hiểu về C4 Model. Bài viết sau là từ bạn Thịnh. Viết khá hay và dí dỏm: https://thinhnotes.com/chuyen-nghe-ba/erd-la-gi/ Giới thiệu ERD – Entity Relationship Diagram, cái tên không ít thì nhiều cũng khá quen với anh em chứ hả 🙂 Bài note hôm nay mình sẽ nói về ERD, một trong những công cụ không thể thiếu của người làm Business Analyst. Sẽ là tất tần tật về ERD, một cách “thực tiễn” nhất có thể, bao gồm: ERD là gì, các thành phần của ERD, hay vai trò của ERD đối với BA. Và quan trọng nhất là 15 phút thực hành ERD để hiểu rõ: thực sự ERD giúp ích được gì cho công việc của BA nhé 😎 ERD là gì? ERD phun nem là “Entity” “Relationship” Diagram. “Entity” nghĩa là các thực thể “Relationship” là các mối quan hệ , (giữa các thực thể đó). ==> Vậy tóm gọn: ERD là mộ

Canvas: Dải màu gradient - Day 3

Có 2 loại dải màu: Linear gradient, Radial gradient, và Conic gradient Linear gradient Linear-gradient (gradient tuyến tính) là loại gradient phổ biến nhất mà chúng ta thấy trong thiết kế web. Nó được gọi là "tuyến tính" vì flow của màu sắc sẽ từ trái sang phải, từ trên xuống dưới hoặc ở bất kỳ góc nào tùy thuộc vào hướng mà mình chọn. Có 3 kiểu cơ bản: horizontal (ngang), vertical (dọc), và diagonal (đường chéo) Cú pháp context.createLinearGradient(x0,y0,x1,y1); Giải thích x0: Tọa độ X của điểm bắt đầu dải màu y0: Tọa độ Y của điểm bắt đầu dải màu x1: Tọa độ X của điểm kết thúc dải màu y1: Tọa độ Y của điểm kết thúc dải màu Định nghĩa dải màu: Horizontal: (0, 0, x1,0) Vertical: (0, 0, 0, y1) Diagonal (0, 0, x1, y1) Ví dụ: Tạo dải màu theo đường chéo từ góc trên bên trái xuống góc dưới bên phải // Create gradient var grd = ctx.createLinearGradient(0, 0, 200, 200); grd.addColorStop(0, "red"); grd.addColorStop(0.3, "yellow"); grd.addColorStop(0.6, "g