예제 #1
0
        public void CreateGroup(GroupDto groupDto)
        {
            var group = GetGroup(groupDto);

            if (groupDto.UsersIds != null)
            {
                var users = _dbContext.Users.Where(item => groupDto.UsersIds.Contains(item.Id)).ToList();

                group.Users = users;
            }

            if (groupDto.ChildGroupsIds != null)
            {
                var childGroups = _dbContext.Groups.Where(item => groupDto.ChildGroupsIds.Contains(item.Id)).ToList();

                group.ChildGroups = childGroups;
            }

            group.CreatedDate = DateTime.UtcNow;

            _dbContext.Groups.Add(group);
            _dbContext.SaveChanges();
        }
예제 #2
0
 public void CreateUser(UserDto userDto)
 {
     _dbContext.Users.Add(GetUser(userDto));
     _dbContext.SaveChanges();
 }