Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ua"></param>
 /// <returns>Whether the object was added to the database</returns>
 public bool Create(UserAccount ua)
 {
     if (!Contains(ua))
     {
         _dbc.UserAccounts.Add(ua);
         _dbc.SaveChanges();
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        public MembershipCreateStatus CreateUser(UserAccountModel acct)
        {
            System.Console.WriteLine("Account with Email:" + acct.Email + "and Password" + acct.Password);
            // attempt to add the account to the database
            userAcctDBContext.UserAccounts.Add(new UserAccount(acct.Email, acct.Password));

            try
            {
                userAcctDBContext.SaveChanges(); // persist it!
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
            {
                // if its an updateexception, we KNOW the user already exists
                return(MembershipCreateStatus.DuplicateEmail);
            }
            // TODO: Add the new instance of SampleItem to the collection
            return(MembershipCreateStatus.Success);
        }