public async Task <IActionResult> PastRecordSave(PlayerPastRecorddto playerPastRecord) { if (ModelState.IsValid) { return(Json(ResponseHelper.UpdateSuccess())); } return(Json(ResponseHelper.UpdateUnSuccess())); }
public async Task <PlayerPastRecorddto> GetPlayerPastRecordByPlayerId(int?playerId) { var playerPastRecord = await _context.PlayerPastRecord .AsNoTracking() .Select(i => new PlayerPastRecorddto { PlayerPastRecordId = i.PlayerPastRecordId, PlayerId = i.PlayerId, TotalMatch = i.TotalMatch, TotalInnings = i.TotalInnings, TotalBatRuns = i.TotalBatRuns, TotalBatBalls = i.TotalBatBalls, TotalFours = i.TotalFours, TotalSixes = i.TotalSixes, NumberOf50s = i.NumberOf50s, NumberOf100s = i.NumberOf100s, TotalNotOut = i.TotalNotOut, GetBowled = i.GetBowled, GetCatch = i.GetCatch, GetHitWicket = i.GetHitWicket, GetLBW = i.GetLBW, GetRunOut = i.GetRunOut, GetStump = i.GetStump, TotalOvers = i.TotalOvers, TotalBallRuns = i.TotalBallRuns, TotalWickets = i.TotalWickets, TotalMaidens = i.TotalMaidens, FiveWickets = i.FiveWickets, DoBowled = i.DoBowled, DoCatch = i.DoCatch, DoHitWicket = i.DoHitWicket, DoLBW = i.DoLBW, DoStump = i.DoStump, OnFieldCatch = i.OnFieldCatch, OnFieldRunOut = i.OnFieldRunOut, OnFieldStump = i.OnFieldStump, BestScore = i.BestScore, Name = i.Player.Player_Name }) .SingleOrDefaultAsync(m => m.PlayerId == playerId); if (playerPastRecord == null) { playerPastRecord = new PlayerPastRecorddto(); } return(playerPastRecord); }
public async Task <IActionResult> PastRecordSave(PlayerPastRecorddto playerPastRecord) { if (ModelState.IsValid) { try { var model = _mapper.Map <PlayerPastRecord>(playerPastRecord); _context.Update(model); await _context.SaveChangesAsync(); } catch (Exception ex) { return(BadRequest(new { Error = ex, Data = playerPastRecord, ModelState })); } return(Json(ResponseHelper.UpdateSuccess())); } return(BadRequest(ModelState)); }