public IActionResult Text(int taskId) { var user = _userData.GetUserWithStats(User.GetUserId()); var task = _taskData.GetTextTask(taskId); TextTaskStatistics currentStat = null; foreach (var stat in user.CourseStatistics) { foreach (var textTaskStatistic in stat.TextTaskStatistics) { if (textTaskStatistic.TaskId == taskId) { currentStat = textTaskStatistic; break; } } } if (currentStat != null) { currentStat.IsComplete = true; _statisticData.UpdateTextTaskStatistic(currentStat); return(Ok()); } return(NotFound()); }
public void UpdateTextTaskStatistic(TextTaskStatistics statistics) { _context.TextTaskStatistics.Update(statistics); _context.SaveChanges(); }