Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,Manufacturer,Color,Engine,Volume,BodyType,Created")] Cars cars)
        {
            if (ModelState.IsValid)
            {
                cars.Created = DateTime.Now;
                _context.Add(cars);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cars));
        }
        public async Task <IActionResult> Create([Bind("Id,Created,Author,Text,NoteId")] Comments comments)
        {
            if (ModelState.IsValid)
            {
                comments.Created = DateTime.Now;
                _context.Add(comments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NoteId"] = new SelectList(_context.Notes, "Id", "Text", comments.NoteId);
            return(View(comments));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("Id,Created,Title,Text,CarId")] Notes notes)
        {
            if (ModelState.IsValid)
            {
                notes.Created = DateTime.Now;
                _context.Add(notes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarId"] = new SelectList(_context.Cars, "Id", "BodyType", notes.CarId);
            return(View(notes));
        }