public ActionResult Index() { if (Request.IsAuthenticated) { string currentUserName = System.Web.HttpContext.Current.User.Identity.Name; ViewBag.UserName = currentUserName; ViewBag.Today = DateTime.Now.ToString("D"); ViewBag.TotalItem = homeManager.GetItem(); ViewBag.StockOut = homeManager.GetStockOut(); ViewBag.Profit = homeManager.GetTotalSoldItemCost(); ViewBag.Below = homeManager.GetReorderBelowCount(); ViewBag.BelowReorderItems = homeManager.GetBelowReorderViewItems(); ViewBag.Year = DateTime.Now.Year; int year = DateTime.Now.Year; int month = DateTime.Now.Month; ViewBag.Jan = homeManager.CalculateTotalByMonth(1, year); ViewBag.Feb = homeManager.CalculateTotalByMonth(2, year); ViewBag.Mar = homeManager.CalculateTotalByMonth(3, year); ViewBag.Apr = homeManager.CalculateTotalByMonth(4, year); ViewBag.May = homeManager.CalculateTotalByMonth(5, year); ViewBag.Jun = homeManager.CalculateTotalByMonth(6, year); ViewBag.Jul = homeManager.CalculateTotalByMonth(7, year); ViewBag.Aug = homeManager.CalculateTotalByMonth(8, year); ViewBag.Sept = homeManager.CalculateTotalByMonth(9, year); ViewBag.Oct = homeManager.CalculateTotalByMonth(10, year); ViewBag.Nov = homeManager.CalculateTotalByMonth(11, year); ViewBag.Dec = homeManager.CalculateTotalByMonth(12, year); if (month == 1) { ViewBag.prevTwoMonth = homeManager.CalculatePercentageProfitByMonth(11, year - 1); ViewBag.prevMonth = homeManager.CalculatePercentageProfitByMonth(12, year - 1); ViewBag.recMonth = homeManager.CalculatePercentageProfitByMonth(month, year); ViewBag.prevTwoMonthName = "November"; ViewBag.prevMonthName = "December"; ViewBag.MonthName = "January"; } else if (month == 2) { ViewBag.prevTwoMonth = homeManager.CalculatePercentageProfitByMonth(12, year - 1); ViewBag.prevMonth = homeManager.CalculatePercentageProfitByMonth(1, year); ViewBag.recMonth = homeManager.CalculatePercentageProfitByMonth(month, year); ViewBag.prevTwoMonthName = "December"; ViewBag.prevMonthName = "January"; ViewBag.MonthName = "February"; } else { ViewBag.prevTwoMonth = homeManager.CalculatePercentageProfitByMonth(month - 2, year - 1); ViewBag.prevMonth = homeManager.CalculatePercentageProfitByMonth(month - 1, year); ViewBag.recMonth = homeManager.CalculatePercentageProfitByMonth(month, year); ViewBag.prevTwoMonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month - 2); ViewBag.prevMonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month - 1); ViewBag.MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month); } ViewBag.MonthlySold = homeManager.GetMonthlySoldItems(); return(View()); } else { return(HttpNotFound()); } }