public ApplicationGroup Delete(int id)
        {
            var appGroup = _appGroupRepository.GetSingleById(id);

            //xoá các roles thuộc group
            _appRoleGroupRepository.DeleteMulti(s => s.GroupId == id);
            //xoá các user thuộc group
            _appUserGroupRepository.DeleteMulti(s => s.GroupId == id);
            return(_appGroupRepository.Delete(appGroup));
        }
Exemple #2
0
 public bool AddUserToGroups(IEnumerable <ApplicationUserGroup> groups, string userId)
 {
     _appUserGroupRepository.DeleteMulti(x => x.UserId == userId);
     foreach (var userGroup in groups)
     {
         _appUserGroupRepository.Add(userGroup);
     }
     return(true);
 }
 public async Task <bool> AddUserToGroups(IEnumerable <ApplicationUserGroup> userGroups, string userId)
 {
     _appUserGroupRepository.DeleteMulti(x => x.UserId == userId);
     foreach (var userGroup in userGroups)
     {
         await Task.FromResult(_appUserGroupRepository.Add(userGroup));
     }
     return(true);
 }