public async Task <IActionResult> NewMenu(CrearMenuVM crearMenuVM) { Entrante primero = await _context.Entrantes.FindAsync(crearMenuVM.Menu.EntranteId); Principal segundo = await _context.Principales.FindAsync(crearMenuVM.Menu.PrincipalId); Postre tercero = await _context.Postres.FindAsync(crearMenuVM.Menu.PostreId); Menu nuevoMenu = new Menu { Entrante = primero, Principal = segundo, Postre = tercero, Fecha = DateTime.Now, //PrecioTotal = primero.Precio + segundo.Precio + tercero.Precio, }; double precio = 0; if (primero != null) { precio += primero.Precio; } if (segundo != null) { precio += segundo.Precio; } if (tercero != null) { precio += tercero.Precio; } nuevoMenu.PrecioTotal = precio; return(View(nuevoMenu)); }
public string Index() { var caminho = HttpContext.Request.Path.Split('/'); var empresa = caminho[caminho.Length - 1]; Cliente cliente = OperacaoClientes.ObtemClientes().Find(x => x.Nome.ToUpper() == empresa.ToUpper()); if (cliente == null) { return("Cliente não encontrado!"); } var parametros = HttpContext.Request.Params; Entrante ligacao = new Entrante(); ligacao.peer = parametros["peer"]; ligacao.phone = parametros["phone"]; ligacao.codcli = parametros["codcli"]; string connectionString = String.Format("Server={0};User Id={1};Password={2};Database={3};", cliente.Endereco, "agilus", "awrpu07!@$AFAFAsdfqrasfafJMYJYJ&* $%", cliente.Database); using (SqlConnection conexao = new SqlConnection(connectionString)) { var comand = new SqlCommand(String.Format(@"INSERT INTO ligacao_entrante_discador (lid_nome_empresa, lid_ramal, lid_telefone, lid_codigo_agilus) VALUES ('VCOM', '{0}', '{1}', '{2}')", ligacao.peer, ligacao.phone, ligacao.codcli), conexao); try { conexao.Open(); comand.ExecuteNonQuery(); return("Ligação entrante registrada com sucesso na empresa " + cliente.Nome); } catch (Exception e) { var erroEmail = "<p><b>cliente</b>: " + cliente.Nome + "</p><p><b>db</b>: " + cliente.Database + "</p><p><b>Endereço</b>: " + cliente.Endereco + "</p><p><b>Comando</b>: " + comand.CommandText + "</p><p><b>Url</b>: " + HttpContext.Request.Url.AbsoluteUri + "</p><p><b>Mensagem da Exceção</b>: " + e.Message; Email.EnviarEmail("Erro entrante LogVcom", erroEmail); return("Ligação entrante não registrada. Erro: " + e.Message); } } }
public async Task <IActionResult> EleccionMenu(CrearMenusVM crearMenusVM) { Entrante entrante = await _context.Entrantes.FindAsync(crearMenusVM.Menu.EntranteId); Postre postre = await _context.Postres.FindAsync(crearMenusVM.Menu.PostreId); Principal principal = await _context.Principales.FindAsync(crearMenusVM.Menu.PrincipalId); Menu menu = new Menu { Entrante = entrante, Postre = postre, Principal = principal, Fecha = DateTime.Now }; double precio = 0; if (entrante != null) { precio += entrante.Precio; } if (principal != null) { precio += principal.Precio; } if (postre != null) { precio += postre.Precio; } menu.PrecioTotal = precio; return(View(menu)); }
public async Task <IActionResult> ConfirmarMenu(EleccionMenuVM emvm) // no seria mas correcto decir que lo que recibe son los 3 Ids? y el menu?, porque no le da error? { Entrante entrante = await _context.Entrantes.FindAsync(emvm.Menu.EntranteId); // buscamos objetos en funcion ID recibido Principal principal = await _context.Principales.FindAsync(emvm.Menu.EntranteId); Postre postre = await _context.Postres.FindAsync(emvm.Menu.EntranteId); Menu menu = new Menu { Entrante = entrante, Principal = principal, Postre = postre, Fecha = DateTime.Now, //PrecioTotal = entrante.Precio + principal.Precio + postre.Precio }; double precio = 0; if (entrante != null) { precio += entrante.Precio; } if (principal != null) { precio += principal.Precio; } if (postre != null) { precio += postre.Precio; } menu.PrecioTotal = precio; return(View(menu)); }
private static PDU FactoryEntrante(byte[] buffer) { return(Entrante.Parse(buffer)); }