0% found this document useful (0 votes)
6 views7 pages

Test Unit

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views7 pages

Test Unit

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Hello Good afternoon, My name is Thanh, but it's hard for some people to say, so can you call

me Thanh.
Iam originally from QB, but now Iam based in Da Nang City for the past 3 years. Iam in the third year of
my FPT university..(Iam work in SF)

I am a goal-oriented person, so I will try my best to work for the company.

I see FPT company as a leading company in technology. If accepted, I would be lucky to work here, with
a very good working environment.

Yes of couse, because pets are very cute, and I can play with them when I feel pressured

I think I like a funny manager, because in a non-toxic working environment, everyone will grow together.

I think I haven't succeeded yet, because I still have many things I haven't achieved in life. I need to try
harder at work.

As I said, I am a goal-oriented person and I have not learned many things in life, so I will try to learn
more knowledge, update and improve it every day, to help the company and myself develop together. .

I am passionate about football, because playing football helps me develop my body, and can also
connect with colleagues in the company, and I am very lucky that the company has a football field so
colleagues can play together.

My biggest weakness is emotions, because I am a person who thinks a lot, so I often have difficulty
regulating my emotions, but I have tried to change it gradually, and now I have improved a lot. .

Maybe I'll get old.

I have a pen, this pen is a magic pen, it sparkles, and it is very beautiful, you can buy it for 2$ but I will
sell it to you for 1$ because you are very beautiful
// Giao diện repository chung

public interface IRepository<T>

T GetById(int id);

IEnumerable<T> GetAll();

void Add(T entity);

void Update(T entity);

void Delete(int id);

// Đối tượng Product

public class Product

{
public int Id { get; set; }

public string Name { get; set; }

// ... other properties

// Đối tượng Category

public class Category

public int Id { get; set; }

public string Name { get; set; }

// ... other properties

// Abstract class chung cho các đối tượng có thể đặc biệt hóa

public abstract class AuditableEntity

public int Id { get; set; }

public DateTime CreatedAt { get; set; }

public DateTime UpdatedAt { get; set; }

public string CreatedBy { get; set; }

public string UpdatedBy { get; set; }

// ... other common audit properties

// Đối tượng Blog kế thừa từ AuditableEntity

public class Blog : AuditableEntity

public string Title { get; set; }

public string Content { get; set; }


// ... other properties

// Repository cụ thể cho đối tượng Product

public class ProductRepository : IRepository<Product>

private readonly DbContext _context;

public ProductRepository(DbContext context)

_context = context;

public Product GetById(int id)

return _context.Set<Product>().Find(id);

public IEnumerable<Product> GetAll()

return _context.Set<Product>().ToList();

public void Add(Product entity)

_context.Set<Product>().Add(entity);

public void Update(Product entity)


{

_context.Set<Product>().Update(entity);

public void Delete(int id)

var product = GetById(id);

if (product != null)

_context.Set<Product>().Remove(product);

// Repository cụ thể cho đối tượng Blog

public class BlogRepository : IRepository<Blog>

private readonly DbContext _context;

public BlogRepository(DbContext context)

_context = context;

public Blog GetById(int id)

return _context.Set<Blog>().Find(id);

}
public IEnumerable<Blog> GetAll()

return _context.Set<Blog>().ToList();

public void Add(Blog entity)

_context.Set<Blog>().Add(entity);

public void Update(Blog entity)

_context.Set<Blog>().Update(entity);

public void Delete(int id)

var blog = GetById(id);

if (blog != null)

_context.Set<Blog>().Remove(blog);

// Ví dụ sử dụng Unit of Work với nhiều đối tượng

class Program

static void Main()


{

using (var unitOfWork = new UnitOfWork(new YourDbContext()))

var productRepo = unitOfWork.GetRepository<Product>();

var blogRepo = unitOfWork.GetRepository<Blog>();

// Thực hiện các thao tác với sản phẩm và blog

var product = new Product { Name = "Example Product" };

productRepo.Add(product);

var blog = new Blog { Title = "Example Blog", Content = "Lorem Ipsum" };

blogRepo.Add(blog);

unitOfWork.SaveChanges();

You might also like