Ejemplo n.º 1
0
 public static IEnumerable<ExpenseModel> GetExpenses(CategoryModel category)
 {
     var query = Query.EQ("Category._id", category.Id);
     var items = ModelCollection<ExpenseModel>.GetCollection(query);
     //return items.Count > 10 ? items.GetRange(0, 10) : items;
     return items;
 }
Ejemplo n.º 2
0
        public ActionResult EditItem(CategoryModel category)
        {
            if (!ModelState.IsValid)
            {
                return View(category);
            }

            if (CategoryDataManager.UpdateItem(category))
                return RedirectToAction("Index");

            return View(category);
        }
Ejemplo n.º 3
0
 public static bool UpdateItem(CategoryModel category)
 {
     try
     {
         ModelCollection<CategoryModel>.UpdateItem(category);
         return true;
     }
     catch
     {
         return false;
     }
 }
Ejemplo n.º 4
0
        private static string InsertCategories()
        {
            var cat = new CategoryModel
                          {
                              DefaultCommon = true,
                              Value = "Mat og husholdn.",
                              Filter = "Kiwi, Rimi, Ica, Rema, Meny"
                          };
            ModelCollection<CategoryModel>.InsertItem(cat);

            var cat2 = new CategoryModel
            {
                DefaultCommon = true,
                Value = "Bil",
                Filter = "Esso, Shell, Jet"
            };

            ModelCollection<CategoryModel>.InsertItem(cat2);

            return "kateg";
        }
Ejemplo n.º 5
0
        public ActionResult InsertItem(CategoryModel category)
        {
            if (!IsKnownUser)
                return Reset();

            if (!ModelState.IsValid)
            {
                return View("Insert", category);
            }

            category = CategoryDataManager.InsertItem(category);

            var expenseId = TempData["SetExpenseId"] ?? string.Empty;
            ExpenseModel expense = ExpenseDataManager.GetExpense(expenseId.ToString());
            if (expense != null)
            {
                expense.Category = category;
                ExpenseDataManager.UpdateItem(expense);
            }

            return RedirectToAction("Index", "List");
        }
Ejemplo n.º 6
0
 public static CategoryModel InsertItem(CategoryModel category)
 {
     category = ModelCollection<CategoryModel>.InsertItem(category);
     return category;
 }