Beispiel #1
0
        public IHttpActionResult PostMostRecentLoggingEvent(MostRecentLoggingEvent mostRecentLoggingEvent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MostRecentLoggingEvents.Add(mostRecentLoggingEvent);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (MostRecentLoggingEventExists(mostRecentLoggingEvent.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = mostRecentLoggingEvent.ID }, mostRecentLoggingEvent));
        }
Beispiel #2
0
        public IHttpActionResult PutMostRecentLoggingEvent(long id, MostRecentLoggingEvent mostRecentLoggingEvent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public IHttpActionResult GetMostRecentLoggingEvent(long id)
        {
            MostRecentLoggingEvent mostRecentLoggingEvent = db.MostRecentLoggingEvents.Find(id);

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

            return(Ok(mostRecentLoggingEvent));
        }
Beispiel #4
0
        public IHttpActionResult DeleteMostRecentLoggingEvent(long id)
        {
            MostRecentLoggingEvent mostRecentLoggingEvent = db.MostRecentLoggingEvents.Find(id);

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

            db.MostRecentLoggingEvents.Remove(mostRecentLoggingEvent);
            db.SaveChanges();

            return(Ok(mostRecentLoggingEvent));
        }