コード例 #1
0
        public async Task <IHttpActionResult> PutGroupACategory(int id, GroupACategory groupACategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public async Task <IHttpActionResult> GetGroupACategory(int id)
        {
            GroupACategory groupACategory = await db.GroupACategories.FindAsync(id);

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

            return(Ok(groupACategory));
        }
コード例 #3
0
        public async Task <IHttpActionResult> PostGroupACategory(GroupACategory groupACategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.GroupACategories.Add(groupACategory);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = groupACategory.Id }, groupACategory));
        }
コード例 #4
0
        public async Task <IHttpActionResult> DeleteGroupACategory(int id)
        {
            GroupACategory groupACategory = await db.GroupACategories.FindAsync(id);

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

            db.GroupACategories.Remove(groupACategory);
            await db.SaveChangesAsync();

            return(Ok(groupACategory));
        }