예제 #1
0
        public User Create(UserViewModel userViewModel)
        {
            if (userViewModel.Password == null)
            {
                throw new ArgumentNullException("password");
            }
            if (string.IsNullOrWhiteSpace(userViewModel.Password))
            {
                throw new ArgumentException("Invalid/empty/whitespace-only value.", "password");
            }

            CreateHashedPassword(userViewModel.Password, out byte[] hash, out byte[] salt);

            User user = new User
            {
                Username     = userViewModel.Username,
                PasswordHash = hash,
                PasswordSalt = salt
            };

            _context.Users.Add(user);
            _context.SaveChanges();

            return(user);
        }
예제 #2
0
        public EmployeeController(AzureDatabaseContext context)
        {
            _context = context;

            if (_context.Employees.Count() == 0)
            {
                _context.Employees.Add(new Employee("Derick", "Gross", 5, "Development"));
                _context.SaveChanges();
            }
        }
예제 #3
0
        public DependentController(AzureDatabaseContext context)
        {
            _context = context;

            if (_context.Dependents.Count() == 0)
            {
                _context.Dependents.Add(new Dependent
                {
                    DependentId    = 1,
                    EmployeeId     = 1,
                    FirstName      = "DeAnna",
                    LastName       = "Gross",
                    Cost           = 500,
                    DiscountFactor = DeductionHelpers.CalculateDiscountFactor("DeAnna")
                });
                _context.SaveChanges();
            }
        }