public void Init(IInvoker invoker) { this.invoker = invoker; npcs = new List <NPC>(); btnOptionA.onClick.AddListener(() => invoker.GetCommand(CMD.OptionA).Execute()); btnOptionB.onClick.AddListener(() => invoker.GetCommand(CMD.OptionB).Execute()); btnEndConversation.onClick.AddListener(() => invoker.GetCommand(CMD.EndConversation).Execute()); btnContinue.onClick.AddListener(() => invoker.GetCommand(CMD.ContinueConversation).Execute()); btnEndConversation.gameObject.SetActive(false); btnContinue.gameObject.SetActive(false); }
public IActionResult ProcessPayment(Models.Payment payment) { try { if (ModelState.IsValid) { var ps = new PaymentStatus(); ps.Payment = _mapper.Map <DB.Payment>(payment); ps.Status = DB.Enums.PaymentStatuses.Pending; _unitOfWork.PaymentStatuses.InsertPaymentStatus(ps); ICommand cmd = _invoker.GetCommand((double)payment.Amount); bool isSuccess = cmd.Execute(); if (isSuccess) { ps.Status = DB.Enums.PaymentStatuses.Processed; _unitOfWork.Commit(); return(Ok(new { Message = "Payment succeeded" })); } else { ps.Status = DB.Enums.PaymentStatuses.Failed; _unitOfWork.Commit(); return(Problem("Internal Server Error!")); } } return(ValidationProblem("The request is invalid!")); } catch (Exception ex) { _logger.LogError("Exception in Payment/ProcessPayment : " + ex.Message); } return(Problem()); }
private void AssignButtonCmds() { foreach (Button button in buttons) { switch (button.name) { default: button.onClick.AddListener(() => invoker.GetCommand(CMD.StartGame).Execute()); break; } } }
public void Init(IInvoker invoker) { this.invoker = invoker; npcs = new List <NPC>(); items = new List <Item>(); btnEngageInConversation.onClick.AddListener(() => invoker.GetCommand(CMD.StartConversation).Execute()); //btnPickUpItem.onClick.AddListener( () => invoker.GetCommand(CMD.PickUpItem).Execute() ); btnEngageInConversation.gameObject.SetActive(false); btnPickUpItem.gameObject.SetActive(false); }