예제 #1
0
 public int Add(Employee entity)
 {
     entity.Password = PasswordHashUtility.HashString(entity.Password);
     _context.Employees.Add(entity);
     _context.SaveChanges();
     return(entity.Id);
 }
예제 #2
0
        public void Update(Employee dbEntity, Employee entity)
        {
            dbEntity.Email        = entity.Email;
            dbEntity.Password     = PasswordHashUtility.HashString(entity.Password);
            dbEntity.EmployeeType = entity.EmployeeType;
            dbEntity.Name         = entity.Name;
            dbEntity.Position     = entity.Position;

            _context.SaveChanges();
        }
예제 #3
0
 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     modelBuilder.Entity <Employee>().HasData(new Employee
     {
         Id           = 1,
         Email        = "*****@*****.**",
         Password     = PasswordHashUtility.HashString("abc123"),
         EmployeeType = "Admin",
         Name         = "Bob",
         Position     = "Manager"
     }, new Employee
     {
         Id           = 2,
         Email        = "*****@*****.**",
         Password     = PasswordHashUtility.HashString("abc123"),
         EmployeeType = "General",
         Name         = "John",
         Position     = "Developer"
     });
 }