Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Code,Date,City,StatusID")] Facture facture)
        {
            if (id != facture.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(facture);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FactureExists(facture.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StatusID"] = new SelectList(_context.Statuses, "Id", "Id", facture.StatusID);
            return(View(facture));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,WareName,Count,Price,Tax")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Code,Date,City,StatusID")] Facture facture)
        {
            if (ModelState.IsValid)
            {
                _context.Add(facture);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StatusID"] = new SelectList(_context.Statuses, "Id", "StatusName", facture.StatusID);
            return(View(facture));
        }
        public async Task <IActionResult> Create(FactureProductsCreateDto factureProductsCreate)
        {
            if (ModelState.IsValid)
            {
                var factureProducts = new FactureProducts();
                factureProducts.FactureId = factureProductsCreate.FactureId;
                factureProducts.ProductId = factureProductsCreate.ProductId;

                _context.Add(factureProducts);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Factures", new { @id = factureProductsCreate.FactureId }));
            }

            return(RedirectToAction("Details", "Factures", new { @id = factureProductsCreate.FactureId }));
        }