예제 #1
0
        public static bool SaveIncome(CreateIncomeVModel Income)
        {
            try
            {
                using (var model = new fmDbDataModel())
                {
                    fm_Incomes newIncome = new fm_Incomes()
                    {
                        UserId = UserSingleton.Instance.Id,
                        Name   = Income.Name,
                        Type   = (int)Enum.Parse(typeof(IncomeType), Income.IncomeType.ToString()),
                        Amount = Income.Amount,
                        //Currency = (int)Enum.Parse(typeof(CurrencyType), Income.Currency.ToString()),
                        InsertTime = DateTime.Now
                    };

                    model.fm_Incomes.Add(newIncome);
                    model.SaveChanges();
                }

                return(true);
            }
            catch (Exception e)
            {
                _log.ErrorFormat("There was an error with saving the income. Message: {0}, Stacktrace: {1}", e.Message, e.StackTrace);
                return(false);
            }
        }
        public ActionResult _CreateIncome(CreateIncomeVModel Income)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_CreateIncome", Income));
            }

            var success = IncomesManager.SaveIncome(Income);

            if (success)
            {
                return(JavaScript("ContainerManager.ShowActionInfo('" + Resources.Resources.MessageForSuccessIncomeSaving + "');"));
            }

            return(JavaScript("ContainerManager.ShowActionInfo('" + Resources.Resources.MessageForErrorIncomeSaving + "');"));
        }