예제 #1
0
        public IHttpActionResult PutMessageReply(int id, MessageReply messageReply)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MessageReplyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult GetMessageReply(int id)
        {
            MessageReply messageReply = db.MessageReplies.Find(id);

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

            return(Ok(messageReply));
        }
예제 #3
0
        public IHttpActionResult DeleteMessageReply(int id)
        {
            MessageReply messageReply = db.MessageReplies.Find(id);

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

            db.MessageReplies.Remove(messageReply);
            db.SaveChanges();

            return(Ok(messageReply));
        }
예제 #4
0
        public HttpResponseMessage PostMessageReply(MessageReply messageReply)
        {
            string      token       = Request.Headers.Authorization.Parameter;
            JwtAuthUtil jwtAuthUtil = new JwtAuthUtil();
            int         Mid         = Convert.ToInt32(jwtAuthUtil.GetId(token));

            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            var msg = db.Messages.Find(messageReply.MessageId);

            msg.PlannerId = Mid;



            db.MessageReplies.Add(messageReply);
            db.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK));
        }