コード例 #1
0
 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));
     }
 }
コード例 #2
0
 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());
 }
コード例 #3
0
 public AccountController(ToWriteDbContext context)
 {
     _context = context;
 }