public ActionResult CommissionsReport(int idPeriod = 0, int page = 1) { var period = new Period().GetAll(Settings.AutenticationKeyEarningSystem).OrderByDescending(m => m.DataInicio).Where(m => m.IdStatusPeriodo == 2 || m.IdStatusPeriodo == 3).ToList(); ViewBag.Periods = GetPeriodSelectListItem(period, idPeriod); if (idPeriod != 0) { ViewBag.SelectedPeriod = idPeriod; } else { var periodAnterior = period.FirstOrDefault(m => m.DataTermino < DateTime.Today); if (periodAnterior == null || periodAnterior == new PeriodModel()) { periodAnterior = period.FirstOrDefault() ?? new PeriodModel(); } ViewBag.SelectedPeriod = periodAnterior.IdPeriodo; } var consolidatedCommissionModel = new List<ConsolidatedCommissionModel>(); if (idPeriod != 0) { consolidatedCommissionModel = new Commissions().SelectConsolidatedCommissions(Settings.AutenticationKeyEarningSystem, idPeriod).ToList(); ViewBag.TotalComissoes = consolidatedCommissionModel.Sum(m => m.ValorComissionamento); ViewBag.TotalComissoesPagas = consolidatedCommissionModel.Where(m => m.IsPago).Sum(m => m.ValorComissionamento); ViewBag.TotalCompras = consolidatedCommissionModel.Sum(m => m.ValorPedido); ViewBag.IsPartial = period.Any(m => m.IdPeriodo == idPeriod && m.IdStatusPeriodo == 3); } return View(CreateMvcList(consolidatedCommissionModel, page)); }
public ActionResult AnalyticalReport(int idPeriod = 0) { var periods = new Period().GetAll(Settings.AutenticationKeyEarningSystem).OrderByDescending(m => m.DataInicio).ToList(); ViewBag.Periods = GetPeriodSelectListItem(periods, idPeriod); var orders = new List<OrderModels>(); if (idPeriod != 0) { var period = periods.FirstOrDefault(m => m.IdPeriodo == idPeriod); orders = SetValues(idPeriod, period); } return View(orders); }