public async Task <IActionResult> Put([FromBody] PredictionDto dto) { var prediction = _mapper.Map <Prediction>(dto); await _predictionService.UpdateAsync(prediction); return(Ok("Updated")); }
public async Task <IActionResult> Post([FromBody] PredictionDto dto) { var prediction = _mapper.Map <Prediction>(dto); await _predictionService.AddAsync(prediction); return(Created("localhost", "")); }
public async Task <int> CompareResultsAsync(GameDto game, PredictionDto prediction) { var gameEntity = game.ToEntity(); var predictionEntity = prediction.ToEntity(); var test = await _predictionRepository.CompareResultsAsync(gameEntity, predictionEntity); return(test); }
public async Task Update(int id, [FromBody] PredictionDto prediction) { prediction.Id = id; var request = new UpdatePredictionRequest { Prediction = prediction }; await _mediator.ExecuteAsync(request).ConfigureAwait(false); }
public async Task <HttpResponseMessage> Create([FromBody] PredictionDto prediction) { var request = new CreatePredictionRequest { Prediction = prediction }; await _mediator.ExecuteAsync(request).ConfigureAwait(false); return(Request.CreateResponse(HttpStatusCode.Created)); }
public void InsertPredictionToDbTest() { PredictionDto prediction = new PredictionDto(); prediction.PredictionText = "Hello!"; IPredictionsRepository repository = new PredictionsDb(); repository.InsertPrediction(prediction); }
public void Test1() { PredictionDto predDto = new PredictionDto() { PredictionText = "yesno 2" }; IPredictionsRepository predictionsRepository = new PredictionsDatabaseRepository(); predictionsRepository.SavePrediction(predDto.PredictionText); }
public IHttpActionResult Save(PredictionDto prediction) { var repo = new Repository(); repo.SavePrediction( User.Identity.Name, prediction.MatchId, prediction.HomeGoals, prediction.AwayGoals); return(Ok()); }
public async Task UpdatePredictionAsync(int gameId, Guid?userId, string prediction) { PredictionDto predictionDto = new PredictionDto() { GameId = gameId, UserId = userId, PredictedResult = prediction }; var predictionEntity = predictionDto.ToEntity(); await _predictionRepository.UpdatePredictionAsync(predictionEntity); }
public async Task CompareResultsAsyncTest1() { //Arrange //await CreateNewDbInstance(); await CreateDb(); GameDto game = new GameDto(); game.Result = "2-2"; PredictionDto prediction = new PredictionDto(); prediction.PredictedResult = "1-1"; //Act var points = await _predictionService2.CompareResultsAsync(game, prediction); //Assert Assert.AreEqual(1, points); }
public void Test3() { IPredictionsRepository predictionsRepository = new PredictionsDatabaseRepository(); PredictionDto oldPred = new PredictionDto() { PredictionText = predictionsRepository.GetPredictionById(2) }; predictionsRepository.UpdatePrediction(oldPred, new PredictionDto() { PredictionText = oldPred.PredictionText + "test" }); Assert.Throws <Exception>((() => { if (predictionsRepository.GetPredictionById(2) != oldPred.PredictionText) { throw new Exception(); } })); }
public async Task CompareResultsAsyncTest2() { //Arrange //await CreateNewDbInstance(); await CreateDb(); GameDto game = new GameDto(); game.Result = "0-2"; game.typeResult = await _predictionService2.CheckTypeResult(game.Result); PredictionDto prediction = new PredictionDto(); prediction.PredictedResult = "3-0"; prediction.PredictedTypeResult = await _predictionService2.CheckTypeResult(prediction.PredictedResult); //Act var points = await _predictionService2.CompareResultsAsync(game, prediction); //Assert Assert.AreEqual(0, points); }
public async Task AddPointsAsync(Guid?userId, int gameId, int points) { var prediction = await _predictionRepository.GetPredictionAsync(gameId, userId); if (prediction != null) { prediction.EarnedPoints = points; } else { PredictionDto predictionDto = new PredictionDto() { GameId = gameId, UserId = userId, EarnedPoints = points }; prediction = predictionDto.ToEntity(); } await _predictionRepository.AddPointsAsync(prediction); }
public static Prediction ToEntity(this PredictionDto prediction) { return(prediction == null ? null : Mapper.Map <Prediction>(prediction)); }
public Prediction(PredictionDto dto) { PredictionText = dto.PredictionText; Id = dto.Id; }