public ActionResult GetExecutiiBugetare(ExecutiiBugetareViewModel model) { var reports = this.Data.Plancts .All() .Select(p => new DisplayExecutiiBugetareViewModel() { DenumireCont = p.Denumire, Simbol = p.Simbol }) .ToList(); var dateTime = new DateTime(model.Year, model.Month, DateTime.DaysInMonth(model.Year, model.Month)); var counter = 0; foreach (var report in reports) { counter += 1; report.NrCrt = counter; this.SetRulajLunarAndRulajCumulatToReport(model, dateTime, report); } var orderedReports = reports .OrderBy(r => r.NrCrt) .ThenBy(r => r.DenumireCont) .ThenBy(r => r.Simbol) .ToList(); return PartialView("_GetExecutiiBugetare", orderedReports); }
private void SetRulajLunarAndRulajCumulatToReport(ExecutiiBugetareViewModel model, DateTime dateTime, DisplayExecutiiBugetareViewModel report) { if (model.Protopopiate == -1 && model.Parohii == -1) { var rulajLunar = this.Data.Ebs .All() .Where(e => e.Data == dateTime && e.Simbol == report.Simbol) .ToList() .Sum(e => e.RulajLunar); var rulajCumulat = this.Data.Ebs .All() .Where(e => e.Data == dateTime && e.Simbol == report.Simbol) .ToList() .Sum(e => e.RulajCumulat); report.RulajLunar = rulajLunar; report.RulajCumulat = rulajCumulat; } else if (model.Protopopiate != -1 && model.Parohii == -1) { var cifs = this.Data.Parohiis .All() .Where(p => p.ProtopopiateId == model.Protopopiate) .Select(p => p.Cif) .ToList(); var rulajLunar = this.Data.Ebs .All() .Where(e => cifs.Contains(e.Cif) && e.Simbol == report.Simbol) .ToList() .Sum(e => e.RulajLunar); var rulajCumulat = this.Data.Ebs .All() .Where(e => cifs.Contains(e.Cif) && e.Simbol == report.Simbol) .ToList() .Sum(e => e.RulajCumulat); report.RulajLunar = rulajLunar; report.RulajCumulat = rulajCumulat; } else if (model.Protopopiate != -1 && model.Parohii != -1) { var parohiis = this.Data.Parohiis .All() .Where(p => p.Cif == model.Parohii); var eb = this.Data.Ebs .All() .FirstOrDefault(e => e.Cif == model.Parohii && e.Data == dateTime && e.Simbol == report.Simbol); if (eb != null) { report.RulajLunar = eb.RulajLunar; report.RulajCumulat = eb.RulajCumulat; } } }
public ActionResult ExecutiiBugetare() { SelectList selectedListMonths; SelectList selectedListParohiis; SelectList selectedListProtopopiates; this.GetDropdownListsForExecutiiBugetare(out selectedListMonths, out selectedListParohiis, out selectedListProtopopiates); ViewBag.Months = selectedListMonths; ViewBag.Parohiis = selectedListParohiis; ViewBag.Protopopiates = selectedListProtopopiates; var newModel = new ExecutiiBugetareViewModel { Year = DateTime.Now.Year }; return View(newModel); }