Example #1
0
        public void TestAddUserToAccount()
        {
            var conn = new EntityConnection(SerializationTests.ConnectionString);
            var repo = new ModuleRepository(conn);
            var account = new Account {
                Name = "DBServer",
                SubdomainName = "dbserver"
            };
            var user = repo.GetUserByName("dbserver");
            account.Users.Add(user);
            repo.AddAccount(account);
            repo.Save();

            var newAcct = repo.GetAccountByName("dbserver");

            Assert.IsNotNull(newAcct);

            var newUser = newAcct.Users.FirstOrDefault(u => u.UserId == user.UserId);

            Assert.IsNotNull(newUser);
        }
Example #2
0
        public ActionResult CreateAccount(AccountViewModel acct, string userName, string email, string password, string confirmPassword)
        {
            if (!ModelState.IsValid) {
                return View(acct);
            }

            var dbAcct = new Account {
                Name = acct.Name,
                SubdomainName = acct.Subdomain,
                Plan = ModRepository.GetPlanByName("Unlimited")
            };

            if (Request.Files.Count > 0 &&
                Request.Files[0].ContentLength > 0) {

                var user = Membership.GetUser() as UACUser;
                var imgInfo = user.SaveImage(Request.Files[0]);
                dbAcct.Logo = imgInfo.FullRelativePath;
            }

            if (!CreateNewUser(userName, email, password, confirmPassword)) {
                return View(acct);
            }

            var createdUser = ModRepository.GetUserByName(userName);

            dbAcct.Users.Add(createdUser);

            ModRepository.AddAccount(dbAcct);
            ModRepository.Save();

            TempData["Message"] = "Conta criada com sucesso!";
            return RedirectToAction("ListAccounts");
        }
Example #3
0
 /// <summary>
 /// Create a new Account object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="subdomainName">Initial value of the SubdomainName property.</param>
 public static Account CreateAccount(global::System.Int32 id, global::System.String name, global::System.String subdomainName)
 {
     Account account = new Account();
     account.Id = id;
     account.Name = name;
     account.SubdomainName = subdomainName;
     return account;
 }
Example #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Account EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAccount(Account account)
 {
     base.AddObject("Account", account);
 }
Example #5
0
 public void AddAccount(Account acct)
 {
     db.AddToAccount(acct);
 }
Example #6
0
 public void AddAccount(Account a)
 {
     throw new NotImplementedException();
 }