/// <summary> /// Custom Execution /// </summary> /// <param name="paramater"></param> private void _executeMethod(object paramater) { using (var _context = new DbEmployeeContext()) { TblEmployee employee = new TblEmployee() { Id = Id, Name = Name, Contact = Contact, Email = Email, Dob = new DateTime(), Address = "Ahmedabad" }; _context.TblEmployees.Update(employee); _context.SaveChanges(); } var window = Application.Current.Windows.OfType <Window>().SingleOrDefault(w => w.IsActive); window.Close(); MainWindow main = new MainWindow(); main.DataContext = new EmployeeViewModel(); main.Show(); MessageBox.Show("Updated Successfully."); }
/// <summary> /// Loads the data. /// </summary> private void LoadData() { using (var _context = new DbEmployeeContext()) { var Employees = _context.TblEmployees.ToList(); foreach (var employee in Employees) { Employee Employee = new Employee() { Id = employee.Id, Name = employee.Name, Contact = employee.Contact, Email = employee.Email }; _employees.Add(Employee); } } }
/// <summary> /// Initializes a new instance of the <see cref="EmployeeRepository"/> class. /// </summary> /// <param name="context">The context.</param> public EmployeeRepository(DbEmployeeContext context) { _context = context; }