public void ThemNhanVien(NhanVienViewModel register) { User user = new User(); user.TenDangNhap = register.TenDangNhap; user.TenDayDu = register.TenDayDu; user.MatKhau = BabyToys.Utilities.EditString.mahoa_md5(register.MatKhau); user.NgayTao = System.DateTime.Now; user.Email = register.Email; user.DiaChi = register.DiaChi; user.SoDienThoai = register.SoDienThoai; user.IdQuyen = register.IdQuyen; user.IsActive = true; db.Users.Add(user); db.SaveChanges(); }
public void SuaNhanVien(NhanVienViewModel u) { User user = new User(); user.Id = u.Id; user.TenDangNhap = u.TenDangNhap; user.TenDayDu = u.TenDayDu; user.MatKhau = u.MatKhau; user.NgayTao = u.NgayTao; user.Email = u.Email; user.DiaChi = u.DiaChi; user.SoDienThoai = u.SoDienThoai; user.IdQuyen = u.IdQuyen; user.IsActive = u.IsActive; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); }