Ejemplo n.º 1
0
        // GET: Budgets/Details/5
        public ActionResult Details(int?id)
        {
            ApplicationUser currUser = db.Users.Find(User.Identity.GetUserId());

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            BudgetItem budgetItem = db.BudgetItem.Find(id);

            if (budgetItem == null)
            {
                return(HttpNotFound());
            }
            BudgetViewItem viewItem = CloneObject(budgetItem);

            //viewItem.CategoryName = budgetItem.Category.Name;
            //viewItem.BudgetItemId = budgetItem.Id;
            //viewItem.BudgetTotal = budgetItem.Amount;
            ViewBag.Transactions = db.Transaction.Where(o => o.Account.HouseholdId == currUser.HouseholdId && o.CategoryId == budgetItem.CategoryId).ToList();
            viewItem             = LinkTransactionsItem(viewItem, ViewBag.Transactions);

            return(View(viewItem));
        }
Ejemplo n.º 2
0
        private BudgetViewItem CloneObject(BudgetItem item)
        {
            var            javaScriptSerializer = new JavaScriptSerializer();
            BudgetViewItem itemList             = new BudgetViewItem();

            itemList.BudgetItemId = item.Id;
            itemList.CategoryName = item.Category.Name;
            itemList.CategoryId   = item.CategoryId;
            itemList.BudgetTotal  = item.Amount;
            itemList.TotalValue   = javaScriptSerializer.Serialize(item.Amount);
            return(itemList);
        }
Ejemplo n.º 3
0
        //========================== Graph Helper ========================================

        private List <BudgetViewItem> Stringify(List <BudgetItem> items)
        {
            List <BudgetViewItem> returnObj = new List <BudgetViewItem>();


            foreach (var item in items)
            {
                BudgetViewItem itemList = CloneObject(item);

                returnObj.Add(itemList);
            }

            return(returnObj);
        }