Exemple #1
0
 public long AddCurrency(CurrencyObject currencyAccount)
 {
     try
     {
         return(_currencyAccountRepository.AddCurrency(currencyAccount));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
        public ActionResult Create(CurrencyVM model)
        {
            try
            {
                string currencyId = string.Empty;
                model.CreatedBy = LogInManager.LoggedInUserId;

                #region Check Currency Code Exist.

                if (this.CheckCurrencyCodeExist(model.Id, model.Code) == false)
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = string.Format("Code : {0} already exist.", model.Code)
                    }, JsonRequestBehavior.AllowGet));
                }

                #endregion

                #region Check Currency Name Exist.

                if (this.CheckCurrencyNameExist(model.Id, model.Name) == false)
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = string.Format("Name : {0} already exist.", model.Name)
                    }, JsonRequestBehavior.AllowGet));
                }

                #endregion

                currencyId = currencyRepository.AddCurrency(model);

                if (!string.IsNullOrWhiteSpace(currencyId))
                {
                    return(Json(new
                    {
                        IsSuccess = true,
                        data = new
                        {
                            CurrencyId = currencyId
                        }
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "Currency details not saved successfully."
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "Create");
                return(Json(new
                {
                    IsSuccess = false,
                    errorMessage = e.Message
                }));
            }
        }