//score public void AddScore(Score score) { ScoreEntity se = new ScoreEntity(); se.IdUser = score.IdUser; se.IdCategory = score.IdCategory; se.Correct = score.Correct; se.Total = score.Total; data.AddToScoreEntities(se); }
public Score UpdateScore(User user, Category category, Boolean correct) { Score score; if (!entities.ExistScore(user.IdUser, category.IdCategory)) { score = new Score() { IdUser = user.IdUser, IdCategory = category.IdCategory, Correct = correct ? 1 : 0, Total = 1 }; entities.AddScore(score); } else { score = entities.GetScore(user.IdUser, category.IdCategory); if (correct) score.Correct++; score.Total++; entities.UpdateScore(score); } return score; }
public void UpdateScore(Score score) { ScoreEntity se = data.ScoreEntities.First(x => x.IdUser == score.IdUser && x.IdCategory == score.IdCategory); se.Total = score.Total; se.Correct = score.Correct; }