예제 #1
0
        public async Task <IHttpActionResult> PutCategory_SubCategory(int id, Category_SubCategory category_SubCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Category_SubCategoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public async Task <IHttpActionResult> GetCategory_SubCategory(int id)
        {
            Category_SubCategory category_SubCategory = await db.Category_SubCategory.FindAsync(id);

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

            return(Ok(category_SubCategory));
        }
예제 #3
0
        public async Task <IHttpActionResult> PostCategory_SubCategory(Category_SubCategory category_SubCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Category_SubCategory.Add(category_SubCategory);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = category_SubCategory.Id }, category_SubCategory));
        }
예제 #4
0
        public async Task <IHttpActionResult> DeleteCategory_SubCategory(int id)
        {
            Category_SubCategory category_SubCategory = await db.Category_SubCategory.FindAsync(id);

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

            db.Category_SubCategory.Remove(category_SubCategory);
            await db.SaveChangesAsync();

            return(Ok(category_SubCategory));
        }
예제 #5
0
 public void AddCategory_Subcategory(Category_SubCategory entity)
 {
     db.Category_SubCategory.Add(entity);
     db.SaveChanges();
 }