public ActionResult VideoReportByCat(int catid, DateTime?from, DateTime?to, string dateType = "week") { DateTime d = DateTime.Today; if (!to.HasValue) { if (dateType == "day") { to = from.Value; } else if (dateType == "week") { to = from.Value.AddDays(6); } else if (dateType == "month") { to = from.Value.AddMonths(1).AddDays(-1); } else if (dateType == "year") { to = from.Value.AddYears(1).AddDays(-1); } } var data = _videoRepository.GetAccessDataByCatBetween(catid, from.Value, to.Value); ViewBag.catId = catid; ViewBag.catName = _videoCatRepository.Find(catid).Name; ViewBag.dateType = dateType; ViewBag.fromDate = from.Value.Date.ToString("dd/MM/yyyy"); ViewBag.toDate = to.Value.Date.ToString("dd/MM/yyyy"); return(View(data)); }