Example #1
0
        /// <summary>
        /// Save the currency (new or edited)
        /// </summary>
        /// <param name="model">The currency details (model)</param>
        /// <returns></returns>
        // POST: /Administration/CurrencySave
        public ActionResult CurrencySave(MODEL.Currency model)
        {
            try
            {
                bool ismodelValid = ModelState.IsValid;
                if (!ismodelValid)
                {
                    ismodelValid = IsModelValidForMultilineTextbox("Description", model.Description, 25);
                    if (ismodelValid)
                    {
                        model.Description = model.Description.Replace("\r\n", "\n");
                    }
                }

                if (ismodelValid)
                {
                    //Get user id
                    int?            userId          = Session.GetUserId();
                    CurrencyService currencyService = new CurrencyService();
                    //CurrencyVO currencyVO = new CurrencyVO(model, userId);
                    CurrencyVO currencyVO = model.Transpose(userId);

                    currencyService.SaveCurrency(currencyVO);
                    return(new HttpStatusCodeResult(200));
                }
                else
                {
                    throw new ApplicationException(String.Format(Constants.CANNOT_SAVE, Constants.CURRENCY));
                }
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
Example #2
0
        /// <summary>
        /// Create new currency
        /// </summary>
        /// <returns></returns>
        // GET: /Administration/CurrencyCreate
        public ActionResult CurrencyCreate()
        {
            try
            {
                MODEL.Currency currency = new MODEL.Currency();

                //Set by default new currency as active
                currency.IsActive = true;
                return(PartialView("CurrencyDetails", currency));
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
Example #3
0
        /// <summary>
        /// Edit currency detail
        /// </summary>
        /// <param name="id">The selected currency id</param>
        /// <returns>The currency index details view</returns>
        // GET: /Administration/CurrencyEdit
        public ActionResult CurrencyEdit(int id)
        {
            MODEL.Currency currency = null;
            try
            {
                CurrencyService currencyService = new CurrencyService();

                //Get currency details
                CurrencyVO currencyVO = currencyService.GetCurrencyById(id);
                if (currencyVO == null)
                {
                    ModelState.AddModelError("", String.Format(Constants.ITEM_NOT_FOUND, Constants.CURRENCY));
                }
                else
                {
                    currency = new MODEL.Currency(currencyVO);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(PartialView("CurrencyDetails", currency));
        }