public override void CreateAccount(Account account) { using (var tran = new TransactionScope(_connName)) { var ds = DSAccount.Create(_connName); if (account.Owner == null) { account.Owner = GetTopLevelAccount(); } if (ds.FindByName(account.Name) != null) { tran.Rollback(); throw new DuplicatedEntityException("Account"); } ds.Insert(account); tran.Commit(); } }
public override void CreateAccount(out int id, string name, int? maxNumberOfUser, int? maxNumberOfDomainUser, int? maxNumberOfProjects, string companyName, string companyAddress1, string companyAddress2, string companyCity, string companyState, string companyZip, string creditCardNumber, CreditCardType creditCardType, string creditCardAddress1, string creditCardAddress2, string creditCardCity, string creditCardZip, bool? recurringBill, DateTime? accountExpirationDate, DateTime? creditCardExpiration, Account owner, string creditCardEmail, int? creditCardIdCountry, string creditCardState, string creditCardCardholder, string promoCode, Int32? companyIdCountry, String creditCardCvs, String companyPhone, string creditCardPhone, int? subscriptionLevelId, long? subscriptionId) { using (var tran = new TransactionScope(_connName)) { var ds = DSAccount.Create(_connName); if (ds.FindByName(name) != null) { tran.Rollback(); throw new DuplicatedEntityException("Account"); } var ce = new Account(); if (name != null) ce.Name = name; if (maxNumberOfUser != null) ce.MaxNumberOfUser = maxNumberOfUser; if (maxNumberOfDomainUser != null) ce.MaxNumberOfDomainUser = maxNumberOfDomainUser; if (maxNumberOfProjects != null) ce.MaxNumberOfProjects = maxNumberOfProjects; if (companyName != null) ce.CompanyName = companyName; if (companyAddress1 != null) ce.CompanyAddress1 = companyAddress1; if (companyAddress2 != null) ce.CompanyAddress2 = companyAddress2; if (companyCity != null) ce.CompanyCity = companyCity; if (companyState != null) ce.CompanyState = companyState; if (companyZip != null) ce.CompanyZip = companyZip; if (creditCardNumber != null) ce.CreditCardNumber = creditCardNumber; if (creditCardType != null) ce.CreditCardType = creditCardType; if (creditCardCvs != null) ce.CreditCardCvs = creditCardCvs; if (creditCardAddress1 != null) ce.CreditCardAddress1 = creditCardAddress1; if (creditCardAddress2 != null) ce.CreditCardAddress2 = creditCardAddress2; if (creditCardCity != null) ce.CreditCardCity = creditCardCity; if (creditCardZip != null) ce.CreditCardZip = creditCardZip; if (recurringBill != null) ce.RecurringBill = recurringBill; if (accountExpirationDate != null) ce.AccountExpirationDate = accountExpirationDate; if (creditCardExpiration != null) ce.CreditCardExpiration = creditCardExpiration; if (owner != null) ce.Owner = owner; if (creditCardEmail != null) ce.CreditCardEmail = creditCardEmail; if (creditCardIdCountry != null) ce.CreditCardIdCountry = creditCardIdCountry; if (creditCardState != null) ce.CreditCardState = creditCardState; if (creditCardCardholder != null) ce.CreditCardCardholder = creditCardCardholder; if (promoCode != null) ce.PromoCode = promoCode; if (companyIdCountry != null) ce.CompanyIdCountry = companyIdCountry; if (companyPhone != null) ce.CompanyPhone = companyPhone; if (creditCardPhone != null) ce.CreditCardPhone = creditCardPhone; if (subscriptionLevelId.HasValue) ce.SubscriptionLevel = new SubscriptionLevel { Id = subscriptionLevelId.Value }; if (subscriptionId.HasValue) ce.SubscriptionId = subscriptionId; ds.Insert(ce); tran.Commit(); id = ce.Id; } }
public override void AddUserToRole(string userName, string roleName) { using (var tran = new TransactionScope(_connName)) { var dsRole = DSRole.Create(_connName); var dsUser = DSSEOToolsetUser.Create(_connName); var user = dsUser.FindByName(userName); if (user == null) { tran.Rollback(); throw new Exception("User Not Found"); } user.UserRole = dsRole.FindByName(roleName); dsUser.Update(user); tran.Commit(); } }