public ComandaTesteUnidade() { var context = new ComandaContext(dbContextOptions); _unidadeTrabalho = new UnidadeTrabalho(context); log = TesteUnidadeLog.Create <ComandaController>(); }
//public getComanda(int idComanda) public Model.Comanda.Comanda getComanda(int idComanda) { Model.Comanda.Comanda comanda = new Model.Comanda.Comanda(); using (var db = new ComandaContext()) { var dbcomanda = db.Comanda .Where(b => b.ID == idComanda).FirstOrDefault(); //.Where(b => b.ID == idComanda).ToList(); comanda = dbcomanda; } return(comanda); }
public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); using (var db = new ItemContext()) { //db.Add(new Item { ID = 1, Nome = "cerveja", Preco = 5.00 }); //db.Add(new Item { ID = 2, Nome = "conhaque", Preco = 20.00 }); //db.Add(new Item { ID = 3, Nome = "suco", Preco = 50.00 }); //db.Add(new Item { ID = 4, Nome = "agua", Preco = 70.00 }); //db.SaveChanges(); var itens = db.Item .OrderBy(b => b.ID) .First(); } using (var db = new ComandaContext()) { //// Create //Console.WriteLine("Inserting a new blog"); //// Read //Console.WriteLine("Querying for a blog"); //var blog = db.Comanda // .OrderBy(b => b.ID) // .First(); //// Update //Console.WriteLine("Updating the blog and adding a post"); //blog.Url = "https://devblogs.microsoft.com/dotnet"; //blog.Posts.Add( // new Post // { // Title = "Hello World", // Content = "I wrote an app using EF Core!" // }); //db.SaveChanges(); //// Delete //Console.WriteLine("Delete the blog"); //db.Remove(blog); //db.SaveChanges(); } }
public Model.Comanda.Comanda cadastraComanda(int idComanda, List <Item> itens) { Model.Comanda.Comanda comanda = new Model.Comanda.Comanda(); using (var db = new ComandaContext()) { db.Add(new Model.Comanda.Comanda { ID = idComanda, Itens = itens, PromocaoAguaPedidos = 0, PromocaoAguaRestantes = 0 }); db.SaveChanges(); var dbcomanda = db.Comanda .Where(b => b.ID == idComanda).FirstOrDefault(); comanda = dbcomanda; } return(comanda); }
public ComandaRepositorio(ComandaContext contexto) : base(contexto) { }
public UnidadeTrabalho(ComandaContext contexto) { _contexto = contexto; }
public ComandaController(ComandaContext context, IControlaComanda controlaComanda) { _context = context; _controlaComanda = controlaComanda; }
public Repositorio(ComandaContext contexto) { _contexto = contexto; }