public void Create(CircleCreateCommand command)
        {
            var ownerId = new UserId(command.UserId);
            var owner   = userRepository.Find(ownerId);

            if (owner == null)
            {
                throw new Exception("サークルオーナーとなるユーザーが見つかりませんでした。");
            }

            var name   = new CircleName(command.Name);
            var circle = circleFactory.Create(name, owner);

            if (circleService.Exists(circle))
            {
                throw new Exception("サークルは既に存在しています。");
            }

            circleRepository.Save(circle);
        }
Exemple #2
0
        public Circle(CircleId id, CircleName name, User owner, List <User> members)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (owner == null)
            {
                throw new ArgumentNullException(nameof(owner));
            }
            if (members == null)
            {
                throw new ArgumentNullException(nameof(members));
            }

            this.Id      = id;
            this.Name    = name;
            this.Owner   = owner;
            this.Members = members;
        }
Exemple #3
0
 public Circle Find(CircleName name)
 {
     return(circles.First(it => it.Name.Equals(name)));
 }
Exemple #4
0
        public Circle Create(CircleName name, User owner)
        {
            var id = new CircleId(Guid.NewGuid().ToString());

            return(new Circle(id, name, owner, new List <User>()));
        }