public JsonResult GetBudgetByID(long id)
        {
            BudgetAdapter budgetAdapter  = new BudgetAdapter();
            BudgetModel   selectedBudget = budgetAdapter.GetBudgetByID(id);

            return(Json(selectedBudget, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.MenuView);
            string        userId       = Intent.GetStringExtra("userId");
            ListView      budgetMenu   = FindViewById <ListView>(Resource.Id.ListView);
            LinearLayout  linearLayout = FindViewById <LinearLayout>(Resource.Id.LinearLayout);
            List <Budget> budget       = model.GetAllData();
            BudgetAdapter adapter      = new BudgetAdapter(this, budget, Resource.Layout.OtherMenuListview);

            budgetMenu.Adapter = adapter;
            EditText searchBar = FindViewById <EditText>(Resource.Id.searchBar);

            budgetMenu.ItemClick += (s, e) =>
            {
                Intent budgetActivity = new Intent(this, typeof(BudgetActivity));
                budgetActivity.PutExtra("id", adapter.GetBudget(e.Position).id);
                budgetActivity.PutExtra("userId", adapter.GetBudget(e.Position).id);
                this.StartActivity(budgetActivity);
            };

            searchBar.TextChanged += searchBar_TextChanged;

            void searchBar_TextChanged(object sender, EventArgs e)
            {
                string        query        = searchBar.Text.ToLower();
                List <Budget> searchBudget = model.GetSearchData(query);

                adapter            = new BudgetAdapter(this, searchBudget, Resource.Layout.OtherMenuListview);
                budgetMenu.Adapter = adapter;
            };
        }
        public ActionResult DeleteBudget(long ID)
        {
            BudgetAdapter budgetAdapter = new BudgetAdapter();

            budgetAdapter.DeleteBudgetByIDAndUID(ID, User.Identity.Name);

            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult AddBudget(BudgetModel budgetToAdd)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index", "Budget", budgetToAdd));
            }


            BudgetAdapter budgetAdapter = new BudgetAdapter();

            budgetAdapter.AddBudget(budgetToAdd, User.Identity.Name);

            return(RedirectToAction("Index", "Budget", null));
        }
        public JsonResult UpdateBudget(string data)
        {
            Dictionary <string, string> variables = JsonConvert.DeserializeObject <Dictionary <string, string> >(data);
            BudgetAdapter budgetAdapter           = new BudgetAdapter();
            BudgetModel   budget = budgetAdapter.GetBudgetByID(long.Parse(variables["Id"]));

            budget.Description  = variables["Description"].ToString();
            budget.Amount       = decimal.Parse(variables["Amount"]);
            budget.Frequency_ID = int.Parse(variables["FrequencyID"]);
            budget.Account_ID   = int.Parse(variables["AccountTypeID"]);

            budgetAdapter.SetBudget(budget, User.Identity.Name);

            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Index(BudgetModel BudgetTryingToAdd = null)
        {
            ViewBag.IsNotDashboard = true;

            BudgetAdapter      budgetAdapter      = new BudgetAdapter();
            FrequencyAdapter   frequencyAdapter   = new FrequencyAdapter();
            AccountTypeAdapter accountTypeAdapter = new AccountTypeAdapter();

            BudgetModelList pageData = new BudgetModelList
            {
                Budgets      = budgetAdapter.GetBudgetsByUID(Utilities.GetUsersUID(User.Identity.Name)),
                Categories   = budgetAdapter.GetUniqueCategoryByUID(Utilities.GetUsersUID(User.Identity.Name)),
                Frequencies  = frequencyAdapter.GetAllFrequencies(),
                AccountTypes = accountTypeAdapter.GetAccountTypesByUID(Utilities.GetUsersUID(User.Identity.Name))
            };

            if (BudgetTryingToAdd != null)
            {
                pageData.NewBudget = BudgetTryingToAdd;
            }

            return(View(pageData));
        }