コード例 #1
0
        public IHttpActionResult PostIncome_Category(Income_Category income_Category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Income_Category.Add(income_Category);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (Income_CategoryExists(income_Category.IncomeCategoryId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = income_Category.IncomeCategoryId }, income_Category));
        }
コード例 #2
0
        public IHttpActionResult PutIncome_Category(decimal id, Income_Category income_Category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public IHttpActionResult GetIncome_Category(decimal id)
        {
            Income_Category income_Category = db.Income_Category.Find(id);

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

            return(Ok(income_Category));
        }
コード例 #4
0
        public IHttpActionResult DeleteIncome_Category(decimal id)
        {
            Income_Category income_Category = db.Income_Category.Find(id);

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

            db.Income_Category.Remove(income_Category);
            db.SaveChanges();

            return(Ok(income_Category));
        }