public IActionResult GetRandomIdea() { using (ToWriteDbContext dbContext = new ToWriteDbContext()) { Random random = new Random(); var randomIdea = dbContext.Ideas.Skip(random.Next(0, dbContext.Ideas.Count())).Take(1); return(Ok(randomIdea.First().IdeaBlock)); } }
public IActionResult SaveText([FromQuery] string text) { using (ToWriteDbContext dbContext = new ToWriteDbContext()) { Text textToSave = new Text() { TextBlock = text, User = dbContext.Users.First(u => u.Email == HttpContext.User.Identity.Name) }; dbContext.Add(textToSave); dbContext.SaveChanges(); } return(Ok()); }
public AccountController(ToWriteDbContext context) { _context = context; }