public async Task UpdateConnectionInfo(Models.ConnectionInfo model) { var uid = HttpContext.User.FindFirst("user_id"); if (ModelState.IsValid) { var _connectionInfo = await _dbContext.ConnectionInfos.FirstOrDefaultAsync(x => x.Uid == uid.Value); if (_connectionInfo == null) { _dbContext.Add(new Models.ConnectionInfo() { Uid = uid.Value, Host = model.Host, Port = model.Port }); } else { _connectionInfo.Host = model.Host; _connectionInfo.Port = model.Port; } await _dbContext.SaveChangesAsync(); } }
public async Task CreatePrizeDrawHistory(PrizeDrawHistory item) { if (ModelState.IsValid) { var uid = HttpContext.User.FindFirst("user_id"); item.Uid = uid.Value; _dbContext.Add(item); await _dbContext.SaveChangesAsync(); } }