public async Task UpdateAsync(Instrument instrument, string userId) { Instrument currentInstrument = await GetByAssetPairIdAsync(instrument.AssetPairId); InstrumentMode currentInstrumentMode = currentInstrument.Mode; currentInstrument.Update(instrument); currentInstrument.Approve(); await _instrumentRepository.UpdateAsync(currentInstrument); _cache.Set(currentInstrument); if (instrument.Mode == InstrumentMode.Disabled && currentInstrumentMode != InstrumentMode.Disabled) { try { await _lykkeExchangeService.CancelAsync(instrument.AssetPairId); } catch (Exception exception) { _log.WarningWithDetails("An error occurred while cancelling limit orders", exception, new { currentInstrument, userId }); } await _orderBookService.RemoveAsync(instrument.AssetPairId); } _log.InfoWithDetails("Instrument was updated", new { currentInstrument, userId }); }
public async Task UpdateAsync(Instrument instrument) { Instrument currentInstrument = await GetByAssetPairIdAsync(instrument.AssetPairId); currentInstrument.Update(instrument); await _instrumentRepository.UpdateAsync(currentInstrument); _cache.Set(currentInstrument); _log.InfoWithDetails("Instrument was updated", currentInstrument); }
public void UpdateTest() { Instrument instrument = new Instrument(); InstrumentList instruments = new InstrumentList(); instruments.Load(); instrument = instruments.FirstOrDefault(i => i.Description == "Test"); instrument.Description = "Update"; int results = instrument.Update(); Assert.IsTrue(results == 1); }
private void ProcessInstruments(string methodName, XmlNode instrumentNode) { if (methodName == "Modify") { Guid id = XmlConvert.ToGuid(instrumentNode.Attributes["ID"].Value); Instrument instrument = InstrumentManager.Default.Get(id); if (instrument != null) { instrument.Update(instrumentNode); } } else if (methodName == "Add") { Guid id = XmlConvert.ToGuid(instrumentNode.Attributes["ID"].Value); Instrument instrument = new Instrument(id, instrumentNode); InstrumentManager.Default.Add(instrument); } if (methodName == "Delete") { Guid id = XmlConvert.ToGuid(instrumentNode.Attributes["ID"].Value); InstrumentManager.Default.Remove(id); } }
public InstrumentEditViewModel(IDataService <LabDbEntities> labDbdata, IEventAggregator aggregator, InstrumentService instrumentService) : base() { _labDbData = labDbdata; _editMode = false; _eventAggregator = aggregator; _instrumentService = instrumentService; AreaList = _labDbData.RunQuery(new InstrumentUtilizationAreasQuery()).ToList(); InstrumentTypeList = _labDbData.RunQuery(new InstrumentTypesQuery()).ToList(); ManufacturerList = _labDbData.RunQuery(new OrganizationsQuery() { Role = OrganizationsQuery.OrganizationRoles.Manufacturer }) .ToList(); CalibrationLabList = _labDbData.RunQuery(new OrganizationsQuery() { Role = OrganizationsQuery.OrganizationRoles.CalibrationLab }) .ToList(); AddCalibrationCommand = new DelegateCommand( () => { _instrumentService.ShowNewCalibrationDialog(_instance); }, () => IsInstrumentAdmin); AddFileCommand = new DelegateCommand( () => { OpenFileDialog fileDialog = new OpenFileDialog { Multiselect = true }; if (fileDialog.ShowDialog() == DialogResult.OK) { IEnumerable <string> fileList = fileDialog.FileNames; _instance.AddFiles(fileList); RaisePropertyChanged("FileList"); } }); AddMaintenanceEventCommand = new DelegateCommand( () => { _instrumentService.ShowNewMaintenanceDialog(_instance); RaisePropertyChanged("MaintenanceEventList"); }, () => IsInstrumentAdmin); AddMethodAssociationCommand = new DelegateCommand( () => { _instance.AddMethodAssociation(_selectedUnassociated); SelectedUnassociatedMethod = null; RaisePropertyChanged("AssociatedMethods"); RaisePropertyChanged("UnassociatedMethods"); }, () => IsInstrumentAdmin && _selectedUnassociated != null); AddPropertyCommand = new DelegateCommand( () => { Views.AddPropertyDialog propertyDialog = new Views.AddPropertyDialog(); if (propertyDialog.ShowDialog() == true) { InstrumentMeasurableProperty newIMP = new InstrumentMeasurableProperty() { CalibrationRangeLowerLimit = 0, CalibrationRangeUpperLimit = 0, Description = "", InstrumentID = _instance.ID, MeasurableQuantityID = propertyDialog.QuantityInstance.ID, RangeLowerLimit = 0, RangeUpperLimit = 0, Resolution = 0, TargetUncertainty = 0, UnitID = propertyDialog.QuantityInstance.GetMeasurementUnits().First().ID }; newIMP.Create(); RaisePropertyChanged("InstrumentMeasurablePropertyList"); } }, () => IsInstrumentAdmin); OpenFileCommand = new DelegateCommand( () => { try { System.Diagnostics.Process.Start(_selectedFile.Path); } catch (Exception) { _eventAggregator.GetEvent <StatusNotificationIssued>().Publish("File non trovato"); } }, () => _selectedFile != null); RemoveFileCommand = new DelegateCommand( () => { _selectedFile.Delete(); RaisePropertyChanged("FileList"); SelectedFile = null; }, () => _selectedFile != null); RemoveMethodAssociationCommand = new DelegateCommand( () => { _instance.RemoveMethodAssociation(_selectedAssociated); SelectedAssociatedMethod = null; RaisePropertyChanged("AssociatedMethods"); RaisePropertyChanged("UnassociatedMethods"); }, () => IsInstrumentAdmin && _selectedAssociated != null); SaveCommand = new DelegateCommand( () => { _instance.Update(); foreach (InstrumentMeasurablePropertyWrapper impw in InstrumentMeasurablePropertyList.Where(imp => imp.IsModified)) { impw.PropertyInstance.Update(); } EditMode = false; _eventAggregator.GetEvent <InstrumentListUpdateRequested>() .Publish(); }, () => _editMode); StartEditCommand = new DelegateCommand( () => { EditMode = true; }, () => IsInstrumentAdmin && !_editMode); #region Event Subscriptions _eventAggregator.GetEvent <MaintenanceEventCreated>() .Subscribe( maint => { if (maint.InstrumentID == _instance?.ID) { RaisePropertyChanged("MaintenanceEventList"); } }); _eventAggregator.GetEvent <CalibrationIssued>() .Subscribe( report => { if (report.instrumentID == _instance?.ID) { RaisePropertyChanged("CalibrationReportList"); } }); #endregion Event Subscriptions }
// PUT: api/Instrument/5 public void Put(Guid id, Instrument instrument) { instrument.Update(); }