diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-23 11:07:15 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-23 11:07:15 +0300 |
| commit | a8718859eea4329ec9ecd3f7155e0001aa610c3d (patch) | |
| tree | 6bd3d16da02cd66923698cbfd3fe4d25fb425974 /Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs | |
| parent | ee43df835127c733d4eeb2c18b2b2fbc7bbf044b (diff) | |
| download | Tango-a8718859eea4329ec9ecd3f7155e0001aa610c3d.tar.gz Tango-a8718859eea4329ec9ecd3f7155e0001aa610c3d.zip | |
Added ObservablesContextAdapter and it's interactions.
Diffstat (limited to 'Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs | 97 |
1 files changed, 5 insertions, 92 deletions
diff --git a/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs index d265fbe01..49c80695f 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs @@ -19,6 +19,7 @@ namespace Tango.BL public partial class ObservablesContext { private List<ObservableModifiedEventArgs> _pending_notifications = new List<ObservableModifiedEventArgs>(); + private ObservablesContextAdapter _adapter; public ObservablesContext() { @@ -33,6 +34,7 @@ namespace Tango.BL public ObservablesContext(DataSource dataSource) : base(dataSource.ToConnection(), true) { Database.SetInitializer<ObservablesContext>(null); + _adapter = new ObservablesContextAdapter(this); } /// <summary> @@ -161,101 +163,12 @@ namespace Tango.BL return base.ShouldValidateEntity(entityEntry); } - #region Public Methods - /// <summary> - /// Loads the configuration with it's Ids packs. + /// Gets an instance of <see cref="ObservablesContextAdapter"/> which wraps this instance. /// </summary> - /// <param name="condition">The condition.</param> - /// <returns></returns> - public Configuration GetConfiguration(Expression<Func<Configuration, bool>> condition) - { - var config = Configurations.SingleOrDefault(condition); - - config.IdsPacks = IdsPacks.Where(x => x.ConfigurationGuid == config.Guid) - .Include(x => x.LiquidType) - .Include(x => x.DispenserType) - .Include(x => x.CartridgeType) - .Include(x => x.DispenserType) - .Include(x => x.IdsPackFormula).OrderBy(x => x.PackIndex).ToObservableCollection(); - - return config; - } - - public HardwareVersion GetHardwareVersion(Expression<Func<HardwareVersion, bool>> condition) + public ObservablesContextAdapter Adapter { - HardwareVersion version = HardwareVersions.SingleOrDefault(condition); - - version.HardwareBlowers = HardwareBlowers.Where(x => x.HardwareVersionGuid == version.Guid).Include(x => x.HardwareBlowerType).ToList().OrderBy(x => x.HardwareBlowerType.Code).ToObservableCollection(); - version.HardwareBreakSensors = HardwareBreakSensors.Where(x => x.HardwareVersionGuid == version.Guid).Include(x => x.HardwareBreakSensorType).ToList().OrderBy(x => x.HardwareBreakSensorType.Code).ToObservableCollection(); - version.HardwareDancers = HardwareDancers.Where(x => x.HardwareVersionGuid == version.Guid).Include(x => x.HardwareDancerType).ToList().OrderBy(x => x.HardwareDancerType.Code).ToObservableCollection(); - version.HardwareMotors = HardwareMotors.Where(x => x.HardwareVersionGuid == version.Guid).Include(x => x.HardwareMotorType).ToList().OrderBy(x => x.HardwareMotorType.Code).ToObservableCollection(); - version.HardwarePidControls = HardwarePidControls.Where(x => x.HardwareVersionGuid == version.Guid).Include(x => x.HardwarePidControlType).ToList().OrderBy(x => x.HardwarePidControlType.Code).ToObservableCollection(); - version.HardwareSpeedSensors = HardwareSpeedSensors.Where(x => x.HardwareVersionGuid == version.Guid).Include(x => x.HardwareSpeedSensorType).ToList().OrderBy(x => x.HardwareSpeedSensorType.Code).ToObservableCollection(); - version.HardwareWinders = HardwareWinders.Where(x => x.HardwareVersionGuid == version.Guid).Include(x => x.HardwareWinderType).ToList().OrderBy(x => x.HardwareWinderType.Code).ToObservableCollection(); - - return version; + get { return _adapter; } } - - public HardwareVersion GetHardwareVersionByMachine(String machineGuid) - { - var machine = Machines.Where(x => x.Guid == machineGuid).Include(x => x.Configuration).FirstOrDefault(); - return GetHardwareVersion(x => x.Guid == machine.Configuration.HardwareVersionGuid); - } - - public ProcessParametersTablesGroup GetActiveProcessParametersTablesGroup(String rmlGuid) - { - return ProcessParametersTablesGroups.Where(x => x.RmlGuid == rmlGuid && x.Active).Include(x => x.ProcessParametersTables).FirstOrDefault(); - } - - public ObservableCollection<Cct> GetRmlCCTs(String rmlGuid) - { - return Ccts.Where(x => x.RmlGuid == rmlGuid).ToObservableCollection(); - } - - public ObservableCollection<Cat> GetRmlCATs(String rmlGuid, String machineGuid) - { - return Cats.Where(x => x.MachineGuid == machineGuid && x.RmlGuid == rmlGuid).ToObservableCollection(); - } - - public ObservableCollection<LiquidTypesRml> GetRmlLiquidTypes(String rmlGuid) - { - return LiquidTypesRmls.Where(x => x.RmlGuid == rmlGuid).ToObservableCollection(); - } - - public Organization GetOrganizationAndUsers(String organizationGuid) - { - var org = Organizations.SingleOrDefault(x => x.Guid == organizationGuid); - - org.Address = Addresses.SingleOrDefault(x => x.Guid == org.AddressGuid); - org.Contact = Contacts.SingleOrDefault(x => x.Guid == org.ContactGuid); - - Roles.Load(); - Permissions.Load(); - RolesPermissions.Load(); - - - org.Users = Users.Where(x => x.OrganizationGuid == organizationGuid) - .Include(x => x.Address) - .Include(x => x.Contact) - .Include(x => x.UsersRoles).ToObservableCollection(); - - return org; - } - - public User GetUser(String userGuid) - { - Roles.Load(); - Permissions.Load(); - RolesPermissions.Load(); - - return Users.Where(x => x.Guid == userGuid) - .Include(x => x.Address) - .Include(x => x.Contact) - .Include(x => x.UsersRoles) - .FirstOrDefault(); - } - - #endregion } } |
