Пример #1
0
        public static bool CancelMandate(string mandateCode, string billerId)
        {
            bool       isSuccessful = false;
            MandateLog resp         = new DAO.MandateLog();

            try
            {
                using (var context = new CentralPayBridgeEntities())
                {
                    resp = context.MandateLogs.FirstOrDefault(g => g.MandateCode.Trim().ToLower().Equals(mandateCode.Trim().ToLower()) && g.BillerId.Equals(billerId));
                    if (resp != null)
                    {
                        resp.DateCancelled = DateTime.Now;
                        resp.IsCancelled   = true;
                        resp.DateUpdated   = DateTime.Now;
                        context.SaveChanges();
                        isSuccessful = true;
                    }
                }
            }
            catch (Exception ext)
            {
                ExceptionLogRepo.SaveExceptionLog(ext);
                Utils.LogError(ext, "Failed to create MandateLog ");
            }
            return(isSuccessful);
        }
Пример #2
0
        public static void SaveExceptionLog(Exception e)
        {
            Exception innerMostException = e;

            while (innerMostException.InnerException != null)
            {
                innerMostException = innerMostException.InnerException;
            }
            try
            {
                using (var context = new CentralPayBridgeEntities())
                {
                    var ex = new ExceptionLog();
                    ex.ErrorDatetime   = DateTime.Now;
                    ex.ErrorMessage    = innerMostException.Message;
                    ex.ErrorSource     = innerMostException.Source;
                    ex.ErrorStacktrace = innerMostException.StackTrace;

                    context.ExceptionLogs.Add(ex);
                    context.SaveChanges();
                }
            }
            catch (Exception ext)
            {
                Utils.LogError(innerMostException, "Original exception meant to be saved on the db ");
                Exception innerMostExceptionforDB = ext;
                while (innerMostExceptionforDB.InnerException != null)
                {
                    innerMostExceptionforDB = innerMostExceptionforDB.InnerException;
                }
                Utils.LogError(innerMostExceptionforDB, "Failed to create SaveExceptionLog ");
            }
        }
Пример #3
0
        public static MandateLog QueryMandate(string mandateCode, string billerId)
        {
            MandateLog resp = new DAO.MandateLog();

            try
            {
                using (var context = new CentralPayBridgeEntities())
                {
                    resp = context.MandateLogs.FirstOrDefault(g => g.MandateCode.Trim().ToLower().Equals(mandateCode.Trim().ToLower()) && g.BillerId.Equals(billerId));
                }
            }
            catch (Exception ext)
            {
                ExceptionLogRepo.SaveExceptionLog(ext);
                Utils.LogError(ext, "Failed to create MandateLog ");
            }
            return(resp);
        }
Пример #4
0
        public static bool SaveCentralPayOtp(CentralPayOtp otp)
        {
            bool isSuccessful = false;

            try
            {
                using (var context = new CentralPayBridgeEntities())
                {
                    context.CentralPayOtps.Add(otp);
                    context.SaveChanges();
                    isSuccessful = true;
                }
            }
            catch (Exception ext)
            {
                ExceptionLogRepo.SaveExceptionLog(ext);
                Utils.LogError(ext, "Failed to create CentralPayOtp ");
            }
            return(isSuccessful);
        }
Пример #5
0
        public static bool SaveMandate(MandateLog mandate)
        {
            bool saved = false;

            try
            {
                using (var context = new CentralPayBridgeEntities())
                {
                    context.MandateLogs.Add(mandate);
                    context.SaveChanges();
                    mandate.MandateCode = "CpayMD" + mandate.Id.ToString().PadLeft(8, '0');
                    context.SaveChanges();
                    saved = true;
                }
            }
            catch (Exception ext)
            {
                ExceptionLogRepo.SaveExceptionLog(ext);
                Utils.LogError(ext, "Failed to create MandateLog ");
            }
            return(saved);
        }
Пример #6
0
 public static void SaveRequestResponse(string httpMethodType, string requestBody, DateTime requestTime, string requestUrl,
                                        string responseBody, DateTime responseTime)
 {
     try
     {
         using (var context = new CentralPayBridgeEntities())
         {
             var rrl = new RequestResponseLog();
             rrl.HttpMethodType = httpMethodType;
             rrl.RequestBody    = requestBody;
             rrl.RequestTime    = requestTime;
             rrl.RequestUrl     = requestUrl;
             rrl.ResponseBody   = responseBody;
             rrl.ResponseTime   = responseTime;
             context.RequestResponseLogs.Add(rrl);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Utils.LogError(e, "Failed to execute SaveRequestResponse");
     }
 }
Пример #7
0
        public static bool ValidateOtp(string mandateCode, string otp, decimal?amount)
        {
            CentralPayOtp resp    = new DAO.CentralPayOtp();
            bool          isValid = false;

            try
            {
                using (var context = new CentralPayBridgeEntities())
                {
                    resp = context.CentralPayOtps.FirstOrDefault(g => g.MandateLog.MandateCode.Trim().ToLower().Equals(mandateCode.Trim().ToLower()) && g.otp.Equals(otp) && g.Amount == amount);
                    if (resp != null)
                    {
                        isValid = true;
                    }
                }
            }
            catch (Exception ext)
            {
                ExceptionLogRepo.SaveExceptionLog(ext);
                Utils.LogError(ext, "Failed to create MandateLog ");
            }
            return(isValid);
        }