Ejemplo n.º 1
0
        public GroupDto SaveGroup(GroupDto groupDto)
        {
            Group group = _groupDtoConverter.Convert(groupDto);

            group = _dbGroupController.SaveGroup(group);
            return(_groupDtoConverter.Convert(group));
        }
Ejemplo n.º 2
0
 public Site Convert(SiteDto site, SecureSiteData originalSecureSiteData)
 {
     return(new Site
     {
         Description = site.Description,
         SiteId = site.Id,
         Name = site.Name,
         Groups = _groupDtoConverter.Convert(site.Groups),
         SecureSiteData = ConvertSecureSiteData(site, originalSecureSiteData)
     });
 }
Ejemplo n.º 3
0
        public List <UserDto> ConvertFromUsersWithGroups(Dictionary <User, List <Group> > users)
        {
            List <UserDto> result = new List <UserDto>();

            foreach (KeyValuePair <User, List <Group> > pair in users)
            {
                UserDto user = Convert(pair.Key);
                user.Groups = _groupDtoConverter.Convert(pair.Value);
                result.Add(user);
            }
            return(result);
        }
Ejemplo n.º 4
0
        public int SaveUser(UserDto userDto)
        {
            User         userToSave = _userDtoConverter.Convert(userDto);
            List <Group> userGroups = _groupDtoConverter.Convert(userDto.Groups);

            if (userDto.Account != null && userDto.Account.NeedSaveAccount)
            {
                UserAccount userAccount = _accountDtoConverter.Convert(userDto.Account);
                _userSaver.SaveUser(userToSave, userAccount);
            }
            else
            {
                userToSave = _userSaver.SaveUser(userToSave);
            }
            _userSaver.SaveUserGroups(userToSave.UserId, userGroups.Select(item => item.Id).ToList());
            return(userToSave.UserId);
        }
Ejemplo n.º 5
0
        public UserDto GetUser(int userId)
        {
            User user = _dbUserController.GetUser(userId);

            if (user == null)
            {
                return(null);
            }
            List <Group> groups = _dbUserController.GetUserGroups(user.UserId);

            UserDto userDto = _userDtoConverter.Convert(user);

            userDto.Groups = _groupDtoConverter.Convert(groups);

            UserAccount userAccount = _dbAuthController.GetUserAccount(user.UserId);

            if (userAccount != null)
            {
                userDto.Account = _userAccountDtoConverter.Convert(userAccount);
            }

            return(userDto);
        }
Ejemplo n.º 6
0
        public List <GroupDto> GetGroupsDto()
        {
            List <Group> groups = _dbGroupController.GetGroups();

            return(_groupDtoConverter.Convert(groups));
        }