コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// The class gets an instance of The DataAccessService
 /// </summary>
 public MainViewModel(IDataAccessService servPxy)
 {
     _serviceProxy = servPxy;
     Employees = new ObservableCollection<EmployeeInfo>();
     EmpInfo = new EmployeeInfo(); 
     ReadAllCommand = new RelayCommand(GetEmployees);
     SaveCommand = new RelayCommand<EmployeeInfo>(SaveEmployee);
     SearchCommand = new RelayCommand(SearchEmployee);
     SendEmployeeCommand = new RelayCommand<EmployeeInfo>(SendEmployeeInfo);
     ReceiveEmployeeInfo();
 }
コード例 #2
0
 /// <summary>
 /// Method to Save Employees. Once the Employee is added in the database
 /// it will be added in the Employees observable collection and Property Changed will be raised
 /// </summary>
 /// <param name="emp"></param>
 void SaveEmployee(EmployeeInfo emp)
 {
     EmpInfo.EmpNo =  _serviceProxy.CreateEmployee(emp);
     if(EmpInfo.EmpNo!=0)
     { 
         Employees.Add(EmpInfo);
         RaisePropertyChanged("EmpInfo");
     }
 }
コード例 #3
0
 /// <summary>
 /// The method to send the selected Employee from the DataGrid on UI
 /// to the View Model
 /// </summary>
 /// <param name="emp"></param>
 void SendEmployeeInfo(EmployeeInfo emp)
 {
     if(emp!=null)
     { 
         Messenger.Default.Send<MessageCommunicator>(new MessageCommunicator() { 
           Emp = emp
         });
     }
 }
コード例 #4
0
ファイル: Services.cs プロジェクト: wondial/wpf-mvvmlight
 public int CreateEmployee(EmployeeInfo Emp)
 {
     context.EmployeeInfoes.Add(Emp);
     context.SaveChanges();
     return Emp.EmpNo;
 }