示例#1
0
        /// <summary>
        /// Post时调用
        /// </summary>
        public override void OnPost(HttpRequest request, HttpResponse response)
        {
            bool status = false;

            if (request.Operation == null)//添加一条数据
            {
                Dataset da = Dataset.CreateInstanceFromJSON(request.PostParams);

                if (null != da)
                {
                    //添加到数据库
                    Console.WriteLine("添加数据库信息");
                    status = bll.Add(da.ToDataAngineModel());
                }
            }
            else
            {
                if (request.Operation == "update")//更新
                {
                    Console.WriteLine("更新数据库信息");
                    Dataset da = Dataset.CreateInstanceFromJSON(request.PostParams);
                    if (null != da)
                    {
                        status = bll.Update(da.ToDataAngineModel());
                    }
                }
                else if (request.Operation == "delete")//删除
                {
                    int id = -1;
                    try
                    {
                        id = Convert.ToInt32(request.RestConvention);
                    }
                    catch
                    {
                    }
                    status = bll.Delete(id);
                }
            }
            response.SetContent(status.ToString());
            response.Send();
        }