Esempio n. 1
0
        public ActionResult Create(income income)
        {
            try
            {
                subcategory subCat = SubCategoryRepository.GetBySubCategoryID(income.subCategoryID);

                if (income.bankAccountID == 0)
                {
                    income.bankAccountID = subCat.bankAccountID;
                }
                if (income.Title == null)
                {
                    income.Title = subCat.SubCategoryName;
                }
                if (income.Comment == null)
                {
                    income.Comment = "";
                }

                if (ModelState.IsValid)
                {
                    db.incomes.Add(income);
                    db.SaveChanges();
                    IncomeRepository.AddRecord(income);
                    TempData["Message2"] = "Income added successfully.";
                    return(RedirectToAction("Create"));
                }
            }
            catch (Exception ex)
            {
                TempData["Message2"] = "Error adding income";
            }
            GetData();
            return(PartialView(income));
        }