Esempio n. 1
0
        public async Task <IHttpActionResult> Putusers_comments(int id, users_comments users_comments)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> Getusers_comments(int id)
        {
            users_comments users_comments = await db.users_comments.FindAsync(id);

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

            return(Ok(users_comments));
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> Postusers_comments(users_comments users_comments)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.users_comments.Add(users_comments);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = users_comments.id }, users_comments));
        }
Esempio n. 4
0
        public async Task <IHttpActionResult> Deleteusers_comments(int id)
        {
            users_comments users_comments = await db.users_comments.FindAsync(id);

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

            db.users_comments.Remove(users_comments);
            await db.SaveChangesAsync();

            return(Ok(users_comments));
        }