コード例 #1
0
        private HttpResponseMessage SavePercentageResult(PercentageResultData percentageResult)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            PercentageService.SavePercentageResult(WebSecurity.CurrentUserId, percentageResult);
            return new HttpResponseMessage(HttpStatusCode.OK);
        }
コード例 #2
0
        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();
        }