/// <summary> /// Initializes a new instance of the CheckListVehicleViewModel class. /// This constructor is declared protected to avoid undesired instantiation of the CheckListVehicleViewModel type without the POCO proxy factory. /// </summary> /// <param name="unitOfWorkFactory">A factory used to create a unit of work instance.</param> protected CheckListVehicleViewModel(IUnitOfWorkFactory <INextBOUnitOfWork> unitOfWorkFactory = null, UnitOfWorkPolicy unitOfWorkPolicy = UnitOfWorkPolicy.Individual) : base(unitOfWorkFactory ?? UnitOfWorkSource.GetUnitOfWorkFactory(), x => x.CheckListByVehicles, query => query.Where(CheckListByVehicle => CheckListByVehicle.CreateDate.Value.Date >= startDate.Date && CheckListByVehicle.CreateDate.Value.Date >= startDate.Date && CheckListByVehicle.Vehicle.PilotId == (pilotId == 0 ? CheckListByVehicle.Vehicle.PilotId: pilotId) && CheckListByVehicle.VehicleId == (vehicleId == 0 ? CheckListByVehicle.VehicleId : vehicleId)), unitOfWorkPolicy: unitOfWorkPolicy) { LookUpPilot = this.CreateUnitOfWork().Users.Where(x => x.Pilot != null).ToList(); User pilot = new User { Id = 0, Name = "todos" }; LookUpPilot.Insert(0, pilot); LookUpVehicle = this.CreateUnitOfWork().Vehicles.ToList(); Vehicle vehicle = new Vehicle { Brand = "Todos", Id = 0 }; LookUpVehicle.Insert(0, vehicle); }
/// <summary> /// Initializes a new instance of the DeliveryHistoryCollectionViewModel class. /// This constructor is declared protected to avoid undesired instantiation of the DeliveryHistoryCollectionViewModel type without the POCO proxy factory. /// </summary> /// <param name="unitOfWorkFactory">A factory used to create a unit of work instance.</param> protected DeliveryHistoryCollectionViewModel(IUnitOfWorkFactory <INextBOUnitOfWork> unitOfWorkFactory = null, UnitOfWorkPolicy unitOfWorkPolicy = UnitOfWorkPolicy.Individual) : base(unitOfWorkFactory ?? UnitOfWorkSource.GetUnitOfWorkFactory(), x => x.Tasks, query => query.Where(task => task.CreatedDate.Value.Date >= startDate.Date && task.CreatedDate.Value.Date <= endDate.Date && task.DriverId == (pilotId == 0 ? task.DriverId : pilotId) && task.VehicleId == (vehicleId == 0 ? task.VehicleId : vehicleId)), unitOfWorkPolicy: unitOfWorkPolicy) { try { User pilotDefault = new User(); pilotDefault.Name = "Todos"; pilotDefault.Id = 0; LookUpPilot = this.CreateUnitOfWork().Users.Where(x => x.Pilot != null).ToList(); LookUpPilot.Insert(0, pilotDefault); Vehicle vehicleDefault = new Vehicle(); vehicleDefault.Brand = "Todos"; vehicleDefault.Id = 0; LookUpVehicle = this.CreateUnitOfWork().Vehicles.ToList(); LookUpVehicle.Insert(0, vehicleDefault); } catch (Exception ex) { MessageBoxService.ShowMessage(GetStringValue(Next.Enums.Enums.MessageError.WindowError) + ex.Message, ex.Message, MessageButton.OK, MessageIcon.Error); } }