示例#1
0
        public IHttpActionResult PutPointsHistory(int id, PointsHistory pointsHistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult PostPointsHistory(PointsHistory pointsHistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PointsHistories.Add(pointsHistory);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = pointsHistory.id }, pointsHistory));
        }
示例#3
0
        public IHttpActionResult DeletePointsHistory(int id)
        {
            PointsHistory pointsHistory = db.PointsHistories.Find(id);

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

            db.PointsHistories.Remove(pointsHistory);
            db.SaveChanges();

            return(Ok(pointsHistory));
        }