Пример #1
0
        public IHttpActionResult PutLiveChat(int id, LiveChat liveChat)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Пример #2
0
        public IHttpActionResult PostLiveChat(LiveChat liveChat)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.LiveChats.Add(liveChat);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = liveChat.ID }, liveChat);
        }