public ViewModelCancelOperations(NavigationController controller) : base(controller) { MessageBus.Default.Subscribe("GetOperationIDForAddCancel", GetOperationid); MessageBus.Default.Subscribe("SetFunctionsToReturnToOpOwervier", SetFunctionsToReturnToOpOwervier); MessageBus.Default.Subscribe("SetFunctionsToReturnToOpCreation", SetFunctionsToReturnToOpCreation); HasNavigation = false; OtherReasonCommand = new DelegateCommand( () => { IsOtherReason = "Yes"; VisibilityOfOtherReason = Visibility.Visible; VisibilityOfReasons = Visibility.Hidden; } ); ToOperationCommand = new DelegateCommand( () => { var buf = new CancelOperation(); if (IsOtherReason != "Yes") { buf.Reason = ReasonSelected + 1; } else { ReasonsOfCancelOperation buf1 = new ReasonsOfCancelOperation(); if (OtherReasonText == null) { OtherReasonText = ""; } buf1.Str = OtherReasonText; Data.ReasonsOfCancleOperation.Add(buf1); buf.Reason = buf1.Id; Data.Complete(); } buf.TransferDate = DateTime.Now; Data.CancelOperation.Add(buf); Operation.cancel_operations = buf.Id; Data.Complete(); if (Operation.Datetime_id != null && Operation.Datetime_id != 0) { var opDate = Data.OperationDateTime.Get(Operation.Datetime_id.Value); opDate.Doctor_id = null; opDate.Note = "Время свободно"; opDate.Operation_id = null; Data.Complete(); } MessageBus.Default.Call("SetCurrentACCOp", this, null); MessageBus.Default.Call("GetOperationForOverwiev", this, operationId); Controller.NavigateTo <ViewModelOperationOverview>(); } ); ToOperationOverviewCommand = new DelegateCommand( () => { MessageBus.Default.Call("GetOperationForOverwiev", this, operationId); Controller.NavigateTo <ViewModelOperationOverview>(); } ); }
private void SetFunctionsToReturnToOpCreation(object sender, object data) { ToOperationCommand = new DelegateCommand( () => { var buf = new CancelOperation(); if (IsOtherReason != "Yes") { buf.Reason = ReasonSelected + 1; } else { ReasonsOfCancelOperation buf1 = new ReasonsOfCancelOperation(); if (OtherReasonText == null) { OtherReasonText = ""; } buf1.Str = OtherReasonText; Data.ReasonsOfCancleOperation.Add(buf1); buf.Reason = buf1.Id; Data.Complete(); } buf.TransferDate = DateTime.Now; Data.CancelOperation.Add(buf); Operation.cancel_operations = buf.Id; Data.Complete(); if (Operation.Datetime_id != null && Operation.Datetime_id != 0) { var opDate = Data.OperationDateTime.Get(Operation.Datetime_id.Value); opDate.Doctor_id = null; opDate.Note = "Время свободно"; opDate.Operation_id = null; Data.Complete(); var timeItem = Data.OperationDateTime.Where(e => e.Operation_id != null && e.Datetime.Year == opDate.Datetime.Year && e.Datetime.Month == opDate.Datetime.Month && e.Datetime.Day == opDate.Datetime.Day).FirstOrDefault(); if (timeItem == null) { foreach (var opDate1 in Data.OperationDateTime.Where(e => e.Datetime.Year == opDate.Datetime.Year && e.Datetime.Month == opDate.Datetime.Month && e.Datetime.Day == opDate.Datetime.Day)) { Data.OperationDateTime.Remove(Data.OperationDateTime.Get(opDate1.Id)); } } Data.Complete(); } MessageBus.Default.Call("SetCurrentACCOp", this, null); MessageBus.Default.Call("ConfirmCancle", null, null); //MessageBus.Default.Call("GetOperationForOverwiev", this, operationId); Controller.NavigateTo <ViewModelAddOperation>(); } ); ToOperationOverviewCommand = new DelegateCommand( () => { //MessageBus.Default.Call("GetOperationForOverwiev", this, operationId); Controller.NavigateTo <ViewModelAddOperation>(); } ); }
public void Handle(CancelOperation message) { if (message.CorrelationId.Equals(_parentCorrelation)) { Subscriber.Unsubscribe(this); var operationIds = from opIds in _responseActions.Keys select $"{opIds}"; Logger?.Invoke($"Cancel Operations\n\tId:{string.Join("\n\tId:",operationIds)}"); } }
public Operation CreateOperation(Guid logGuid, TransactionOperation transactionOperation, IOperationProvider operationProvider) { Operation operation = null; if (operationProvider != null) { OperationProvider = operationProvider; } else { throw new ArgumentException("Provider cann't be null"); } switch (transactionOperation) { case TransactionOperation.CheckPayment: operation = new CheckOperation(logGuid, OperationProvider); break; case TransactionOperation.IPayment: operation = new IPaymentOperation(logGuid, OperationProvider); break; case TransactionOperation.ICommit: operation = new ICommitOperation(logGuid, OperationProvider); break; case TransactionOperation.Cancel: operation = new CancelOperation(logGuid, OperationProvider); break; default: string msg = $"TransactionOperation {OperationProvider} not supported"; Logger.WriteLoggerError(msg); throw new ArgumentOutOfRangeException(msg); } return(operation); }