示例#1
0
        public int SaveMediaServiceAccount(MediaServicesAccountConfig config)
        {
            int added = 0;
            MediaServicesAccount newAcct = new MediaServicesAccount
            {
                AccountName      = config.AccountName,
                SubscriptionName = config.MetaData.AzureSubscriptionId,
                DataCenter       = config.MetaData.ResourceGroup,
                Location         = config.MetaData.Location,
                AccountCreated   = DateTime.UtcNow.Date
            };

            ExecuteWriteQuery(dataContext =>
            {
                //check for the existing account first
                var acct = dataContext.MediaServicesAccounts
                           .FirstOrDefault(account => account.AccountName == config.AccountName);
                if (acct == null)
                {
                    //only add if the account is not in the db
                    dataContext.MediaServicesAccounts.Add(newAcct);
                    added = dataContext.SaveChanges();
                }
                else
                {
                    added = acct.AccountId;
                }
            });
            return(added);
        }
示例#2
0
 public List <MediaServicesAccount> SaveMediaServiceAccount(MediaServicesAccount acct, AzureDataConfig deploymentToTest)
 {
     using (var dataContext = new AMSDashboardEntities1(GetConnection(deploymentToTest).ConnectionString))
     {
         dataContext.MediaServicesAccounts.Add(acct);
         dataContext.SaveChanges();
         return(GetAccounts());
     }
 }