Example #1
0
 public int UpdateStoreCurrency(StoreCurrencyObject currency)
 {
     try
     {
         if (currency == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower().Equals(currency.Name.Trim().ToLower()) && (m.StoreCountryId == currency.StoreCountryId) && (m.StoreCurrencyId != currency.StoreCurrencyId));
         if (duplicates > 0)
         {
             return(-3);
         }
         var currencyEntity = ModelCrossMapper.Map <StoreCurrencyObject, StoreCurrency>(currency);
         if (currencyEntity == null || currencyEntity.StoreCurrencyId < 1)
         {
             return(-2);
         }
         _repository.Update(currencyEntity);
         _uoWork.SaveChanges();
         return(5);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
Example #2
0
 public long AddStoreCurrency(StoreCurrencyObject currency)
 {
     try
     {
         if (currency == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.Name.Trim().ToLower().Equals(currency.Name.Trim().ToLower()) && currency.StoreCountryId.Equals(m.StoreCountryId));
         if (duplicates > 0)
         {
             return(-3);
         }
         var currencyEntity = ModelCrossMapper.Map <StoreCurrencyObject, StoreCurrency>(currency);
         if (currencyEntity == null || string.IsNullOrEmpty(currencyEntity.Name))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(currencyEntity);
         _uoWork.SaveChanges();
         return(returnStatus.StoreCurrencyId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Example #3
0
        private GenericValidator ValidateStoreCurrency(StoreCurrencyObject storeCurrency)
        {
            var gVal = new GenericValidator();

            if (storeCurrency == null)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Fatal_Error;
                return(gVal);
            }
            if (string.IsNullOrEmpty(storeCurrency.Name))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Currency_Name_Error;
                return(gVal);
            }
            if (string.IsNullOrEmpty(storeCurrency.Symbol))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Currency_Symbol_Error;
                return(gVal);
            }
            if (storeCurrency.StoreCountryId < 1)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Country_Selection_Error;
                return(gVal);
            }

            gVal.Code = 5;
            return(gVal);
        }
Example #4
0
        public ActionResult EditStoreCurrency(StoreCurrencyObject storeCurrency)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateStoreCurrency(storeCurrency);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    if (Session["_storeCurrency"] == null)
                    {
                        gVal.Code  = -5;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var oldStoreCurrency = Session["_storeCurrency"] as StoreCurrencyObject;
                    if (oldStoreCurrency == null || oldStoreCurrency.StoreCurrencyId < 1)
                    {
                        gVal.Code  = -5;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldStoreCurrency.Name = storeCurrency.Name.Trim();
                    oldStoreCurrency.IsDefaultCurrency = storeCurrency.IsDefaultCurrency;
                    oldStoreCurrency.Symbol            = storeCurrency.Symbol.Trim();
                    oldStoreCurrency.StoreCountryId    = storeCurrency.StoreCountryId;
                    var k = new StoreCurrencyServices().UpdateStoreCurrency(oldStoreCurrency);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure;
                        gVal.Code  = -1;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Update_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -5;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = 0;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Example #5
0
 public int UpdateStoreCurrency(StoreCurrencyObject storeCurrencyAccount)
 {
     try
     {
         return(_storeCurrencyAccountRepository.UpdateStoreCurrency(storeCurrencyAccount));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
Example #6
0
        public ActionResult AddStoreCurrency(StoreCurrencyObject storeCurrency)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateStoreCurrency(storeCurrency);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var k = new StoreCurrencyServices().AddStoreCurrency(storeCurrency);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        gVal.Code  = -1;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code  = k;
                    gVal.Error = message_Feedback.Model_State_Error;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -5;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }