Ejemplo n.º 1
0
        /// <summary>
        /// 添加工作任务评论
        /// </summary>
        /// <param name="user">评论人</param>
        /// <param name="taskId">工作任务</param>
        /// <param name="comment">评论</param>
        public bool AddComment(UserModel user, int taskId, string comment)
        {
            if (taskId <= 0 || string.IsNullOrEmpty(comment))
            {
                Log.Error("无效的评论。");
                throw new InvalidOperationException("无效的评论。 ");
            }

            using (var dbContext = new MissionskyOAEntities())
            {
                var entity = new WorkTaskComment()
                {
                    Comment     = comment,
                    UserId      = user.Id,
                    TaskId      = taskId,
                    CreatedTime = DateTime.Now
                };

                dbContext.WorkTaskComments.Add(entity); //添加评论

                dbContext.SaveChanges();

                return(true);
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <WorkTaskComment> > Create([FromBody] WorkTaskComment taskComment)
        {
            taskComment.Date = DateTime.Now;

            var res = await _workTaskCommentService.AddNewItem(taskComment);

            return(Ok(res));
        }
        public static WorkTaskCommentModel ToModel(this WorkTaskComment entity)
        {
            if (entity == null)
            {
                Log.Error("参数无效。");
                throw new InvalidOperationException("参数无效。");
            }

            var model = new WorkTaskCommentModel()
            {
                Id          = entity.Id,
                TaskId      = entity.TaskId,
                UserId      = entity.UserId,
                Comment     = entity.Comment,
                CreatedTime = entity.CreatedTime
            };

            return(model);
        }
        public static WorkTaskComment ToEntity(this WorkTaskCommentModel model)
        {
            if (model == null)
            {
                Log.Error("参数无效。");
                throw new InvalidOperationException("参数无效。");
            }

            var enity = new WorkTaskComment()
            {
                Id          = model.Id,
                TaskId      = model.TaskId,
                UserId      = model.UserId,
                Comment     = model.Comment,
                CreatedTime = model.CreatedTime
            };

            return(enity);
        }