public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] Category category) { if (id != category.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(long id, [Bind("ID,Title,Body")] Note note) { if (id != note.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(note); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NoteExists(note.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(note)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Owner,NoteTitle,NoteContent")] 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))); } return(View(notes)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Title,Notes,CreatedOn,CategoryId,UserId,IsDeleted")] Note note) { if (id != note.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(note); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NoteExists(note.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "ID", "ID", note.CategoryId); ViewData["UserId"] = new SelectList(_context.Users, "ID", "ID", note.UserId); return(View(note)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Text,Date_system,UrlNote,TagID,CategoryID")] Note note) { if (id != note.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(note); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NoteExists(note.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryID"] = new SelectList(_context.Category, "Id", "Name", note.CategoryID); ViewData["TagID"] = new SelectList(_context.Tag, "Id", "Name", note.TagID); return(View(note)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Email,Name,CreatedOn")] User user) { if (id != user.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,UrlSlug,Description")] Tag tag) { if (id != tag.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tag); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TagExists(tag.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tag)); }
public bool Salvar(Notes notes) { if (notes.Id != null) { _notesContext.Update(notes); } else { _notesContext.Add(notes); } _notesContext.SaveChanges(); return(true); }
public bool Salvar(Users dados) { if (dados.Id > 0) { _notesContext.Update(dados); } else { _notesContext.Add(dados); } _notesContext.SaveChanges(); return(true); }
public IActionResult Edit(Note note) { if (ModelState.IsValid) { bool orgNoteFinish = _context.Notes.Where(m => m.Id == note.Id).Select(m => m.Finished).FirstOrDefault(); if (!orgNoteFinish && note.Finished) { note.FinishedDate = DateTime.Now; } _context.Update(note); _context.SaveChanges(); return(RedirectToAction("Index")); } return(BadRequest()); }
public async Task <ActionResult <Note> > Put(Note note) { if (note == null) { return(BadRequest()); } if (!_context.Notes.Any(x => x.Id == note.Id)) { return(NotFound()); } _context.Update(note); await _context.SaveChangesAsync(); return(Ok(note)); }