Esempio n. 1
0
        public async Task <IHttpActionResult> PostDisscussion(Disscussion disscussion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Disscussions.Add(disscussion);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (DisscussionExists(disscussion.DisscussionId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = disscussion.DisscussionId }, disscussion));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> PutDisscussion(int id, Disscussion disscussion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> GetDisscussion(int id)
        {
            Disscussion disscussion = await db.Disscussions.FindAsync(id);

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

            return(Ok(disscussion));
        }
        public void showBookDisscussionDetail(Disscussion disscussion)
        {
            Glide.With(mContext)
            .Load(Constant.IMG_BASE_URL + disscussion.post.author.avatar)
            //.Placeholder(Resource.Drawable.avatar_default)
            .Transform(new GlideCircleTransform(mContext))
            .Into(headerViewHolder.ivAvatar);

            headerViewHolder.tvNickName.Text     = (disscussion.post.author.nickname);
            headerViewHolder.tvTime.Text         = (FormatUtils.getDescriptionTimeFromDateString(disscussion.post.created));
            headerViewHolder.tvTitle.Text        = (disscussion.post.title);
            headerViewHolder.tvContent.Text      = (disscussion.post.content);
            headerViewHolder.tvCommentCount.Text = (Java.Lang.String.Format(mContext.GetString(Resource.String.comment_comment_count), disscussion.post.commentCount));
        }
Esempio n. 5
0
        public async Task <IHttpActionResult> DeleteDisscussion(int id)
        {
            Disscussion disscussion = await db.Disscussions.FindAsync(id);

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

            db.Disscussions.Remove(disscussion);
            await db.SaveChangesAsync();

            return(Ok(disscussion));
        }