Ejemplo n.º 1
0
        public async Task PaymentOptionnameExistsTest()
        {
            IPaymentOptionsRepository paymentOptionsRepository = GetIPaymentOptionsRepository();
            string cardName = "Visa Card";
            var    result   = await paymentOptionsRepository.IsPaymentExists(cardName);

            Assert.True(
                result == true,
                "Payment name is exist.");

            Assert.False(
                result == false,
                "Payment name should not exist.");
        }
        public async Task <JsonResult> PostPaymentOptions(PaymentOptions paymentOptions)
        {
            string result = "";

            try
            {
                if (paymentOptions.Name == null || paymentOptions.Name == "")
                {
                    // return new JsonResult("Name is empty");
                    result = "Name is empty";
                }
                // logger.LogInformation("Start Post module");
                else
                {
                    if (await paymentOptionsRepository.IsPaymentExists(paymentOptions.Name))
                    {
                        var id = await paymentOptionsRepository.InsertPaymentOptions(paymentOptions);

                        if (id > 0)
                        {
                            result = "DataSved Successfully";
                        }
                        // return new JsonResult("DataSved Successfully");
                        else
                        {
                            //    return new JsonResult("Failed");
                            result = "Failed";
                        }
                    }
                    else
                    {
                        //   return new JsonResult("already Existed");
                        result = "already Existed";
                    }
                }
                //  logger.LogInformation("End Post module");
            }
            catch (Exception ex)
            {
            }
            return(new JsonResult(result));
        }