Exemple #1
0
        public async Task <IHttpActionResult> PutBetComment(int id, BetComment betComment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public async Task <IHttpActionResult> GetBetComment(int id)
        {
            BetComment betComment = await db.BetComments.FindAsync(id);

            if (betComment == null)
            {
                return(NotFound());
            }
            return(Ok(betComment));
        }
Exemple #3
0
        public async Task <IHttpActionResult> PostBetComment(BetComment betComment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            betComment.ApplicationUserId = User.Identity.GetUserId();
            db.BetComments.Add(betComment);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = betComment.Id }, betComment));
        }
Exemple #4
0
        public async Task <IHttpActionResult> DeleteBetComment(int id)
        {
            BetComment betComment = await db.BetComments.FindAsync(id);

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

            db.BetComments.Remove(betComment);
            await db.SaveChangesAsync();

            return(Ok(betComment));
        }