Пример #1
0
        public ActionResult AddPayment(int?roommateId, int?billId, decimal?amountOwed)
        {
            HouseHoldViewModel model = new HouseHoldViewModel();

            if (roommateId != null && billId != null)
            {
                ViewBag.selectedRoommate = RoommateProcessor.GetRoommateById((int)roommateId).FullName;
                ViewBag.selectedBill     = BillProcessor.GetBillById((int)billId).BillName;
                ViewBag.AmountOwed       = amountOwed?.ToString("C", CultureInfo.CurrentCulture);
                model.Payment.BillId     = (int)billId;
                model.Payment.RoommateId = RoommateProcessor.GetRoommateById((int)roommateId).RoommateId;
            }
            else
            {
                var billData = BillProcessor.LoadBills();
                //var billData = PaymentProcessor.GetUnpaidBills();
                var roommateData = RoommateProcessor.LoadRoommates();
                foreach (var item in billData)
                {
                    model.Bills.Add(new Models.BillModel
                    {
                        //ID = item.BillId,
                        ID       = item.ID,
                        BillName = item.BillName,
                        Amount   = item.AmountDue,
                        DueDate  = item.DueDate
                    });
                }
                foreach (var item in roommateData)
                {
                    model.Roommates.Add(new Models.RoommateModel
                    {
                        RoommateId     = item.RoommateId,
                        FirstName      = item.FirstName,
                        LastName       = item.LastName,
                        MonthlyPayment = item.MonthlyPayment
                    });
                }
            }


            return(View(model));
        }