public void Update(Models.RoundPlayer item) { var entity = _context.RoundPlayers.FirstOrDefault(rp => rp.Id == item.Id); entity.IsWin = item.IsWin; _context.SaveChanges(); }
public int Create(Models.RoundPlayer item) { RoundPlayer roundPlayer = Mapper.ToEntity(item); _context.RoundPlayers.Add(roundPlayer); _context.SaveChanges(); return(roundPlayer.Id); }
public void Update(Models.RoundPlayer item) { var sqlQuery = "UPDATE RoundPlayers SET IsWin = @IsWin WHERE Id = @Id"; using (var connection = new SqlConnection(_connectionString)) { connection.Execute(sqlQuery, item); } }
public int Create(Models.RoundPlayer item) { var sqlQuery = @"INSERT INTO RoundPlayers (RoundId, PlayerId) VALUES(@RoundId, @PlayerId); SELECT CAST(SCOPE_IDENTITY() as int)"; using (var connection = new SqlConnection(_connectionString)) { int?id = connection.QuerySingle <int>(sqlQuery, item); return(id.Value); } }