예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("FactureId,ParentId,Visible")] ParentFacture parentFacture)
        {
            if (id != parentFacture.FactureId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(parentFacture);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ParentFactureExists(parentFacture.FactureId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FactureId"] = new SelectList(_context.Factures, "FactureId", "FactureId", parentFacture.FactureId);
            ViewData["ParentId"]  = new SelectList(_context.Parents, "ParentId", "ParentId", parentFacture.ParentId);
            return(View(parentFacture));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("FactureId,ParentId,Visible")] ParentFacture parentFacture)
        {
            if (ModelState.IsValid)
            {
                _context.Add(parentFacture);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FactureId"] = new SelectList(_context.Factures, "FactureId", "FactureId", parentFacture.FactureId);
            ViewData["ParentId"]  = new SelectList(_context.Parents, "ParentId", "ParentId", parentFacture.ParentId);
            return(View(parentFacture));
        }