Exemplo n.º 1
0
        public static ResponceModel Change(string username, int id, string content, string pic)
        {
            if (content != "")
            {
                MsgUni msg = new MsgUni(id);
                if (msg.TryQuery())
                {
                    if (msg.mark == 2)
                    {
                        return(new ResponceModel(403, "该留言已删除"));
                    }
                    msg.content = content;
                    if (pic != null)
                    {
                        msg.pic = ToolUtil.HexToByte(pic);
                    }
                    msg.Update("body");
                    msg.SavePic();

                    return(new ResponceModel(200, "修改留言成功", msg));
                }
                else
                {
                    return(new ResponceModel(403, "该留言不存在"));
                }
            }
            else
            {
                return(new ResponceModel(403, "留言内容为空"));
            }
        }
Exemplo n.º 2
0
        public static ResponceModel Add(string username, string content, string pic)
        {
            if (content != "")
            {
                //SOLVED BUG ??
                byte[] data = null;

                if (pic != null)
                {
                    data = ToolUtil.HexToByte(pic);
                }

                MsgUni msg = new MsgUni(username, content, data)
                {
                    time       = DateTime.Now.ToString(),
                    updatetime = DateTime.Now.ToString(),
                };
                msg.Add();

                msg = SqlExtension.GetLastRecord <MsgUni>();

                if (data != null)
                {
                    msg.SavePic();
                }
                return(new ResponceModel(200, "添加成功", msg));
            }
            else
            {
                return(new ResponceModel(403, "留言内容为空"));
            }
        }