Skip to content

Instantly share code, notes, and snippets.

@vitorpiovezam vitorpiovezam/foo.cs
Last active Aug 29, 2019

Embed
What would you like to do?
Entediado na aula de c#
using System;
public class FOO {
public static void Main() {
var category = new Category("Maquiagem");
var product = new Product("Vareta", "vitor@gmail.com", category);
var categoryRepository = new CategoryRepository();
var productRepository = new ProductRepository();
Console.WriteLine(category.mandaLetra());
Console.WriteLine(product.mandaLetra());
productRepository.Insert(product);
productRepository.Update(product);
productRepository.Delete(product);
categoryRepository.Insert(category);
categoryRepository.Update(category);
categoryRepository.Delete(category);
}
public class Category: BaseModel {
public String name;
public Category(String name): base() {
this.name = name;
}
}
public class Product: BaseModel {
public String name;
public String email;
public Category category;
public Product(String name, String email, Category category): base() {
this.name = name;
this.email = email;
this.category = category;
}
}
public class ProductRepository: BaseService < Product > {
}
public class CategoryRepository: BaseService < Category > {
}
public abstract class BaseModel {
public int id;
public BaseModel() {
this.id = generateId();
}
public int generateId() {
Random randNum = new Random();
return randNum.Next(100000);
}
public String mandaLetra() {
return "Salve -> " + this.ToString();
}
}
public abstract class BaseService < T > {
public void Insert(T item) {
Console.WriteLine("Aeeee cadastrou");
Console.WriteLine("\n\n " + item.ToString());
}
public void Update(T item) {
Console.WriteLine("Aeeee atualizou");
Console.WriteLine("\n\n " + item.ToString());
}
public void Delete(T item) {
Console.WriteLine("Aeeee deletou");
Console.WriteLine("\n\n " + item.ToString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.