Esempio n. 1
0
 public function SubmitScore(Requests\ScoreEntryRequest $request)
 {
     $input = $request->all();
     \DB::$user = '******';
     \DB::$password = '******';
     \DB::$dbName = 'Euro2016';
     $row = \DB::queryFirstRow("select * from Scores where MatchID = %i and UserID = %i", $request->matchid, Auth::user()->id);
     $count = \DB::count();
     if ($count == 0) {
         \DB::insert('Scores', array('MatchID' => $request->matchid, 'UserID' => Auth::user()->id, 'CountryHome' => $request->CountryHomeScore, 'CountryAway' => $request->CountryAwayScore));
     } else {
         \DB::update('Scores', array('CountryHome' => $request->CountryHomeScore, 'CountryAway' => $request->CountryAwayScore), "ID=%i", $row['ID']);
     }
     \DB::disconnect();
     return json_encode($input);
 }
Esempio n. 2
0
 public function SubmitScoreFinal(Requests\ScoreEntryFinalRequest $request)
 {
     $input = $request->all();
     \DB::$user = '******';
     \DB::$password = '******';
     \DB::$dbName = 'Euro2016';
     $row = \DB::queryFirstRow("select * from Scores where MatchID = %i and UserID = %i", $request->matchid, Auth::user()->id);
     $count = \DB::count();
     //Log::info($count.' '.$request->matchid);
     \DB::startTransaction();
     if ($count == 0) {
         \DB::insert('Scores', array('MatchID' => $request->matchid, 'UserID' => Auth::user()->id, 'CountryHome' => $request->CountryHomeScore, 'CountryAway' => $request->CountryAwayScore));
     } else {
         \DB::update('Scores', array('CountryHome' => $request->CountryHomeScore, 'CountryAway' => $request->CountryAwayScore), "ID=%i", $row['ID']);
     }
     $affectedcount = \DB::affectedRows();
     \DB::update('Matches', array('CountryHomeID' => $request->CountryHomeID, 'CountryAwayID' => $request->CountryAwayID), "MatchID=%i", $request->matchid);
     \DB::commit();
     \DB::disconnect();
     // retrieve country names and flag
     $countrynamehome = \DB::queryFirstRow("select CountryName, Flag from Countries where CountryID = %i", $request->CountryHomeID);
     $countrynameaway = \DB::queryFirstRow("select CountryName, Flag from Countries where CountryID = %i", $request->CountryAwayID);
     $input['CountryHomeID'] = $countrynamehome['CountryName'];
     $input['CountryAwayID'] = $countrynameaway['CountryName'];
     $input['CountryHomeImage'] = $countrynamehome['Flag'];
     $input['CountryAwayImage'] = $countrynameaway['Flag'];
     //$input['CountryHID'] = $request->CountryHomeID;
     //$input['CountryAID'] = $request->CountryAwayID;
     return json_encode($input);
 }