public Int32 UpdatePaymentGateway(PaymentGatewayObject paymentGateway) { try { if (paymentGateway == null) { return(-2); } if (_repository.Count(m => m.GatewayName.Trim().ToLower() == paymentGateway.GatewayName.Trim().ToLower() && (m.PaymentGatewayId != paymentGateway.PaymentGatewayId)) > 0) { return(-3); } var paymentGatewayEntity = ModelCrossMapper.Map <PaymentGatewayObject, PaymentGateway>(paymentGateway); if (paymentGatewayEntity == null || paymentGatewayEntity.PaymentGatewayId < 1) { return(-2); } _repository.Update(paymentGatewayEntity); _uoWork.SaveChanges(); return(5); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(-2); } }
public long AddPaymentGateway(PaymentGatewayObject paymentGateway) { try { if (paymentGateway == null) { return(-2); } if (_repository.Count(m => m.GatewayName.Trim().ToLower() == paymentGateway.GatewayName.Trim().ToLower()) > 0) { return(-3); } var paymentGatewayEntity = ModelCrossMapper.Map <PaymentGatewayObject, PaymentGateway>(paymentGateway); if (paymentGatewayEntity == null || string.IsNullOrEmpty(paymentGatewayEntity.GatewayName)) { return(-2); } var returnStatus = _repository.Add(paymentGatewayEntity); _uoWork.SaveChanges(); return(returnStatus.PaymentGatewayId); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public int UpdatePaymentGateway(PaymentGatewayObject paymentGateway) { try { return(_paymentGatewayRepository.UpdatePaymentGateway(paymentGateway)); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(-2); } }
public ActionResult AddPaymentGateway(PaymentGatewayObject paymentGateway) { try { if (ModelState.IsValid) { var valStatus = ValidatePaymentGateway(paymentGateway); if (valStatus.Code < 1) { paymentGateway.PaymentGatewayId = 0; paymentGateway.GatewayName = valStatus.Error; return(Json(paymentGateway, JsonRequestBehavior.AllowGet)); } var logoPath = SaveFile(""); if (!string.IsNullOrEmpty(logoPath)) { paymentGateway.LogoPath = logoPath; } var k = new PaymentGatewayServices().AddPaymentGateway(paymentGateway); if (k < 1) { if (k == -3) { paymentGateway.GatewayName = "Payment Gateway information already exists"; } if (k == -4) { paymentGateway.GatewayName = "This Sort Code has been registered for another Payment Gateway."; } if (k != -3 && k != -4) { paymentGateway.GatewayName = "Payment Gateway information could not be added. Please try again"; } paymentGateway.PaymentGatewayId = 0; return(Json(paymentGateway, JsonRequestBehavior.AllowGet)); } paymentGateway.PaymentGatewayId = k; return(Json(paymentGateway, JsonRequestBehavior.AllowGet)); } paymentGateway.PaymentGatewayId = -5; paymentGateway.GatewayName = message_Feedback.Model_State_Error; return(Json(paymentGateway, JsonRequestBehavior.AllowGet)); } catch { paymentGateway.PaymentGatewayId = 0; paymentGateway.GatewayName = message_Feedback.Process_Failed; return(Json(paymentGateway, JsonRequestBehavior.AllowGet)); } }
private GenericValidator ValidatePaymentGateway(PaymentGatewayObject paymentGateway) { var gVal = new GenericValidator(); if (paymentGateway == null) { gVal.Code = -1; gVal.Error = message_Feedback.Fatal_Error; return(gVal); } if (string.IsNullOrEmpty(paymentGateway.GatewayName)) { gVal.Code = -1; gVal.Error = message_Feedback.Payment_Gateway_Error; return(gVal); } gVal.Code = 5; gVal.Error = ""; return(gVal); }
public ActionResult EditPaymentGateway(PaymentGatewayObject paymentGateway) { try { if (ModelState.IsValid) { var valStatus = ValidatePaymentGateway(paymentGateway); if (valStatus.Code < 1) { paymentGateway.PaymentGatewayId = 0; paymentGateway.GatewayName = valStatus.Error; return(Json(paymentGateway, JsonRequestBehavior.AllowGet)); } if (Session["_paymentGateway"] == null) { paymentGateway.PaymentGatewayId = -5; paymentGateway.GatewayName = message_Feedback.Session_Time_Out; return(Json(paymentGateway, JsonRequestBehavior.AllowGet)); } var oldPaymentGateway = Session["_paymentGateway"] as PaymentGatewayObject; if (oldPaymentGateway == null || oldPaymentGateway.PaymentGatewayId < 1) { paymentGateway.PaymentGatewayId = -5; paymentGateway.GatewayName = message_Feedback.Session_Time_Out; return(Json(paymentGateway, JsonRequestBehavior.AllowGet)); } oldPaymentGateway.GatewayName = paymentGateway.GatewayName.Trim(); var formerLogoPath = string.Empty; if (!string.IsNullOrEmpty(oldPaymentGateway.LogoPath)) { formerLogoPath = oldPaymentGateway.LogoPath; } var logoPath = SaveFile(formerLogoPath); if (!string.IsNullOrEmpty(logoPath)) { oldPaymentGateway.LogoPath = logoPath; } var k = new PaymentGatewayServices().UpdatePaymentGateway(oldPaymentGateway); if (k < 1) { if (k == -3) { paymentGateway.GatewayName = "Payment Gateway information already exists"; } if (k == -4) { paymentGateway.GatewayName = "This Sort Code has been registered for another Payment Gateway."; } if (k != -3 && k != -4) { paymentGateway.GatewayName = "Payment Gateway information could not be updated. Please try again"; } paymentGateway.PaymentGatewayId = 0; return(Json(paymentGateway, JsonRequestBehavior.AllowGet)); } return(Json(oldPaymentGateway, JsonRequestBehavior.AllowGet)); } paymentGateway.PaymentGatewayId = -5; paymentGateway.GatewayName = message_Feedback.Model_State_Error; return(Json(paymentGateway, JsonRequestBehavior.AllowGet)); } catch { paymentGateway.PaymentGatewayId = 0; paymentGateway.GatewayName = message_Feedback.Process_Failed; return(Json(paymentGateway, JsonRequestBehavior.AllowGet)); } }