Exemplo n.º 1
0
        public Prediction ToEntity(PredictionEditModel prediction, IApplicationDbContext context, int id)
        {
            var entity = context.Predictions.FirstOrDefault(p => p.Id == id) ?? new Prediction();

            entity.Id            = id;
            entity.FulltimeScore = prediction.FulltimeScore;
            entity.HalftimeScore = prediction.HalftimeScore;
            return(entity);
        }
Exemplo n.º 2
0
 public IActionResult OnGet(int id)
 {
     Prediction = _converter.ToPredictionEditModel(_predictionData.Get(id));
     if (Prediction == null)
     {
         return(NotFound());
     }
     return(Page());
 }
Exemplo n.º 3
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            Prediction = _predictionConverter.ToPredictionEditModel(_predictionData.Get(id));
            Id         = id;
            if (Prediction == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

//            var isAuthorized = await AuthorizationService.AuthorizeAsync(
//                User, Prediction,
//                PouleOperations.Update);
//            if (!isAuthorized.Succeeded)
//                return new ChallengeResult();

            return(Page());
        }
Exemplo n.º 4
0
        public void ShouldConvertPredictionEditModelToEntity()
        {
            var localtime           = new DateTime(2018, 5, 30, 9, 24, 37);
            var predictionEditModel = new PredictionEditModel
            {
                Date          = localtime,
                AwayTeam      = "AwayTeam",
                FulltimeScore = "3-4",
                HalftimeScore = "1-2",
                HomeTeam      = "HomeTeam",
                Username      = "******"
            };
            //no index and with index

//            var entity = _sut.ToEntity(predictionEditModel,_cotext);

//            Assert.AreEqual("3-4", entity.FulltimeScore);
//            Assert.AreEqual("1-2", entity.HalftimeScore);
        }