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); }
private Space Map(SpaceRecord rec) => factory.Create(rec.Id, rec.UserId, rec.Name, rec.Description, rec.CreationDate, rec.SubscriptionCount, rec.IsDefault);