public static (string Total, string Average) GetCalendarRow(this CalendarWeeksModel model, string shopDescription) { var result = (totaal : string.Empty, average : string.Empty); var calendarDesciptions = model.KassaBonItem.Where(x => x.Boodschap.Description == shopDescription); if (calendarDesciptions == null) { return(result); } decimal sum = calendarDesciptions.Sum(x => x.Hoeveelheid).Value; if (sum == 0) { return(result); } string package = calendarDesciptions.Select(x => x.Boodschap.Package) .Distinct() //Resolve when it results as more lines .Single(); if (package == "St") { result.totaal = sum.ToString("0"); } else { result.totaal = sum.ToString("0.000"); } try { result.average = (sum / model.DateHeader.Count()).ToString("0.0000"); } catch { result.average = "-"; } return(result); }
public static string GetCalendarCell(this CalendarWeeksModel model, string shopDescription, string weekNumber) { string result = string.Empty; var calendarDesciptions = model.KassaBonItem.Where(x => x.Boodschap.Description == shopDescription); if (calendarDesciptions == null) { return(result); } var calendarCell = calendarDesciptions.Where(x => x.KassaBon.BonDate.WeekNumberString() == weekNumber); if (calendarCell == null) { return(result); } decimal sum = calendarCell.Sum(x => x.Hoeveelheid).Value; if (sum == 0) { return(result); } string package = calendarCell.Select(x => x.Boodschap.Package) .Distinct() //Resolve when it results as more lines .Single(); if (package == "St") { result = sum.ToString("0"); } else { result = sum.ToString("0.000"); } return(result); }