Beispiel #1
0
        public IHttpActionResult PutMessage(int id, Message_tbl message)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult GetMessage(int id)
        {
            Message_tbl message = db.Message_tbl.Find(id);

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

            return(Ok(message));
        }
Beispiel #3
0
        public IHttpActionResult DeleteMessage(int id)
        {
            Message_tbl message = db.Message_tbl.Find(id);

            if (message == null)
            {
                return(NotFound());
            }
            db.SaveChanges();

            return(Ok(message));
        }
Beispiel #4
0
        public IHttpActionResult PostMessage(Message_tbl message)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Message_tbl.Add(message);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = message.MessageId }, message));
        }