Ejemplo n.º 1
0
        public void SaveConsultationMark(int userId, CourseProjectConsultationMarkData consultationMarkData)
        {
            AuthorizationHelper.ValidateLecturerAccess(Context, userId);

            CourseProjectConsultationMark consultationMark;

            if (consultationMarkData.Id.HasValue)
            {
                consultationMark = Context.CourseProjectConsultationMarks
                                   .Single(x => x.Id == consultationMarkData.Id);
            }
            else
            {
                consultationMark = new CourseProjectConsultationMark
                {
                    StudentId          = consultationMarkData.StudentId,
                    ConsultationDateId = consultationMarkData.ConsultationDateId
                };
                Context.CourseProjectConsultationMarks.Add(consultationMark);
            }

            consultationMark.Mark = string.IsNullOrWhiteSpace(consultationMarkData.Mark) ? null : consultationMarkData.Mark;

            //            consultationMark.Comments = consultationMarkData.Comment;
            Context.SaveChanges();
        }
        public IActionResult Post([FromBody] CourseProjectConsultationMarkData consultationMark)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            PercentageService.SaveConsultationMark(/*todo #auth WebSecurity.CurrentUserId*/ 2, consultationMark);
            return(Ok());
        }
Ejemplo n.º 3
0
        public HttpResponseMessage Post([FromBody] CourseProjectConsultationMarkData consultationMark)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            PercentageService.SaveConsultationMark(WebSecurity.CurrentUserId, consultationMark);
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }