public ActionResult SaveNewExpense()
        {
            //save new expense in DB and return json of all expenses
            if (!Authorize())
            {
                return(RedirectToAction("RedirectByUser", "Home"));
            }
            ExpenseDal expDal     = new ExpenseDal();
            Expense    newExpense = new Expense();

            try
            {
                newExpense.UserName     = ((User)(Session["CurrentUser"])).UserName;
                newExpense.Amount       = Convert.ToDouble(Request.Form["Amount"]);
                newExpense.Store        = Request.Form["Store"];
                newExpense.Category     = Request.Form["categoryCombo"];
                newExpense.referenceNum = Request.Form["referenceNum"];
                newExpense.Comment      = Request.Form["Comment"];
                newExpense.expDate      = Convert.ToDateTime(Request.Form["expDate"]);
                newExpense.EntryDate    = DateTime.Now;
                newExpense.groupID      = ((Int32)(Session["gid"]));
            }
            catch (Exception)
            {
                ViewBag.addNewCExpenseError = "שדות חובה!";
            }
            ModelState.Clear();
            TryValidateModel(newExpense);
            if (ModelState.IsValid)
            {
                //save the new expense
                try
                {
                    expDal.Expenses.Add(newExpense);
                    expDal.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    ViewBag.addNewCExpenseError = "התרחשה שגיאה בהוספת ההוצאה!";
                }
            }
            int            gid          = (int)Session["gid"];
            List <Expense> expenseGroup = (from e in expDal.Expenses
                                           where e.groupID == gid
                                           select e).ToList <Expense>();

            Thread.Sleep(2000);
            return(Json(expenseGroup, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetExpensesByJson()
        {
            //get json of all the expenses of the group
            if (!Authorize())
            {
                return(RedirectToAction("RedirectByUser", "Home"));
            }
            int            gid          = (int)Session["gid"];
            ExpenseDal     expDal       = new ExpenseDal();
            List <Expense> expenseGroup = (from e in expDal.Expenses
                                           where e.groupID == gid
                                           select e).ToList <Expense>();

            Thread.Sleep(2000);
            return(Json(expenseGroup, JsonRequestBehavior.AllowGet));
        }