コード例 #1
0
        public Result <LessonComment> AddComment(int lessonId, LessonCommentDTO dto)
        {
            //todo: check has enrolled/attended class

            LessonComment comment = new LessonComment()
            {
                Comment = dto.Comment, CreatedTime = DateTime.UtcNow, CreatedById = UserId, LessonId = lessonId
            };

            _lessonRepository.AddComment(comment);

            //var response = Request.CreateResponse(HttpStatusCode.Created);
            // Generate a link to the new book and set the Location header in the response.
            //string uri = Url.Link("GetCommentById", new { lessonId = lessonId, id = comment.Id });
            //response.Headers.Location = new Uri(uri);
            //return response;

            Result <LessonComment> res = new Result <LessonComment>(true, comment);

            return(res);
        }