Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        private IActionResult SavePercentageResult(PercentageResultData percentageResult)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            PercentageService.SavePercentageResult(/*todo #auth WebSecurity.CurrentUserId*/ 2, percentageResult);
            return(Ok());
        }
Ejemplo n.º 4
0
 public HttpResponseMessage Put([FromBody] PercentageResultData percentage)
 {
     return(SavePercentageResult(percentage));
 }
Ejemplo n.º 5
0
 public IActionResult Put([FromBody] PercentageResultData percentage)
 {
     return(SavePercentageResult(percentage));
 }