Example #1
0
        public ActionResult NewAdjustment(BudgetAdjustmentViewModel bavm)
        {
            ViewBag.Title = Constant.BUDGET_ADJUSTMENT;

            bavm.BudgetList = BudgetAdjustmentCommon();

            try
            {
                if (ModelState.IsValid)
                {
                    bavm.Status      = 1;
                    bavm.CreatedDate = DateTime.Now;
                    _repAnnualBudget.CreateAnnualBudget(bavm);

                    var budgetObj = _repAnnualBudget.GetBudgetList().OrderByDescending(x => x.Id).Take(1).SingleOrDefault();

                    if (budgetObj != null)
                    {
                        return(RedirectToAction("Dashboard", "Home"));
                    }
                }
            }
            catch (IOException e)
            {
                if (e.Source != null)
                {
                    Console.WriteLine("IOException source: {0}", e.Source);
                    throw;
                }
            }

            return(View(bavm));
        }
        public IEnumerable <BudgetViewModel> GetBudgetList()
        {
            var buvm      = new BudgetViewModel();
            var lstBudget = new List <BudgetViewModel>();

            var budgetList = _repAnnualBudget.GetBudgetList().ToList();

            for (int i = 0; i < budgetList.Count; i++)
            {
                var bvm = new BudgetViewModel();

                bvm.BudgetProvision = budgetList[i].BudgetProvision;
                lstBudget.Add(bvm);
            }

            return(lstBudget.ToList());
        }
        public ActionResult Index()
        {
            ViewBag.Title = Constant.BUDGET_LIST;
            var buvm       = new BudgetViewModel();
            var lstBudget  = new List <BudgetViewModel>();
            var budgetList = _repAnnualBudget.GetBudgetList().OrderByDescending(x => x.Id).ToList();

            foreach (var item in budgetList)
            {
                var ExceedSum = _repAnnualBudget.GetBudgetExceed()
                                .Where(x => x.BudgetId == item.Id)
                                .Select(x => x.ExceedAmountProvision)
                                .Sum();

                var bvm = new BudgetViewModel()
                {
                    Id              = item.Id,
                    Year            = item.Year,
                    BudgetProvision = item.BudgetProvision,
                    ExceedProvision = ExceedSum,
                    TotalProvision  = item.BudgetProvision + ExceedSum,
                    UsedBudget      = _repAnnualBudget.GetUsedBudget(item.Id), //Total Purchase - Total Purchase Return
                    RemainingAmount = item.BudgetProvision +
                                      _repAnnualBudget.GetExceedProvision(item.Id) -
                                      _repAnnualBudget.GetUsedBudget(item.Id),
                    StartDate = item.StartDate,
                    EndDate   = item.EndDate,
                    Status    = item.Status
                };
                lstBudget.Add(bvm);
            }

            buvm.BudgetList = lstBudget;

            var currentBudgetList = _repAnnualBudget.GetBudgetList().Where(x => x.Year == DateTime.Now.Year.ToString()).SingleOrDefault();

            buvm.RemainingAmount = currentBudgetList.BudgetProvision
                                   + _repAnnualBudget.GetExceedProvision(currentBudgetList.Id)
                                   - _repAnnualBudget.GetUsedBudget(currentBudgetList.Id);
            //buvm.RemainingAmount = 0;

            return(View(buvm));
        }