コード例 #1
0
        public JsonResult Comment(int topic, string comment, string email, string name)
        {
            if (topic == 0)
            {
                return(Json(new { status = HttpStatusCode.BadRequest }));
            }


            var cTopic = dataItemService.GetDataItem(topic);

            if (cTopic == null)
            {
                return(Json(new { status = HttpStatusCode.NotFound }));
            }

            if (String.IsNullOrEmpty(comment) || String.IsNullOrEmpty(email) || String.IsNullOrEmpty(name))
            {
                return(Json(new { status = HttpStatusCode.NoContent }));
            }

            Comment commentTopic = new Comment
            {
                Content       = comment,
                Name          = name,
                Email         = email,
                ComemmentTime = DateTime.Now,
                DataItemID    = topic
            };

            dataItemService.CreateComment(commentTopic);
            dataItemService.SaveDataItem();
            var jsonData = new
            {
                status = HttpStatusCode.OK,
                data   = new
                {
                    Id            = commentTopic.ID,
                    Content       = commentTopic.Content,
                    Name          = commentTopic.Name,
                    Email         = commentTopic.Email,
                    ComemmentTime = commentTopic.ComemmentTime.ToString(),
                    DataItemID    = commentTopic.DataItemID
                }
            };

            return(Json(jsonData));
        }
コード例 #2
0
 /// <summary>
 /// 保存分类表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="dataItemEntity">分类实体</param>
 /// <returns></returns>
 public void SaveDataItem(string keyValue, DataItemEntity dataItemEntity)
 {
     _dataItemService.SaveDataItem(keyValue, dataItemEntity);
 }