Beispiel #1
0
        // POST: odata/IssueBookHistories
        public IHttpActionResult Post(IssueBookHistory issueBookHistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.IssueBookHistories.Add(issueBookHistory);
            db.SaveChanges();

            return(Created(issueBookHistory));
        }
Beispiel #2
0
        // DELETE: odata/IssueBookHistories(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            IssueBookHistory issueBookHistory = db.IssueBookHistories.Find(key);

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

            db.IssueBookHistories.Remove(issueBookHistory);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        // PUT: odata/IssueBookHistories(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <IssueBookHistory> patch)
        {
            Validate(patch.GetEntity());

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

            IssueBookHistory issueBookHistory = db.IssueBookHistories.Find(key);

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

            patch.Put(issueBookHistory);

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

            return(Updated(issueBookHistory));
        }