Beispiel #1
0
        public ActionResult Create([Bind(Include = "Id,FullName")] Person person)
        {
            if (ModelState.IsValid)
            {
                db.Persons.Add(person);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(person));
        }
        public ActionResult Create([Bind(Include = "ID,Setting,SettingValue,SettingDate")] SystemSetting systemSetting)
        {
            if (ModelState.IsValid)
            {
                db.SystemSettings.Add(systemSetting);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(systemSetting));
        }
        public ActionResult Create([Bind(Include = "Id,Description,Amount,EffectiveDate,ChangeType,IncomeSourceId")] IncomeSource incomeSource)
        {
            if (ModelState.IsValid)
            {
                db.IncomeSources.Add(incomeSource);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(incomeSource));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Description,IsMonthly,RecuranceDayNumber,RecuranceEndDate,AllocationType,Amount")] Allocation allocation)
        {
            if (ModelState.IsValid)
            {
                db.Allocations.Add(allocation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(allocation));
        }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "Id,Name")] ExpenseCategory expenseCategory)
        {
            if (ModelState.IsValid)
            {
                db.ExpenseCategories.Add(expenseCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(expenseCategory));
        }
Beispiel #6
0
        public ActionResult Create([Bind(Include = "Id,Name,Apr,AccountType,Institution,Website")] Account account)
        {
            if (ModelState.IsValid)
            {
                db.Accounts.Add(account);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(account));
        }
Beispiel #7
0
        public ActionResult Create([Bind(Include = "Id,EffectiveDateTime,Amount,ChangeTypeEnum,Recurance,AllocationId,IsRecurring")] AllocationChange allocationChange)
        {
            if (ModelState.IsValid)
            {
                db.ChangeEvents.Add(allocationChange);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AllocationId = new SelectList(db.Allocations, "Id", "Name", allocationChange.AllocationId);
            return(View("~/Views/Budget/Index.cshtml"));
        }
Beispiel #8
0
        public ActionResult Create([Bind(Include = "Id,Date,Amount,LoanId")] LoanBalanceEntry loanBalanceEntry)
        {
            if (ModelState.IsValid)
            {
                db.LoanBalanceEntries.Add(loanBalanceEntry);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.LoanId = new SelectList(db.Allocations, "Id", "Name", loanBalanceEntry.LoanId);
            return(View(loanBalanceEntry));
        }
Beispiel #9
0
        public ActionResult Create([Bind(Include = "Id,Date,Amount,AccountId")] AccountBalanceEntry accountBalanceEntry)
        {
            if (ModelState.IsValid)
            {
                db.AccountBalanceEntries.Add(accountBalanceEntry);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountId = new SelectList(db.Accounts, "Id", "Name", accountBalanceEntry.AccountId);
            return(View(accountBalanceEntry));
        }
Beispiel #10
0
        public ActionResult Create([Bind(Include = "Id,EffectiveDateTime,Amount,ChangeTypeEnum,Recurance,AccountId,IsRecurring")] AccountChange accountChange)
        {
            if (ModelState.IsValid)
            {
                db.ChangeEvents.Add(accountChange);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountId = new SelectList(db.Accounts, "Id", "Name", accountChange.AccountId);

            return(View(accountChange));
        }
Beispiel #11
0
        public ActionResult Create([Bind(Include = "Id,TransactionType,TransactionDate,EnteredDate,Description,Amount,AccountId,AllocationId")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                db.Transactions.Add(transaction);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountId    = new SelectList(db.Accounts, "Id", "Name", transaction.AccountId);
            ViewBag.AllocationId = new SelectList(db.Allocations, "Id", "Name", transaction.AllocationId).OrderBy(x => x.Text);
            return(View(transaction));
        }
Beispiel #12
0
 public TEntity Create(TEntity item)
 {
     try
     {
         dbcontext.Entry(item).State = EntityState.Added;
         dbcontext.SaveChanges();
     }
     catch (DbEntityValidationException dx)
     {
         throw dx;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(item);
 }
Beispiel #13
0
        public ActionResult Create([Bind(Include = "Id,Name,Description,Amount,AccountId,ExpenseCategoryId")] Expense expense,
                                   [Bind(Include = "RecurrenceFrequencyEnum, RecuranceStartDate, RecuranceEndDate, RecuranceDayNumber")] Recurrence recurrence)
        {
            if (ModelState.IsValid)
            {
                if (recurrence != null)
                {
                    expense.Recurrence = recurrence;
                }
                db.Allocations.Add(expense);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountId         = new SelectList(db.Accounts, "Id", "Name", expense.AccountId);
            ViewBag.ExpenseCategoryId = new SelectList(db.ExpenseCategories, "Id", "Name", expense.ExpenseCategoryId).OrderBy(x => x.Text);
            return(View("~/Views/Budget/Index.cshtml"));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Description,IsMonthly,Amount,AccountId,LoanAccountId")] Loan loan,
                                   [Bind(Include = "RecurrenceFrequencyEnum, RecuranceStartDate, RecuranceEndDate, RecuranceDayNumber")] Recurrence recurrence)
        {
            if (ModelState.IsValid)
            {
                if (recurrence != null)
                {
                    loan.Recurrence = recurrence;
                }
                db.Allocations.Add(loan);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountId     = new SelectList(db.Accounts, "Id", "Name", loan.AccountId).OrderBy(x => x.Text);
            ViewBag.LoanAccountId = new SelectList(db.Accounts, "Id", "Name", loan.LoanAccountId).OrderBy(x => x.Text);
            return(View(loan));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Description,AllocationType,Amount,AccountId,Notes,DestinationAccountId")] SavingsInvestment savingsInvestment,
                                   [Bind(Include = "RecurrenceFrequencyEnum, RecuranceStartDate, RecuranceEndDate, RecuranceDayNumber")] Recurrence recurrence)
        {
            if (ModelState.IsValid)
            {
                if (recurrence != null)
                {
                    savingsInvestment.Recurrence = recurrence;
                }
                db.Allocations.Add(savingsInvestment);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ViewBag.AccountId            = new SelectList(db.Accounts, "Id", "Name", savingsInvestment.AccountId);
            ViewBag.DestinationAccountId = new SelectList(db.Accounts, "Id", "Name", savingsInvestment.DestinationAccountId).OrderBy(x => x.Text);
            return(View(savingsInvestment));
        }
Beispiel #16
0
        public ActionResult Create([Bind(Include = "Id,Name,Description,Amount,AccountId,PersonId,IncomeSourceId")] Income income,
                                   [Bind(Include = "RecurrenceFrequencyEnum, RecuranceStartDate, RecuranceEndDate, RecuranceDayNumber")] Recurrence recurrence)
        {
            if (ModelState.IsValid)
            {
                if (recurrence != null)
                {
                    income.Recurrence = recurrence;
                }
                db.Allocations.Add(income);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountId      = new SelectList(db.Accounts, "Id", "Name", income.AccountId);
            ViewBag.IncomeSourceId = new SelectList(db.IncomeSources, "Id", "Name", income.IncomeSourceId);
            ViewBag.PersonId       = new SelectList(db.Persons, "Id", "FullName", income.PersonId);
            return(View(income));
        }
        public ActionResult Index(TransactionsUpload model, string command)
        {
            switch (command)
            {
            case "Commit":
                Utilities.TransactionUtils.CommitTransactions(model);
                break;

            case "Save":
                db.SaveChanges();
                break;

            default:
                throw new NotImplementedException();

/*
 *                  break;
 */
            }
            return(View("Index"));
        }
Beispiel #18
0
        //Run once after upgrading to object based recurrence
        public static void SetAllNullRecurrenceToValue()
        {
            PrimaryContext db = new PrimaryContext();

            foreach (var allocation in db.Allocations.ToList())
            {
                if (allocation.Recurrence == null)
                {
                    allocation.Recurrence = new Recurrence()
                    {
                        RecuranceStartDate      = System.DateTime.Today,
                        RecurrenceFrequencyEnum = Models.Enums.RecurrenceEnum.Monthly
                    };
                    db.SaveChanges();
                }
            }
        }
Beispiel #19
0
        public static int GetWeeksInMonth(this DateTime time)
        {
            PrimaryContext db = new PrimaryContext();
            DayOfWeek      settingDay;

            if (db.SystemSettings.Any(x => x.Setting == Enums.SysSetting.WeekStartDay))
            {
                settingDay = (DayOfWeek)Convert.ToInt16(db.SystemSettings.FirstOrDefault(x => x.Setting == Enums.SysSetting.WeekStartDay).SettingValue);
            }
            else
            {
                db.SystemSettings.Add(new SystemSetting()
                {
                    Setting = Enums.SysSetting.WeekStartDay, SettingInt = (int)DayOfWeek.Monday
                });
                db.SaveChanges();
                settingDay = DayOfWeek.Monday;
            }

            int       daysInMonth   = _gc.GetDaysInMonth(time.Year, time.Month);
            DayOfWeek firstDay      = _gc.GetDayOfWeek(new DateTime(time.Year, time.Month, 1));
            DateTime  lastDay       = new DateTime(time.Year, time.Month, daysInMonth);
            int       count         = (int)Math.Floor((decimal)(daysInMonth / 7));
            int       remainder     = (int)(daysInMonth % 7);
            int       daysToLastDay = (int)(lastDay.DayOfWeek - settingDay);    //index setting day to last day of the month

            if (daysToLastDay < 0)
            {
                daysToLastDay += 7;                                             //account for setting Day after last day of week
            }
            if (remainder >= daysToLastDay)
            {
                count++;
            }

            return(count);
        }