예제 #1
0
 public string ValidateInstance(Instance instance)
 {
     if (string.IsNullOrEmpty(instance.InstanceName))
         return Messages.EmptyInstanceName;
     if (Db.IsExistInstanceName(instance.InstanceName))
         return Messages.ExistsInstanceName;
     return null;
 }
예제 #2
0
        public MethodResult<int> CreateInstance(string instanceName)
        {
            using (var transaction = new TransactionScope())
            {
                var instance = new Instance
                {
                    InstanceName = instanceName
                };
                var validateError = ValidateInstance(instance);
                if (!string.IsNullOrEmpty(validateError))
                    return new MethodResult<int> { ErrorMessage = validateError };

                Db.Save(instance);
                Db.SetInstanceId(instance.InstanceId);

                var adminRoleId = InsertSystemRoles(instance.InstanceId);
                Db.AddUserInstance();
                Db.AddUserRole(adminRoleId);
                transaction.Complete();
                return new MethodResult<int>(instance.InstanceId);

            }
        }