public ActionResult SendEmail([FromBody] MessageInput messageInput)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var reply = _NotificationOrchestration.SendEmail(messageInput);

                    if (reply != null)
                    {
                        return(Content(reply.Response));
                    }

                    return(BadRequest());
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Beispiel #2
0
        public ActionResult Buy([FromBody] Buy buy)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(buy));
            }

            var merchant = _UserOrchestration.GetMerchant(buy.Merchant);

            var user = _MarketOrhestration.GetUser(buy);

            if (buy.Amount > user.Balance)
            {
                return(BadRequest("Insufficient Funds, Please load Account"));
            }

            var res = _MarketOrhestration.MakePayment(buy);

            var smsMerchant = _NotificationOrchestration.SendSMS(
                new MessageInput {
                Destination = merchant.Phone, Message = $"{user.Name} bought {buy.Description} for R{buy.Amount}"
            });

            var emailMerchant = _NotificationOrchestration.SendEmail(
                new MessageInput {
                Destination = merchant.Email, Message = $"{user.Name} bought {buy.Description} for R{buy.Amount}"
            });

            var smsUser = _NotificationOrchestration.SendSMS(
                new MessageInput {
                Destination = user.Phone, Message = $"{merchant.Name} received R{buy.Amount} for R{buy.Description}"
            });

            var emailUser = _NotificationOrchestration.SendEmail(
                new MessageInput {
                Destination = merchant.Email, Message = $"{user.Name} bought {buy.Description} for R{buy.Amount}"
            });

            return(Content($"{res}"));
        }