public void SavePercentageResult(int userId, PercentageResultData percentageResultData) { AuthorizationHelper.ValidateLecturerAccess(Context, userId); CoursePercentagesResult coursePercentagesResult; if (percentageResultData.Id.HasValue) { coursePercentagesResult = Context.CoursePercentagesResults .Single(x => x.Id == percentageResultData.Id); } else { coursePercentagesResult = new CoursePercentagesResult { StudentId = percentageResultData.StudentId, CoursePercentagesGraphId = percentageResultData.PercentageGraphId }; Context.CoursePercentagesResults.Add(coursePercentagesResult); } coursePercentagesResult.Mark = percentageResultData.Mark; coursePercentagesResult.Comments = percentageResultData.Comment; Context.SaveChanges(); }
public void SavePercentageResult(int userId, PercentageResultData percentageResultData) { AuthorizationHelper.ValidateLecturerAccess(Context, userId); CoursePercentagesResult coursePercentagesResult; if (percentageResultData.Id.HasValue) { coursePercentagesResult = Context.CoursePercentagesResults .Single(x => x.Id == percentageResultData.Id); } else { coursePercentagesResult = new CoursePercentagesResult { StudentId = percentageResultData.StudentId, CoursePercentagesGraphId = percentageResultData.PercentageGraphId }; Context.CoursePercentagesResults.Add(coursePercentagesResult); } coursePercentagesResult.Mark = percentageResultData.Mark; coursePercentagesResult.Comments = percentageResultData.Comment; Context.SaveChanges(); }