using System;
using System.Linq;
using DevExpress.DevAV.Common.ViewModel;
using DevExpress.DevAV.DevAVDbDataModel;
using DevExpress.Mvvm.DataModel;
using DevExpress.Mvvm.POCO;
using DevExpress.Mvvm.ViewModel;
namespace DevExpress.DevAV.ViewModels {
///
/// Represents the single Employee object view model.
///
public partial class EmployeeViewModel : SingleObjectViewModel {
///
/// Creates a new instance of EmployeeViewModel as a POCO view model.
///
/// A factory used to create a unit of work instance.
public static EmployeeViewModel Create(IUnitOfWorkFactory unitOfWorkFactory = null) {
return ViewModelSource.Create(() => new EmployeeViewModel(unitOfWorkFactory));
}
///
/// Initializes a new instance of the EmployeeViewModel class.
/// This constructor is declared protected to avoid undesired instantiation of the EmployeeViewModel type without the POCO proxy factory.
///
/// A factory used to create a unit of work instance.
protected EmployeeViewModel(IUnitOfWorkFactory unitOfWorkFactory = null)
: base(unitOfWorkFactory ?? UnitOfWorkSource.GetUnitOfWorkFactory(), x => x.Employees, x => x.FullName) {
}
///
/// The view model that contains a look-up collection of Pictures for the corresponding navigation property in the view.
///
public IEntitiesViewModel LookUpPictures {
get {
return GetLookUpEntitiesViewModel(
propertyExpression: (EmployeeViewModel x) => x.LookUpPictures,
getRepositoryFunc: x => x.Pictures);
}
}
///
/// The view model that contains a look-up collection of Probations for the corresponding navigation property in the view.
///
public IEntitiesViewModel LookUpProbations {
get { return GetLookUpEntitiesViewModel((EmployeeViewModel x) => x.LookUpProbations, x => x.Probations); }
}
///
/// The view model for the EmployeeOwnedTasks detail collection.
///
public CollectionViewModelBase EmployeeOwnedTasksDetails {
get {
return GetDetailsCollectionViewModel(
propertyExpression: (EmployeeViewModel x) => x.EmployeeOwnedTasksDetails,
getRepositoryFunc: x => x.Tasks,
foreignKeyExpression: x => x.OwnerId,
navigationExpression: x => x.Owner);
}
}
///
/// The view model for the EmployeeEvaluations detail collection.
///
public CollectionViewModelBase EmployeeEvaluationsDetails {
get {
return GetDetailsCollectionViewModel(
propertyExpression: (EmployeeViewModel x) => x.EmployeeEvaluationsDetails,
getRepositoryFunc: x => x.Evaluations,
foreignKeyExpression: x => x.EmployeeId,
navigationExpression: x => x.Employee);
}
}
}
}