public ActionResult Post(PositionModel data) { UserMocker.Mock(data.Id); using (var db = new RescContext()) { var position = db.ActivePositions.SingleOrDefault(p => p.FirstResponderId == data.Id); if (position == null) { position = new ActivePosition { FirstResponderId = data.Id } } ; position.Lat = data.Lat; position.Lng = data.Lng; if (position.Id != 0) { db.ActivePositions.Update(position); } else { db.ActivePositions.Add(position); } db.SaveChanges(); } return(Ok()); } }
public static void Resolve(InvokeContext context, ActivePosition position) { if (context.CodeItem.middleWares == null) { return; } foreach (var item in context.CodeItem.middleWares) { if (MiddleWares.ContainsKey(item.Key)) { var middleWare = MiddleWares[item.Key]; if (middleWare.ActivePosition == position) { var message = middleWare.Validate(context, item.Value); if (string.IsNullOrEmpty(message)) { middleWare.Resolve(context, item.Value); } else { throw new Exception("Resolving middle ware '{0}' failed. {1}{2}".FormatWith(item.Key, Environment.NewLine, message)); } } } else { throw new Exception("Unknown middle ware '{0}'.".FormatWith(item.Key)); } } }
/// <summary> /// Reset the selection /// </summary> public void ResetSelection(bool mantainFocus) { //Reset also the focus is mantainFocus == false if (mantainFocus == false && ActivePosition.IsEmpty() == false) { Focus(Position.Empty, false); } OnResetSelection(); //If mantainFocus == true leave the selection for the focus if (mantainFocus && ActivePosition.IsEmpty() == false) { SelectCell(ActivePosition, true); } }
// AlanP: Sep 2013 Added an optional parameter to suppress selection_changed /// <summary> /// Reset the selection /// </summary> public void ResetSelection(bool mantainFocus, bool suppressChangeEvent = false) { //Reset also the focus is mantainFocus == false if (mantainFocus == false && suppressChangeEvent == false && ActivePosition.IsEmpty() == false) { Focus(Position.Empty, false); } OnResetSelection(); //If mantainFocus == true leave the selection for the focus // AlanP: Sep 2013 Only select the cell if we want selection_changed to fire if (mantainFocus && !suppressChangeEvent && ActivePosition.IsEmpty() == false) { SelectCell(ActivePosition, true); } }
public override void SelectRow(int row, bool select) { // AlanP: Sep 2013. Two small but significant code changes here... Range rowRange = Grid.Rows.GetRange(row); if (select && mList.IsSelectedRow(row) == false) { // if multi selection is false, remove all previously selected rows // AlanP: Sep 2013. No need for this line now - see below // var activePosition = this.ActivePosition; if (this.EnableMultiSelection == false) { this.Grid.Selection.ResetSelection(false, true); // AlanP: Sep 2013 - don't propagate events from this reset } // continue with adding selection mList.AddRange(rowRange); // AlanP: Sep 2013. The active position is now set to the specified row // Prior to this change it was set to the value it had on entry, which was often Empty // because ResetSelection was called just before this call. // AlanP: Oct 2013. Added the code that sets (preserves) the column as well as the row. Previous Sep 2013 fix always set column to 0 int column = -1; if (row >= 0) { column = ActivePosition.IsEmpty() ? 0 : ActivePosition.Column; } this.ActivePosition = new Position(row, column); if (!m_SuppressSelectionChangedEvent) { OnSelectionChanged(new RangeRegionChangedEventArgs(rowRange, Range.Empty)); } } else if (!select && mList.IsSelectedRow(row)) { mList.RemoveRange(rowRange); OnSelectionChanged(new RangeRegionChangedEventArgs(Range.Empty, rowRange)); } }
/// <summary> /// Fired when a cell lost the focus /// </summary> /// <param name="e"></param> protected virtual void OnCellLostFocus(ChangeActivePositionEventArgs e) { if (e.Cancel) { return; } //This code is not necessary because when the cell receive a focus I check // if the grid can receive the focus using the SetFocusOnCells method. // The SetFocusOnCells method cause any editor to automatically close itself. // If I leave this code there are problem when the cell lost the focus because the entire grid lost the focus, // in this case the EndEdit cause the grid to receive again the focus. (this problem is expecially visible when using the grid inside a tab and you click on the second tab after set an invalid cell value inside the first tab) //CellContext cellLostContext = new CellContext(Grid, e.OldFocusPosition); ////Stop the Edit operation //if (cellLostContext.EndEdit(false) == false) // e.Cancel = true; //if (e.Cancel) // return; //evento Lost Focus if (CellLostFocus != null) { CellLostFocus(this, e); } if (e.Cancel) { return; } //Row/Column leaving //If the new Row is different from the current focus row calls a Row Leaving event int focusRow = ActivePosition.Row; if (ActivePosition.IsEmpty() == false && focusRow != e.NewFocusPosition.Row) { RowCancelEventArgs rowArgs = new RowCancelEventArgs(focusRow); OnFocusRowLeaving(rowArgs); if (rowArgs.Cancel) { e.Cancel = true; return; } } //If the new Row is different from the current focus row calls a Row Leaving event int focusColumn = ActivePosition.Column; if (ActivePosition.IsEmpty() == false && focusColumn != e.NewFocusPosition.Column) { ColumnCancelEventArgs columnArgs = new ColumnCancelEventArgs(focusColumn); OnFocusColumnLeaving(columnArgs); if (columnArgs.Cancel) { e.Cancel = true; return; } } //Change the focus cell to Empty m_ActivePosition = Position.Empty; //from now the cell doesn't have the focus //Cell Focus Left Grid.Controller.OnFocusLeft(new CellContext(Grid, e.OldFocusPosition), EventArgs.Empty); }
public (PriceActionResult, RecoveryTurn) PriceAction(double bid, double ask) { return(ActivePosition.PriceAction(bid, ask)); }