Created
March 30, 2010 23:21
-
-
Save peterlandry/349734 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public JsonResult GraphOne ( int week ) { | |
if ( week == 0 || week > 10 ) { | |
week = 11; | |
} | |
var dc = new PortalDataContext( ); | |
List<object> actual = new List<object>( ); | |
for ( int i = 0 ; i < week ; i++ ) { | |
var date = GetWeekEndingDate( i ); | |
var total = dc.RepLogResults.Where( r => r.WeekEnding == date ).Sum( r => r.Trial1 + r.Trial2 + r.Trial3 ); | |
actual.Add( new { @value = total } ); | |
} | |
List<object> goal = new List<object>( ); | |
for ( int i = 0 ; i < 11 ; i++ ) { | |
goal.Add( new { @week = i.ToString( ) , @value = 5400 } ); | |
} | |
return this.Json( new{ actual, goal} ); | |
} | |
public JsonResult GraphThree ( int week ) { | |
if ( week == 0 || week > 10 ) { | |
week = 11; | |
} | |
var dc = new PortalDataContext( ); | |
var resultsAll = dc.RepLogResults; | |
var date = GetWeekEndingDate( week ); | |
if ( week >= 11 ) { | |
date = dc.RepLogResults.Max( r => r.WeekEnding ); | |
if ( date == null ) { | |
date = _FirstSunday.AddDays( -14 ); | |
} | |
} | |
var resultsWeekEnding = resultsAll.Where( a => a.WeekEnding == date ); | |
var fbWe = resultsWeekEnding.Sum( a => a.Social2 + a.Social3 ); | |
var fbAll = resultsAll.Sum( a => a.Social2 + a.Social3 ); | |
var twWe = resultsWeekEnding.Sum( a => a.Social5 + a.Social6 ); | |
var twAll = resultsAll.Sum( a => a.Social5 + a.Social6 ); | |
var ytWe = resultsWeekEnding.Sum( a => a.Social7 + a.Social8 ); | |
var ytAll = resultsAll.Sum( a => a.Social7 + a.Social8 ); | |
var fb = new { @current = getValueIfNull(fbWe) , @ProgramToDate = getValueIfNull(fbAll) }; | |
var tw = new { @current = getValueIfNull(twWe), @ProgramToDate=getValueIfNull(twAll) }; | |
var yt = new { @current = getValueIfNull(ytWe), @ProgramToDate=getValueIfNull(ytAll) }; | |
return this.Json( new { fb , tw , yt } ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment