public void Update(Models.Round item) { var entity = _context.Rounds.FirstOrDefault(r => r.Id == item.Id); entity.IsCompleted = true; _context.SaveChanges(); }
public int Create(Models.Round item) { Round round = Mapper.ToEntity(item); _context.Rounds.Add(round); _context.SaveChanges(); return(round.Id); }
private Round MapRound(Models.Round dbRound) { return(new Round { GameId = dbRound.GameId, PlayerId = dbRound.PlayerId, Score = dbRound.Score, DartsUsed = dbRound.DartsUsed }); }
public void Update(Models.Round item) { var sqlQuery = "UPDATE Rounds SET IsCompleted = @IsCompleted WHERE Id = @Id"; item.IsCompleted = true; using (var connection = new SqlConnection(_connectionString)) { connection.Execute(sqlQuery, item); } }
public int Create(Models.Round item) { var sqlQuery = @"INSERT INTO Rounds (NumberRound, GameId, IsCompleted) VALUES(@NumberRound, @GameId, @IsCompleted); SELECT CAST(SCOPE_IDENTITY() as int)"; item.IsCompleted = false; using (var connection = new SqlConnection(_connectionString)) { int?id = connection.QuerySingle <int>(sqlQuery, item); return(id.Value); } }
public RoundAddOrUpdateResponseDto AddOrUpdate(RoundAddOrUpdateRequestDto request) { var entity = _repository.GetAll() .FirstOrDefault(x => x.Id == request.Id && x.IsDeleted == false); if (entity == null) { _repository.Add(entity = new Models.Round()); } entity.Name = request.Name; _uow.SaveChanges(); return(new RoundAddOrUpdateResponseDto(entity)); }
public void Add(Round round) { var dbRound = new Models.Round { GameId = round.GameId, PlayerId = round.PlayerId, Score = round.Score, DartsUsed = round.DartsUsed }; using (var db = new ApiContext()) { db.Rounds.Add(dbRound); db.SaveChanges(); } }
private static DTO.Round ConvertRound(Models.Round currentRound) { if (currentRound == null) { return(new DTO.Round()); } return(new DTO.Round { Clue = currentRound.Clue, RemainingGuesses = currentRound.RemainingGuesses, Team = currentRound.Team.Id, Votes = currentRound.Votes.Select(vote => new DTO.Vote { UserName = vote.Key.UserName, Word = vote.Value.Word }).ToList(), IsClueSubmitted = currentRound.IsClueSubmitted, NumberOfWordsRelatedToGuess = currentRound.NumberOfWordsRelatedToGuess }); }
public RoundAddOrUpdateResponseDto(Models.Round entity) : base(entity) { }
public RoundDto(Models.Round entity) { Id = entity.Id; Name = entity.Name; }