Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("GenreId,GenreName")] Genre genre)
        {
            if (id != genre.GenreId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(genre);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GenreExists(genre.GenreId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(genre));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("BranchId,BranchName,City,Address,Latitude,Longitude,PhoneNumber")] Branch branch)
        {
            if (id != branch.BranchId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(branch);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BranchExists(branch.BranchId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(branch));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutAsync(int id, [FromBody] Book bookToUpdate)
        {
            var book = await _context.Books.FindAsync(id);

            if (book == null)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            _context.Update(bookToUpdate);
            await _context.SaveChangesAsync();

            return(Ok());
        }