/// <summary> /// Function to Insert the GameResult for Registed User /// </summary> /// <returns></returns> public async System.Threading.Tasks.Task <IHttpActionResult> AddScoreAsync(string name, int score) { GameResultRQ request = new GameResultRQ() { UserName = name, Score = score }; try { GameResultRS response = new GameResultRS(); if (!string.IsNullOrEmpty(name)) { response = await gameResultRepository.Add(request); } else { response.TransactionStatus = TransactionStatusHelper.CreateTransaction(HttpStatusCode.BadRequest.ToString(), invalidParamters, EndTransactionType.Error, ErrorType.ExternalError); } return(Ok(response)); } catch (Exception e) { Console.WriteLine("Exception source: {0}", e.Source); return(null); } }
public bool Add(GameResultDTO gameResultDTO) { if (repository.ExistGameResultWithSameGameIdAndPlayerId(gameResultDTO)) { return(repository.Update(gameResultDTO)); } else { return(repository.Add(gameResultDTO)); } }
public void AddGameResult(GameResultDto gameResultDto, Gamer gamer) { var gameResult = MapGameResultDtoToGameResultWithReferences(gameResultDto, gamer); _gameResultRepository.Add(gameResult); }