private HttpResponseMessage SavePercentageResult(PercentageResultData percentageResult)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            PercentageService.SavePercentageResult(WebSecurity.CurrentUserId, percentageResult);
            return new HttpResponseMessage(HttpStatusCode.OK);
        }
        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();
        }