public IActionResult FazerPedido(List <string> carne, List <string> guarnicao, List <string> salada, Pedido pedido) { if (pedido.Nome == "Quentinha Media") { pedido.Preco = 7 * pedido.Quantidade; } else if (pedido.Nome == "Quentinha Grande") { pedido.Preco = 10 * pedido.Quantidade; } _context.Pedidos.Add(pedido); _context.SaveChanges(); foreach (var c in carne) { Carne _carne = new Carne() { Nome = c, PedidoId = pedido.Id }; _context.Carnes.Add(_carne); } _context.SaveChanges(); foreach (var g in guarnicao) { Guarnicao _guarnicao = new Guarnicao() { Nome = g, PedidoId = pedido.Id }; _context.Guarnicoes.Add(_guarnicao); } _context.SaveChanges(); foreach (var s in salada) { Salada _salada = new Salada() { Nome = s, PedidoId = pedido.Id }; _context.Saladas.Add(_salada); } _context.SaveChanges(); return(RedirectToAction("Index", "Pedido")); }
static void Main(string[] args) { Console.WriteLine("Data da escala ex: 01/12/2020"); string DateString = "01/05/2020"; // Console.ReadLine(); DateTime Data = new DateTime(); Data = DateTime.Parse(DateString); Guarnicao Guarnicao = new Guarnicao(); Meses Mes = new Meses(Data); Escala Escala = new Escala(); Escala.finaisDeSemana(Mes.FirstDomingo, Mes.QuantDiaMes); Mes.Feriados(); Escala.FeriadosEfinaisDeSemana(Mes.DiasQueSaoFeriados, Mes.quantferiado); Guarnicao.CadastrarGuarnicao(); StreamWriter texto; // para criar textos "assemble system.io" string CaminhoNome = "C:\\Users\\Geibi\\Desktop\\arq01.txt"; texto = File.CreateText(CaminhoNome); for (int i = 0; i < 4; i++) // para criar texto na area de trabalho { texto.WriteLine("\n" + Guarnicao.Duplas[i].ToUpper()); texto.WriteLine(" \t 12 HORAS"); for (int l = 0 + 1 + i; l < 32; l += 4) { if (Guarnicao.DiasTrabalho[i, l] != Escala.FinaisSemana[l]) { texto.WriteLine(Data.AddDays(l - 1).ToLongDateString() + "\n"); } } texto.WriteLine(" \t 24 HORAS"); for (int l = 0 + i + 1; l < 32; l += 4) { if (Guarnicao.DiasTrabalho[i, l] == Escala.FinaisSemana[l] && Escala.FinaisSemana[l] != 0) { texto.WriteLine(Data.AddDays(l - 1).ToLongDateString()); } } texto.WriteLine("---------------------------------"); } texto.Close(); }