예제 #1
0
        public async Task <Space> Create(SpaceCreate data, User user)
        {
            // Check if name is available.
            Space?existing = await repo.FindByName(data.Name);

            if (existing != null)
            {
                throw new SpaceNameAlreadyInUseException($"{data.Name} is unavailable.");
            }

            Space s = factory.Create(data, user);

            await repo.Add(s);

            await bus.Dispatch(new SpaceCreateEvent(s));

            return(s);
        }
예제 #2
0
 private Space Map(SpaceRecord rec) => factory.Create(rec.Id, rec.UserId, rec.Name, rec.Description, rec.CreationDate, rec.SubscriptionCount, rec.IsDefault);