Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public AccountEntityModel Create(AccountEntityModel model)
        {
            Context.Accounts.Add(model);
            Context.SaveChanges();

            return(model);
        }
Example #2
0
        public override void TestInit()
        {
            base.TestInit();

            // Create Test Account.
            _testAccount = AddAccount("Unit Test Account");
        }
Example #3
0
        protected void AddAccountMembership(UserEntityModel user, AccountEntityModel account)
        {
            // Add Account Membership.
            var userAccount = new UserAccountEntityModel
            {
                User      = user,
                Account   = account,
                CreatedBy = User
            };

            Context.UserAccounts.Add(userAccount);
            Context.SaveChanges();
            Trace.WriteLine($"Added Account Membership -> {user.UserName} => {account.Name}");
        }
Example #4
0
        protected AccountEntityModel AddAccount(string accountName)
        {
            // Create New Account.
            var account = new AccountEntityModel
            {
                Name      = accountName,
                StateId   = 1,
                CreatedBy = User
            };

            Context.Accounts.Add(account);
            Context.SaveChanges();
            Trace.WriteLine($"Added Test Account -> {account.Name}");
            return(Context.Accounts.FirstOrDefault(u => u.Name == accountName));
        }
Example #5
0
        public void CreateAccount(RegisterInputModel createAccount)
        {
            string name       = createAccount.FirstName + " " + createAccount.LastName;
            var    newAccount = new AccountEntityModel
            {
                Name          = name,
                Address       = createAccount.Address,
                Image         = createAccount.Image,
                Email         = createAccount.Email,
                FavouriteBook = createAccount.FavouriteBook
            };

            _db.Add(newAccount);
            _db.SaveChanges();
            Console.WriteLine("new account Success");
        }
Example #6
0
        protected ShopEntityModel AddShop(string shopName, AccountEntityModel account)
        {
            var shop = new ShopEntityModel
            {
                Name       = shopName,
                StateId    = 1,
                CurrencyId = 1,
                Account    = account,
                CreatedBy  = User
            };

            Context.Shops.Add(shop);
            Context.SaveChanges();
            Trace.WriteLine($"Added Test Shop -> {shop.Name}");
            return(Context.Shops.FirstOrDefault(s => s.Name == shopName));
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public AccountEntityModel Update(AccountEntityModel model)
        {
            Context.Configuration.AutoDetectChangesEnabled = true;

            var account = Get(model.AccountId);

            account.FirstName    = model.FirstName;
            account.LastName     = model.LastName;
            account.EmailAddress = model.EmailAddress;
            account.Password     = model.Password;

            account.ModifiedDate = DateTime.Now;

            Context.Entry(account).State = EntityState.Modified;
            Context.SaveChanges();

            return(account);
        }
Example #8
0
        public void EditAccount(EditAccountInputModel editAccount, string email)
        {
            var account = GetAccount(email);

            /*three if statements to check if string from the textboxes are empty
             *  and gives them their right values if they are empty
             */
            if (editAccount.Name == null)
            {
                editAccount.Name = account.Name;
            }
            if (editAccount.Address == null)
            {
                editAccount.Address = account.Address;
            }
            if (editAccount.Image == null)
            {
                editAccount.Image = account.Image;
            }
            if (editAccount.FavouriteBook == null)
            {
                editAccount.FavouriteBook = account.FavouriteBook;
            }
            var editedAccount = new AccountEntityModel
            {
                Id            = account.Id,
                Name          = editAccount.Name,
                Email         = account.Email,
                Address       = editAccount.Address,
                Image         = editAccount.Image,
                FavouriteBook = editAccount.FavouriteBook
            };

            _db.Update(editedAccount);
            _db.SaveChanges();
            Console.WriteLine("Account was Successfully Edited");
        }