public int Add(Employee entity) { entity.Password = PasswordHashUtility.HashString(entity.Password); _context.Employees.Add(entity); _context.SaveChanges(); return(entity.Id); }
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(); }
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" }); }