public async Task <IHttpActionResult> PutBetParticipant(int id, BetParticipant betParticipant)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != betParticipant.Id)
            {
                return(BadRequest());
            }

            db.Entry(betParticipant).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BetParticipantExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> GetBetParticipant(int id)
        {
            BetParticipant betParticipant = await db.BetParticipants.FindAsync(id);

            if (betParticipant == null)
            {
                return(NotFound());
            }

            return(Ok(betParticipant));
        }
        public async Task <IHttpActionResult> PostBetParticipant(BetParticipant betParticipant)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            betParticipant.ApplicationUserId      = User.Identity.GetUserId();
            betParticipant.ApplicationUser.Point -= betParticipant.Bet.RequiredPoints;
            db.BetParticipants.Add(betParticipant);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = betParticipant.Id }, betParticipant));
        }
        public async Task <IHttpActionResult> DeleteBetParticipant(int id)
        {
            BetParticipant betParticipant = await db.BetParticipants.FindAsync(id);

            if (betParticipant == null)
            {
                return(NotFound());
            }

            db.BetParticipants.Remove(betParticipant);
            await db.SaveChangesAsync();

            return(Ok(betParticipant));
        }