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(); }
public void CreateUser(UserDto userDto) { _dbContext.Users.Add(GetUser(userDto)); _dbContext.SaveChanges(); }