public async Task <string> _Alimenticio([FromBody] Alimenticio elemento) { try { if (elemento.Id == 0) { return(await RepositoryElemento.salvar(elemento)); } else { return(await RepositoryElemento.Editar(elemento)); } } catch (Exception ex) { return(ex.Message); } }
static void Main(string[] args) { Estanteria <Alimenticio> est1 = new Estanteria <Alimenticio>(5); Estanteria <Ferreteria> est2 = new Estanteria <Ferreteria>(5); Estanteria <Alimenticio> est3 = new Estanteria <Alimenticio>(5); DateTime d1 = new DateTime(1); DateTime d2 = new DateTime(2); Alimenticio alimento1 = new Alimenticio(5, "Verdura", d1); Alimenticio alimento2 = new Alimenticio(6, "Bebida", d2); Alimenticio alimento3 = new Alimenticio(7, "Snack", d1); Alimenticio alimento4 = new Alimenticio(8, "Carne", d1); Alimenticio alimento5 = new Alimenticio(9, "Pollo", d2); Alimenticio alimento6 = new Alimenticio(8, "AlimentoRepetido", d1); Ferreteria ferre1 = new Ferreteria(23, "Martillo", 20); Ferreteria ferre2 = new Ferreteria(24, "Destornillador", 25); Ferreteria ferre3 = new Ferreteria(25, "Lija", 30); Ferreteria ferre4 = new Ferreteria(26, "Tornillo", 5); Ferreteria ferre5 = new Ferreteria(27, "Regla", 10); Ferreteria ferre6 = new Ferreteria(26, "FerreRepetida", 30); Console.WriteLine("ESTANTE 1: "); if (est1 + alimento1) { Console.WriteLine("Alimento 1 ha sido agregado (Verdura)"); } else { Console.WriteLine("No pudo agregarse"); } if (est1 + alimento1) { Console.WriteLine("Alimento 1 ha sido agregado (Verdura)"); } else { Console.WriteLine("No pudo agregarse"); } if (est1 + ferre2) { Console.WriteLine("Pudo agregarse"); } else { Console.WriteLine("No pudo agregarse"); } Console.ReadKey(); }
static void Main(string[] args) { Estanteria <Ferreteria> e1 = new Estanteria <Ferreteria>(3); Estanteria <Producto> e2 = new Estanteria <Producto>(3); Estanteria <Alimenticio> e3 = new Estanteria <Alimenticio>(3); Alimenticio alimento1 = new Alimenticio(1, "arroz", new DateTime(2020, 05, 07)); Alimenticio alimento2 = new Alimenticio(2, "fideos", new DateTime(2022, 10, 23)); Ferreteria ferrete1 = new Ferreteria(3, "pinza", 35.6f); Ferreteria ferrete2 = new Ferreteria(4, "clavos", 1.5f); bool b1 = e3 + alimento1; bool b2 = e3 + alimento2; bool b3 = e1 + ferrete1; bool b4 = e1 + ferrete2; }
static void Main(string[] args) { bool flag; Estanteria <Producto> estanteria1 = new Estanteria <Producto>(5); Estanteria <Alimenticio> estanteria2 = new Estanteria <Alimenticio>(5); Estanteria <Ferreteria> estanteria3 = new Estanteria <Ferreteria>(5); Alimenticio alimenticioGenerico = new Alimenticio(1, "Alimento Generico", new DateTime(2019, 10, 21)); Ferreteria ferreteriaGenerico = new Ferreteria(2, "Herramienta Generica", 25.5f); flag = estanteria2 + alimenticioGenerico; flag = estanteria3 + ferreteriaGenerico; Console.WriteLine(estanteria2.Productos[0].Descripcion); Console.WriteLine(estanteria3.Productos[0].Descripcion); Console.ReadKey(); }
static void Main(string[] args) { //Fecha de hoy DateTime fecha = DateTime.Today; // Instancio Estanterias. Estanteria <Producto> estProductos = new Estanteria <Producto>(50); Estanteria <Alimenticio> estAlimenticio = new Estanteria <Alimenticio>(50); Estanteria <Ferreteria> estFerreteria = new Estanteria <Ferreteria>(50); //Creo Productos. Alimenticio arroz = new Alimenticio(1, "Arroz", new DateTime()); Alimenticio leche = new Alimenticio(2, "Leche", fecha); Alimenticio aceite = new Alimenticio(3, "Aceite", fecha); Ferreteria tornillo = new Ferreteria(4, "Tornillo", (float)30.5); Ferreteria bulon = new Ferreteria(5, "Bulon", (float)4.5); Ferreteria tuerca = new Ferreteria(6, "Tuerca", (float)2.5); // Agrego al estante (Ferreteria) Console.WriteLine("**Si esta bien, agrega 3 prod. Ferreteria."); Console.WriteLine(""); if (estFerreteria + tornillo) { Console.WriteLine("Agrege Tornillo a Estante de Ferreteria"); } if (estFerreteria + bulon) { Console.WriteLine("Agrege bulon a Estante de Ferreteria"); } if (estFerreteria + tuerca) { Console.WriteLine("Agrege tuerca a Estante de Ferreteria"); } Console.WriteLine(""); // Agrego al estante (Alimenticio) Console.WriteLine("**Si esta bien, agrega 3 prod. Alimenticio."); Console.WriteLine(""); if (estAlimenticio + arroz) { Console.WriteLine("Agrege arroz a Estante de Alimenticio"); } if (estAlimenticio + aceite) { Console.WriteLine("Agrege aceite a Estante de Alimenticio"); } if (estAlimenticio + leche) { Console.WriteLine("Agrege leche a Estante de Alimenticio"); } Console.WriteLine(""); // Agrego al estante (General) Console.WriteLine("**Si esta bien, agrega 4 prod. Generales."); Console.WriteLine(""); if (estProductos + arroz) { Console.WriteLine("Agrege arroz a Estante de Productos Generales"); } if (estProductos + bulon) { Console.WriteLine("Agrege bulon a Estante de Productos Generales"); } if (estProductos + leche) { Console.WriteLine("Agrege leche a Estante de Productos Generales"); } if (estProductos + tornillo) { Console.WriteLine("Agrege leche a Estante de Productos Generales"); } Console.WriteLine(""); //Quito elementos. Console.WriteLine("**Si esta bien, QUITO 4 prod. Generales."); Console.WriteLine(""); if (estProductos - arroz) { Console.WriteLine("Quite arroz a Estante de Productos Generales"); } if (estProductos - bulon) { Console.WriteLine("Quite bulon a Estante de Productos Generales"); } if (estProductos - leche) { Console.WriteLine("Quite leche a Estante de Productos Generales"); } if (estProductos - tornillo) { Console.WriteLine("Quite tornillo a Estante de Productos Generales"); } Console.ReadKey(); }
public async Task <IActionResult> Create(string elemento, int pagina) { var site = HttpHelper.GetPedidoId(); var usuario = await UserManager.GetUserAsync(this.User); var email = usuario.UserName; var condicao = ""; ViewBag.elemento = elemento; ViewBag.condicao = _context.InfoVenda.FirstOrDefault(i => i.ClienteId == usuario.Id); ViewBag.condicao2 = _context.InfoEntrega.FirstOrDefault(i => i.ClienteId == usuario.Id); ViewBag.condicao3 = _context.ContaBancaria.FirstOrDefault(i => i.ClienteId == usuario.Id); var claims = User.Claims.ToList(); var roles = ""; foreach (var v in claims) { roles += v.Value + ", "; } bool permissao2 = await UserHelper.VerificarPermissao2(site, email, condicao, elemento); bool permissao = await UserHelper.VerificarPermissao(site, roles, elemento); if (!permissao2) { return(PartialView("NoPermission")); } if (!permissao) { return(PartialView("NoPermission")); } Elemento ele = null; if (elemento == "Imagem") { ele = new Imagem(); } if (elemento == "Show") { ele = new Show(); } if (elemento == "Video") { ele = new Video(); } if (elemento == "Texto") { ele = new Texto(); } if (elemento == "Table") { ele = new Table(); } if (elemento == "Roupa") { ele = new Roupa(); } if (elemento == "Calcado") { ele = new Calcado(); } if (elemento == "Alimenticio") { ele = new Alimenticio(); } if (elemento == "Acessorio") { ele = new Acessorio(); } if (elemento == "LinkBody") { ele = new LinkBody(); } if (elemento == "Formulario") { ele = new Formulario(); } if (elemento == "Dropdown") { ele = new Dropdown(); } if (elemento == "CarouselPagina") { ele = new CarouselPagina(); } if (elemento == "CarouselImg") { ele = new CarouselImg(); } if (elemento == "Campo") { ele = new Campo(); } var pedido = await _context.Pedido.Include(p => p.Paginas).Include(p => p.Pastas).FirstAsync(p => p.Id == site); var elementos = new List <Elemento>(); var els = await _context.Elemento.Where(elem => elem.Pagina_ == pagina).ToListAsync(); List <Pagina> lista = new List <Pagina>(); lista.Add(new Pagina { Id = 0, Titulo = "[[ Escolha uma pagina ]]" }); var page = await _context.Pagina.Include(p => p.Story) .ThenInclude(p => p.Pagina).FirstAsync(p => p.Id == pagina); lista.AddRange(page.Story.Pagina); ViewBag.PaginaEscolhida = new SelectList(lista, "Id", "Titulo"); elementos.AddRange(els); ViewBag.condicao = !page.Layout; PreencherCombo(ele, pedido, elementos); return(PartialView(ele)); }