Beispiel #1
0
        public async Task <IHttpActionResult> Post(UserGroup userGroup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.UserGroups.Add(userGroup);
            await db.SaveChangesAsync();

            return(Ok(UserGroupsViewModel.MapFrom(userGroup)));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> Delete(long id)
        {
            UserGroup userGroup = await db.UserGroups.FindAsync(id);

            if (userGroup == null)
            {
                return(NotFound());
            }
            else
            {
                db.UserGroups.Remove(userGroup);
                await db.SaveChangesAsync();

                return(Ok(UserGroupsViewModel.MapFrom(userGroup)));
            }
        }