Пример #1
0
    public static Space Initialize(ISpaceChecker spaceValidatorService, Guid userId, string name,
                                   string backgroundImage, Visibility visibility)
    {
        if (!spaceValidatorService.IsUniqueNameInUserSpace(userId, name))
        {
            throw new SpaceNameAlreadyExistsException();
        }

        var space = new Space(Guid.NewGuid());

        space.ApplyChange(new SpaceCreatedEvent(space.Id, space.GetNextVersion(), userId, name, backgroundImage,
                                                visibility));

        return(space);
    }
Пример #2
0
    public void Update(ISpaceChecker validator, string name, string backgroundImage, Visibility visibility)
    {
        if (_isDeleted)
        {
            throw new SpaceHasBeenDeletedException();
        }

        if (_name != name)
        {
            if (!validator.IsUniqueNameInUserSpace(_creatorId, name))
            {
                throw new SpaceNameAlreadyExistsException();
            }
        }

        ApplyChange(new SpaceUpdatedEvent(
                        Id,
                        GetNextVersion(),
                        name,
                        backgroundImage,
                        visibility));
    }