Exemple #1
0
        public ActionResult Accounts(string type, string cardNumber)
        {
            ViewBag.Accounts = "current";
            if (string.IsNullOrEmpty(type))
            {
                ShowMessage("Type of bouquet must be selected", AlertType.Danger);
                return(RedirectToAction("Index"));
            }
            if (!type.Equals("gotv") && !type.Equals("dstv"))
            {
                ShowMessage("Bouquet type can only be gotv or dstv", AlertType.Danger);
                return(RedirectToAction("Index"));
            }
            if (string.IsNullOrEmpty(cardNumber))
            {
                ShowMessage("Smart card number is required.", AlertType.Danger);
                return(RedirectToAction("Index"));
            }
            var response = new CustomerAccountModel();

            try
            {
                var url = ApiConstantService.BASE_URL + type + "/accounts/" + cardNumber;
                response = _request.MakeRequest <CustomerAccountModel>(url);
                return(View(response));
            }
            catch (Exception exception)
            {
                ShowMessage(exception.Message, AlertType.Danger);
                return(View(response));
            }
        }
        public IActionResult Post([FromBody] CustomerAccountModel pCustomerAccount)
        {
            var customerAccount = _Mapper.Map <CustomerAccount>(pCustomerAccount);

            if (customerAccount.ID != null && customerAccount.ID != Guid.Empty)
            {
                _CustomerAccountDAO.Update(customerAccount);
            }
            else
            {
                _CustomerAccountDAO.Add(customerAccount);
            }
            _CustomerAccountDAO.SaveChanges();
            pCustomerAccount.ID = customerAccount.ID;
            return(Ok(_Mapper.Map <CustomerAccountModel>(customerAccount)));
        }
Exemple #3
0
        public ActionResult ValidateNumberForPayment(string type, string cardNumber, string payel)
        {
            if (string.IsNullOrEmpty(type))
            {
                this.ShowMessage("Type of bouquet must be selected", AlertType.Danger);
                return(RedirectToAction("Index", new{ id = type }));
            }
            if (!type.Equals("gotv") && !type.Equals("dstv"))
            {
                this.ShowMessage("Bouquet type can only be gotv or dstv", AlertType.Danger);
                return(RedirectToAction("Index", new { id = type }));
            }
            if (string.IsNullOrEmpty(cardNumber))
            {
                this.ShowMessage("Smart card number is required.", AlertType.Danger);
                return(RedirectToAction("Index", new { id = type }));
            }

            var response = new CustomerAccountModel();

            try
            {
                var url = ApiConstantService.BASE_URL + type + "/accounts/" + cardNumber;
                response = _request.MakeRequest <CustomerAccountModel>(url);
                if (response == null)
                {
                    ShowMessage("Invalid card number", AlertType.Danger);
                    return(RedirectToAction("Index", new { id = type }));
                }
                return(RedirectToAction("MakePayment", new { type, cardNumber, payel }));
            }
            catch (Exception exception)
            {
                ShowMessage(exception.Message, AlertType.Danger);
                return(RedirectToAction("Index", new { id = payel }));
            }
        }
 static PaymentRepository()
 {
     var customerAccountModel = new CustomerAccountModel { CustomerId = 1, MaximumOrderLimit = 1000 };
     customerAccountModels.Add(customerAccountModel);
 }
        public async Task <IActionResult> EditCustomerAccount([FromRoute] int id, [FromBody] CustomerAccountModel model)
        {
            await customerAccountService.Update(id, model);

            return(NoContent());
        }
        public async Task <IActionResult> SaveCustomerAccount([FromBody] CustomerAccountModel model)
        {
            ICustomerAccount customerAccount = await customerAccountService.Create(model);

            return(Created(Url.Action(nameof(GetCustomerAccount), ControllerContext.ActionDescriptor.ControllerName, new { id = customerAccount.Id }), customerAccount));
        }