예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Price")] Produit produit)
        {
            if (id != produit.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(produit);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProduitExists(produit.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(produit));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,ReleaseDate,Genre")] Book book)
        {
            if (id != book.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(book);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Nome,Sobrenome,RA,Curso,Status,DataInicio,DataTermino,Email,Telefone,Escola,Endereço,CPF")] Aluno aluno)
        {
            if (id != aluno.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(aluno);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlunoExists(aluno.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(aluno));
        }
예제 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,tytul,data_wydania,gatunek,cena,ocena")] Game game)
        {
            if (id != game.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(game);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GameExists(game.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(game));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome")] Departments departments)
        {
            if (id != departments.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(departments);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentsExists(departments.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(departments));
        }
예제 #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Author author)
        {
            if (id != author.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(author);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AuthorExists(author.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(author));
        }
        public void Update(Seller seller)
        {
            //Id exists on DB ?
            if (seller == null || !_context.Seller.Any(x => x.Id == seller.Id))
            {
                throw new NotFoundException("Id [" + seller.Id + "] Not Found");
            }

            try {
                _context.Update(seller);
                _context.SaveChanges();
            } catch (DbUpdateConcurrencyException e) {
                //throw customized exception
                throw new DbConcurrencyException(e.Message);
            }
        }