Пример #1
0
        public ActionResult PropertyAccountTransactionIndex()
        {
            var created = PropertyOwnerAccount.CreateAccountsForOwnersWithoutAccount(db);

            var accounttransactions = db.AccountTransactions.Where(x => !x.BookingID.Equals(null)).Include(a => a.Booking).Include(a => a.BookingExtraSelection).Include(x => x.PropertyOwnerAccount.PropertyOwner.Properties);

            return(View("Index", accounttransactions.ToList()));
        }
Пример #2
0
        public ActionResult Create(AccountTransaction accounttransaction)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var created = PropertyOwnerAccount.CreateAccountsForOwnersWithoutAccount(db);

                    var booking  = db.Bookings.Find(accounttransaction.BookingID);
                    var property =
                        db.Properties.Include(x => x.PropertyOwner.PropertyOwnerAccounts)
                        .Where(x => x.PropertyID == booking.PropertyID).FirstOrDefault();


                    accounttransaction.AccountID   = property.PropertyOwner.PropertyOwnerAccounts.First().AccountID;
                    accounttransaction.WhenCreated = DateTime.Now;
                    accounttransaction.WhoCreated  = User.Identity.Name;



                    db.AccountTransactions.Add(accounttransaction);
                    db.SaveChanges();
                    ViewBag.BookingID = new SelectList(db.Bookings, "BookingID", "BookingPRCReference", accounttransaction.BookingID);
                    ViewBag.BookingExtraSelectionID = new SelectList(db.BookingExtraSelections, "BookingExtraSelectionID", "BookingExtraPRCReference", accounttransaction.BookingExtraSelectionID);
                    return(RedirectToAction("Create"));
                }
                catch (Exception ex)
                {
                    throw new Exception("Can't add a transaction!", ex);
                }
            }

            ViewBag.BookingID = new SelectList(db.Bookings, "BookingID", "BookingPRCReference", accounttransaction.BookingID);
            ViewBag.BookingExtraSelectionID = new SelectList(db.BookingExtraSelections, "BookingExtraSelectionID", "BookingExtraPRCReference", accounttransaction.BookingExtraSelectionID);
            return(View(accounttransaction));
        }