/* * Füllt die DB mit einem neuen Datensatz */ private void FillDBWithNode(int id) { Note note = Note.CreateNew(); note.ID = id; note.Title = "Titel 1.Notiz"; note.Text = "Text der 1. Notiz"; _dbContext.Add(note); _dbContext.SaveChanges(); }
public async Task <IActionResult> Create([Bind("ID,Title,DateCreated,DateModified,Details")] NoteContext noteContext) { if (ModelState.IsValid) { _context.Add(noteContext); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(noteContext)); }
public IActionResult Create([Bind("CreatedDate,Title,Text,Importance,FinishDate,Finished")] Note note) { ViewData["CurrentStyle"] = style.getCurrent(); if (note.ID > 0) { return(BadRequest()); } if (ModelState.IsValid) { try { note.CreatedDate = DateTime.Now; _noteDBContext.Add(note); _noteDBContext.SaveChanges(); return(RedirectToAction("Index", "Home")); } catch (DbUpdateConcurrencyException) { return(BadRequest()); } catch (DbUpdateException) { return(BadRequest()); } } return(View(note)); }