public void Delete(Post entityToDelete) { if (context.Entry(entityToDelete).State == EntityState.Detached) { dbSet.Attach(entityToDelete); } dbSet.Remove(entityToDelete); }
public async Task <IActionResult> PutTask(int id, Services.Task task) { if (id != task.taskID) { return(BadRequest()); } _context.Entry(task).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutWordList(string userName, WordList wordList) { if (userName != wordList.UserName) { return(BadRequest()); } _context.Entry(wordList).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WordListExists(userName)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutLearningSchedule(string userName, LearningSchedule learningSchedule) { if (userName != learningSchedule.UserName) { return(BadRequest()); } _context.Entry(learningSchedule).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LearningScheduleExists(userName)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutWord(int id, Word word) { if (id != word.WordID) { return(BadRequest()); } _context.Entry(word).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WordExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutBook(int id, Book book) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != book.Id) { return(BadRequest()); } db.Entry(book).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BookExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void UpdateAlbum(Album album) { context.Entry(album).State = EntityState.Modified; }