示例#1
0
        public void SaveConsultationMark(int userId, DipomProjectConsultationMarkData consultationMarkData)
        {
            AuthorizationHelper.ValidateLecturerAccess(Context, userId);

            DiplomProjectConsultationMark consultationMark;

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

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

            //            consultationMark.Comments = consultationMarkData.Comment;
            Context.SaveChanges();
        }
        public HttpResponseMessage Post([FromBody] DipomProjectConsultationMarkData consultationMark)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            PercentageService.SaveConsultationMark(WebSecurity.CurrentUserId, consultationMark);
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        public IActionResult Post([FromBody] DipomProjectConsultationMarkData consultationMark)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            PercentageService.SaveConsultationMark(/*todo #auth WebSecurity.CurrentUserId*/ 2, consultationMark);
            return(Ok());
        }