예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Created,Title,Text,CarId")] Notes notes)
        {
            if (id != notes.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(notes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NotesExists(notes.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarId"] = new SelectList(_context.Cars, "Id", "BodyType", notes.CarId);
            return(View(notes));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Created,Author,Text,NoteId")] Comments comments)
        {
            if (id != comments.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(comments);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommentsExists(comments.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NoteId"] = new SelectList(_context.Notes, "Id", "Text", comments.NoteId);
            return(View(comments));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Manufacturer,Color,Engine,Volume,BodyType,Created")] Cars cars)
        {
            if (id != cars.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cars);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarsExists(cars.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cars));
        }