Пример #1
0
        public async Task <ActionResult> Bet([FromBody] Models.Bet bet)
        {
            if (ModelState.IsValid)
            {
                var roulette = await _repository.GetRoulette(bet.RouletteId);

                if (roulette != null)
                {
                    if (roulette.Status)
                    {
                        var result = _mapper.Map <Entities.Bet>(bet);
                        return(Ok(await _repository.BetRoulette(bet.RouletteId, result)));
                    }
                    else
                    {
                        return(BadRequest("Error ruleta Cerrada"));
                    }
                }
                else
                {
                    return(BadRequest("Identificador de ruleta no existe"));
                }
            }

            return(BadRequest(ModelState));
        }
Пример #2
0
        public async Task <IActionResult> OnGetAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bet = await _context.BetItems.FirstOrDefaultAsync(m => m.Id == id);

            if (Bet == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #3
0
        public async Task <IActionResult> OnPostAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bet = await _context.BetItems.FindAsync(id);

            if (Bet != null)
            {
                _context.BetItems.Remove(Bet);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Пример #4
0
 public IHttpActionResult Bet(int tournamentId, int marketId, int selectionId)
 {
     using (var db = new Adriana42Context())
     {
         var repository = new Repository <Models.Bet>(db);
         var bet        = new Models.Bet
         {
             Date         = DateTime.UtcNow,
             TournamentId = tournamentId,
             MarketId     = marketId,
             SelectionId  = selectionId,
             UserId       = UserId
         };
         repository.Add(bet);
         db.SaveChanges();
         return(Ok());
     }
 }