public static Task AddServerNode(ServerNode model) // this process is too expensive...
        {
            var foundCluster = _clusterRepository.FindById(model.ClusterId);

            var nodesByCluster = _repo.FindByClusterId(model.ClusterId);

            int currentSize = model.ClusterId != null && nodesByCluster != null?nodesByCluster.Count() : 0;

            var foundService = _serviceRepo.FindById(model.ServiceId);

            if (foundCluster != null && foundCluster.MaxSize < currentSize)
            {
                throw new System.Exception(string.Format("Max Size for Cluster Exceeded, Current Limit is {0}", foundCluster.MaxSize));
            }
            else if (foundService == null)
            {
                throw new System.Exception(string.Format("Service Does Not Exist, To Create a Cluster a Valid Serice Should Exist"));
            }

            return(_repo.Create(model));
        }
Esempio n. 2
0
 public static ClusterModel FindById(string id) => _repo.FindById(id);