public async Task <IActionResult> CalculateExpensesByAdmin(string StartDate, string EndDate)
        {
            try
            {
                if (String.IsNullOrEmpty(StartDate) && String.IsNullOrEmpty(EndDate))
                {
                    var model = new CalculateExpensesVM()
                    {
                        _Expenses = null,
                        StartDate = null,
                        EndDate   = null
                    };
                    return(View("CalculateExpensesByAdmin", model));
                }

                else
                {
                    var result = new SearchExpenses()
                    {
                        StartDate = StartDate,
                        EndDate   = EndDate
                    };
                    var SearchExpenses = await Task.Run(() => _ExpensesServ.SearchExpenses(result));

                    var list = new List <CalculateExpensesVM_Expenses>();
                    foreach (var item in SearchExpenses._Expenses.ToList())
                    {
                        var temp = new CalculateExpensesVM_Expenses()
                        {
                            Id = item.Id,

                            Name            = item.Name,
                            Amount          = item.Amount,
                            Date            = item.Date,
                            ExpenseTypeId   = item.ExpenseTypeId,
                            ExpenseTypeName = item.ExpenseTypeName
                        };
                        list.Add(temp);
                    }
                    ;

                    var model = new CalculateExpensesVM()
                    {
                        _Expenses = list,
                        ammount   = SearchExpenses.DateRangeAmount,
                        StartDate = StartDate,
                        EndDate   = EndDate
                    };

                    return(View("CalculateExpensesByAdmin", model));
                }
            }
            catch
            {
                return(BadRequest());
            }
        }
        public async Task <IActionResult> CalculateExpenses(string StartDate, string EndDate, int pg = 1)
        {
            try
            {
                if (String.IsNullOrEmpty(StartDate) && String.IsNullOrEmpty(EndDate))
                {
                    var model = new CalculateExpensesVM()
                    {
                        _Expenses = null,
                        StartDate = null,
                        EndDate   = null
                    };
                    return(View("CalculateExpenses", model));
                }

                else
                {
                    var result = new SearchExpenses()
                    {
                        StartDate = StartDate,
                        EndDate   = EndDate
                    };
                    var SearchExpenses = await Task.Run(() => _ExpensesServ.SearchExpenses(result));

                    var list = new List <CalculateExpensesVM_Expenses>();
                    foreach (var item in SearchExpenses._Expenses.ToList())
                    {
                        var temp = new CalculateExpensesVM_Expenses()
                        {
                            Id = item.Id,

                            Name            = item.Name,
                            Amount          = item.Amount,
                            Date            = item.Date,
                            ExpenseTypeId   = item.ExpenseTypeId,
                            ExpenseTypeName = item.ExpenseTypeName
                        };
                        list.Add(temp);
                    }
                    ;

                    #region "Paging"
                    const int pageSize = 5;
                    if (pg < 1)
                    {
                        pg = 1;
                    }
                    int recsCount = list.Count();
                    var pager     = new Pager(recsCount, pg, pageSize);
                    int recSkip   = (pg - 1) * pageSize;
                    var data      = list.Skip(recSkip).Take(pager.PageSize).ToList();
                    this.ViewBag.Pager = pager;
                    var model = new CalculateExpensesVM()
                    {
                        _Expenses = data,
                        ammount   = SearchExpenses.DateRangeAmount,
                        StartDate = StartDate,
                        EndDate   = EndDate
                    };
                    #endregion "Paging"

                    return(View("CalculateExpenses", model));
                }
            }
            catch
            {
                return(BadRequest());
            }
        }