public Int32 UpdateStorePaymentGateway(StorePaymentGatewayObject storePaymentGateway)
        {
            try
            {
                if (storePaymentGateway == null)
                {
                    return(-2);
                }

                if (_repository.Count(m => m.GatewayName.Trim().ToLower() == storePaymentGateway.GatewayName.Trim().ToLower() && (m.StorePaymentGatewayId != storePaymentGateway.StorePaymentGatewayId)) > 0)
                {
                    return(-3);
                }

                var storePaymentGatewayEntity = ModelCrossMapper.Map <StorePaymentGatewayObject, StorePaymentGateway>(storePaymentGateway);
                if (storePaymentGatewayEntity == null || storePaymentGatewayEntity.StorePaymentGatewayId < 1)
                {
                    return(-2);
                }
                _repository.Update(storePaymentGatewayEntity);
                _uoWork.SaveChanges();
                return(5);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(-2);
            }
        }
 public long AddStorePaymentGateway(StorePaymentGatewayObject storePaymentGateway)
 {
     try
     {
         if (storePaymentGateway == null)
         {
             return(-2);
         }
         if (_repository.Count(m => m.GatewayName.Trim().ToLower() == storePaymentGateway.GatewayName.Trim().ToLower()) > 0)
         {
             return(-3);
         }
         var storePaymentGatewayEntity = ModelCrossMapper.Map <StorePaymentGatewayObject, StorePaymentGateway>(storePaymentGateway);
         if (storePaymentGatewayEntity == null || string.IsNullOrEmpty(storePaymentGatewayEntity.GatewayName))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(storePaymentGatewayEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StorePaymentGatewayId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
 public int UpdateStorePaymentGateway(StorePaymentGatewayObject storePaymentGateway)
 {
     try
     {
         return(_storePaymentGatewayRepository.UpdateStorePaymentGateway(storePaymentGateway));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
        public ActionResult AddStorePaymentGateway(StorePaymentGatewayObject storePaymentGateway)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateStorePaymentGateway(storePaymentGateway);
                    if (valStatus.Code < 1)
                    {
                        storePaymentGateway.StorePaymentGatewayId = 0;
                        storePaymentGateway.GatewayName           = valStatus.Error;
                        return(Json(storePaymentGateway, JsonRequestBehavior.AllowGet));
                    }

                    var logoPath = SaveFile("");
                    if (!string.IsNullOrEmpty(logoPath))
                    {
                        storePaymentGateway.LogoPath = logoPath;
                    }
                    var k = new StorePaymentGatewayServices().AddStorePaymentGateway(storePaymentGateway);
                    if (k < 1)
                    {
                        if (k == -3)
                        {
                            storePaymentGateway.GatewayName = "Payment Gateway information already exists";
                        }
                        if (k == -4)
                        {
                            storePaymentGateway.GatewayName = "This Sort Code has been registered for another Payment Gateway.";
                        }
                        if (k != -3 && k != -4)
                        {
                            storePaymentGateway.GatewayName = "Payment Gateway information could not be added. Please try again";
                        }
                        storePaymentGateway.StorePaymentGatewayId = 0;
                        return(Json(storePaymentGateway, JsonRequestBehavior.AllowGet));
                    }

                    storePaymentGateway.StorePaymentGatewayId = k;
                    return(Json(storePaymentGateway, JsonRequestBehavior.AllowGet));
                }

                storePaymentGateway.StorePaymentGatewayId = -5;
                storePaymentGateway.GatewayName           = message_Feedback.Model_State_Error;
                return(Json(storePaymentGateway, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                storePaymentGateway.StorePaymentGatewayId = 0;
                storePaymentGateway.GatewayName           = message_Feedback.Process_Failed;
                return(Json(storePaymentGateway, JsonRequestBehavior.AllowGet));
            }
        }
        private GenericValidator ValidateStorePaymentGateway(StorePaymentGatewayObject storePaymentGateway)
        {
            var gVal = new GenericValidator();

            if (storePaymentGateway == null)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Fatal_Error;
                return(gVal);
            }
            if (string.IsNullOrEmpty(storePaymentGateway.GatewayName))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Payment_Gateway_Error;
                return(gVal);
            }

            gVal.Code  = 5;
            gVal.Error = "";
            return(gVal);
        }
        public ActionResult EditStorePaymentGateway(StorePaymentGatewayObject storePaymentGateway)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateStorePaymentGateway(storePaymentGateway);
                    if (valStatus.Code < 1)
                    {
                        storePaymentGateway.StorePaymentGatewayId = 0;
                        storePaymentGateway.GatewayName           = valStatus.Error;
                        return(Json(storePaymentGateway, JsonRequestBehavior.AllowGet));
                    }

                    if (Session["_storePaymentGateway"] == null)
                    {
                        storePaymentGateway.StorePaymentGatewayId = -5;
                        storePaymentGateway.GatewayName           = message_Feedback.Session_Time_Out;
                        return(Json(storePaymentGateway, JsonRequestBehavior.AllowGet));
                    }

                    var oldStorePaymentGateway = Session["_storePaymentGateway"] as StorePaymentGatewayObject;
                    if (oldStorePaymentGateway == null || oldStorePaymentGateway.StorePaymentGatewayId < 1)
                    {
                        storePaymentGateway.StorePaymentGatewayId = -5;
                        storePaymentGateway.GatewayName           = message_Feedback.Session_Time_Out;
                        return(Json(storePaymentGateway, JsonRequestBehavior.AllowGet));
                    }

                    oldStorePaymentGateway.GatewayName = storePaymentGateway.GatewayName.Trim();

                    var formerLogoPath = string.Empty;
                    if (!string.IsNullOrEmpty(oldStorePaymentGateway.LogoPath))
                    {
                        formerLogoPath = oldStorePaymentGateway.LogoPath;
                    }

                    var logoPath = SaveFile(formerLogoPath);

                    if (!string.IsNullOrEmpty(logoPath))
                    {
                        oldStorePaymentGateway.LogoPath = logoPath;
                    }

                    var k = new StorePaymentGatewayServices().UpdateStorePaymentGateway(oldStorePaymentGateway);
                    if (k < 1)
                    {
                        if (k == -3)
                        {
                            storePaymentGateway.GatewayName = "Payment Gateway information already exists";
                        }
                        if (k == -4)
                        {
                            storePaymentGateway.GatewayName = "This Sort Code has been registered for another Payment Gateway.";
                        }
                        if (k != -3 && k != -4)
                        {
                            storePaymentGateway.GatewayName = "Payment Gateway information could not be updated. Please try again";
                        }
                        storePaymentGateway.StorePaymentGatewayId = 0;
                        return(Json(storePaymentGateway, JsonRequestBehavior.AllowGet));
                    }
                    return(Json(oldStorePaymentGateway, JsonRequestBehavior.AllowGet));
                }

                storePaymentGateway.StorePaymentGatewayId = -5;
                storePaymentGateway.GatewayName           = message_Feedback.Model_State_Error;
                return(Json(storePaymentGateway, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                storePaymentGateway.StorePaymentGatewayId = 0;
                storePaymentGateway.GatewayName           = message_Feedback.Process_Failed;
                return(Json(storePaymentGateway, JsonRequestBehavior.AllowGet));
            }
        }