Example #1
0
        public ActionResult AddPeriod(string Source, string Sum)
        {
            if (!string.IsNullOrWhiteSpace(Source))
            {
                if (float.TryParse(Sum, out var value))
                {
                    _incomeService.AddPeriodicIncome(_user, Source, value, DateTime.Now);

                    ViewBag.Title = "Доходы";

                    ViewBag.IncomesRegular = _incomeService.GetAll(_user).Where(x => x.GetType() == typeof(RegularIncome));
                    ViewBag.IncomesPeriod  = _incomeService.GetAll(_user).Where(x => x.GetType() == typeof(PeriodicIncome));

                    return(View("Index"));
                }
                else
                {
                    ViewBag.Error = "Введите сумму";
                }
            }
            else
            {
                ViewBag.Error = "Введите название";
            }

            ViewBag.Title = "Новый доход";

            return(View("AddPeriod"));
        }