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); }
public EmployeeController(AzureDatabaseContext context) { _context = context; if (_context.Employees.Count() == 0) { _context.Employees.Add(new Employee("Derick", "Gross", 5, "Development")); _context.SaveChanges(); } }
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(); } }