コード例 #1
0
        public async Task <IActionResult> RemoveUserFromGroup(string userId, string groupId)
        {
            RemoveUserFromGroupDTO data = new RemoveUserFromGroupDTO {
                userId = userId, groupId = groupId
            };
            await Task.Run(() => grp.RemoveUserFromGroup(data));

            if ((await grp.GetGroupUsers(new GroupIdDTO {
                groupId = data.groupId
            })).Count == 0)
            {
                await grp.RemoveGroup(new GroupIdDTO { groupId = data.groupId });
            }
            return(Ok("User removed from group"));
        }
コード例 #2
0
 public Task <bool> RemoveUserFromGroup(RemoveUserFromGroupDTO data) => Task.Run(() =>
 {
     context.Userandgroup.Remove(context.Userandgroup.First(a => a.Userid == data.userId && a.Groupid == data.groupId));
     context.SaveChanges();
     return(true);
 });