public async Task <IActionResult> PutUser(Guid id, User user) { if (id != user.UserId) { return(BadRequest()); } _context.Entry(user).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTweet(Guid id, Tweet tweet) { if (id != tweet.Id) { return(BadRequest()); } _context.Entry(tweet).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TweetExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <bool> CreateAsync(Post newPost) { await _dbContext.Posts.AddAsync(newPost); var created = await _dbContext.SaveChangesAsync(); return(created > 0); }