Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new user and account
        /// </summary>
        /// <param name="user">The user</param>
        /// <param name="password">The account</param>
        public void AddUserAndAccount(User user, string password)
        {
            var db = new ReScrumEntities();

            var newUser = new data.User
            {
                EmployeeNumber  = user.EmployeeNumber,
                Forename        = user.Forename,
                Surname         = user.Surname,
                Email           = user.Email,
                JobTitle        = user.JobTitle,
                IsLineManager   = user.IsLineManager,
                IsAdministrator = user.IsAdministrator,
            };

            db.Users.Add(newUser);

            var team = db.Teams.Where(t => t.TeamId == user.Team).FirstOrDefault();

            newUser.Teams.Add(team);

            var account = new data.Account
            {
                User     = newUser,
                Password = Encoding.UTF8.GetBytes(password),
            };

            db.Accounts.Add(account);

            db.SaveChanges();
        }
Ejemplo n.º 2
0
        public bool Addacount(DTO.Account accountDTO)
        {
            var _context = new InteractiveDBContext();
            var account  = new DataLayer.Models.Account();

            using (_context)
            {
                account.AccountNumber        = accountDTO.AccountNumber;
                account.Code                 = accountDTO.Code;
                account.OutstandingBalance   = accountDTO.OutstandingBalance;
                account.PersonCode           = accountDTO.PersonCode;
                account.PersonCodeNavigation = accountDTO.PersonCodeNavigation;
                account.Transactions         = (ICollection <Transaction>)accountDTO.Transactions;

                _context.Accounts.Add(account);

                _context.SaveChanges();
            }

            return(true);
        }