/// <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 async Task <GameResultRS> Add(GameResultRQ gameResultRQ) { GameResultRS response = new GameResultRS(); //check if the User is Registed DataTable table = await DBManager.Instance.CheckRegistedUser(gameResultRQ); //Rows of table count > 0 that means the User is registed if (table != null && table.Rows.Count > 0) { response.IsAdded = await DBManager.Instance.AddGameResultAsync(table, gameResultRQ); response.TransactionStatus.Message = string.Format("{0} has score {1} is reported", gameResultRQ.UserName, gameResultRQ.Score); return(response); } else { //User in unregisted and the score doesn't save so return false response.TransactionStatus.Message = string.Format("{0} is not registed User", gameResultRQ.UserName); response.IsAdded = false; } return(response); }