public async Task <JsonResult> PostBusinessRules(BusinessRules businessRules)
        {
            if (businessRules == null)
            {
                throw new ArgumentNullException(" business Rules is Empty");
            }
            string result = "";

            try
            {
                if (businessRules.ModuleId <= 0 || businessRules.PaymentOptionId <= 0)
                {
                    // return new JsonResult("Name is empty");
                    //   result = "Name is empty";
                    throw new ArgumentNullException("business Rules is invalid");
                }
                // logger.LogInformation("Start Post module");
                else
                {
                    if (await businessRulesRepository.IsBusinessRuleExists(businessRules))
                    {
                        var id = await businessRulesRepository.InsertBusinessRule(businessRules);

                        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)
            {
                // logger.LogInformation(ex.ToString());
                //result= - 2;
                // return BadRequest(ex);
            }
            return(new JsonResult(result));
        }
Esempio n. 2
0
        public async Task InsertBusinessRulesTest()
        {
            try
            {
                IBusinessRulesRepository businessRulesRepository = GetBusinessRulesRepository();
                BusinessRules            businessRules           = new BusinessRules {
                    ModuleId = 1, PaymentOptionId = 1
                };
                var result = await businessRulesRepository.InsertBusinessRule(businessRules);

                Assert.True(Convert.ToInt32(result) > 0, "The DataSved Successfully !!");
            }
            catch (Exception ex)
            {
                Assert.NotNull(ex);
                Assert.IsType <InvalidOperationException>(ex);
            }
        }