public HttpResponseMessage AddGameScore(GamesScoreModel gameScoreModel) { try { GamesScoreModel gameScore = gamescorelogic.AddGameScore(gameScoreModel); return(Request.CreateResponse(HttpStatusCode.Created, gameScore)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
//Add Game Result public GamesScoreModel AddGameScore(GamesScoreModel gameScoreModel) { DateTime nowTime = DateTime.Now; GameScore gameScore = new GameScore { UserID = gameScoreModel.userId, GameDateTime = nowTime, GameDuration = gameScoreModel.gameDuration, GameMoves = gameScoreModel.moves }; DB.GameScores.Add(gameScore); DB.SaveChanges(); gameScoreModel.id = gameScore.ScoreID; return(gameScoreModel); }