Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("CustoFlorId,FlorId,Quantidade,ValorCalculado,DataCadastro")] CustoFlor custoFlor)
        {
            if (id != custoFlor.CustoFlorId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(custoFlor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustoFlorExists(custoFlor.CustoFlorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FlorId"] = new SelectList(_context.Set <Flor>(), "FlorId", "Descricao", custoFlor.FlorId);
            return(View(custoFlor));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("CustoFlorId,FlorId,Quantidade,ValorCalculado,DataCadastro")] CustoFlor custoFlor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(custoFlor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FlorId"] = new SelectList(_context.Set <Flor>(), "FlorId", "Descricao", custoFlor.FlorId);
            return(View(custoFlor));
        }