/// <summary> /// Populates a trading support record with the contents of the entity. /// </summary> /// <param name="baseRecord">The empty record to populate.</param> protected override void PopulateRecord(TradingSupportReference.BaseRecord baseRecord) { TradingSupportReference.Entity record = baseRecord as TradingSupportReference.Entity; record.Description = this.Description; record.ImageId = this.ImageId; record.IsHidden = this.IsHidden; record.IsReadOnly = this.IsReadOnly; record.Name = this.Name; record.RowId = this.EntityId; record.RowVersion = this.RowVersion; record.TypeId = this.TypeId; }
/// <summary> /// Commit any changes to this object to the server. /// </summary> public override void Commit() { TradingSupportClient tradingSupportClient = new TradingSupportClient(Guardian.Properties.Settings.Default.TradingSupportEndpoint); try { TradingSupportReference.Entity record = new TradingSupportReference.Entity(); MethodResponseErrorCode response; this.PopulateRecord(record); if (this.Deleted) { throw new NotImplementedException("Cannot delete from Entity.Commit. You must override Commit in a derived class"); } else { response = tradingSupportClient.UpdateEntity(new TradingSupportReference.Entity[] { record }); } if (!response.IsSuccessful) { Entity.ThrowErrorInfo(response.Errors[0]); } this.Modified = false; } catch (Exception exception) { // Any issues trying to communicate to the server are logged. EventLog.Error("{0}: {1}\n{2}", exception.GetType(), exception.Message, exception.StackTrace); throw; } finally { if (tradingSupportClient != null && tradingSupportClient.State == CommunicationState.Opened) { tradingSupportClient.Close(); } } }