Example #1
0
        public JObject Apply(dynamic in_data)
        {
            try
            {
                JObject data      = JObject.Parse(in_data.ToString());
                string  carname   = data["carname"].ToString();
                string  caridcard = data["caridcard"].ToString();
                string  capacity  = data["capacity"].ToString();
                string  cartype   = data["cartype"].ToString();

                string us_id = data["CarpoolSSID"]?.ToString();
                if (us_id == null || Session["CarpoolSSID"].ToString() != us_id)
                {
                    return(SendData(15001, "未授权访问"));
                }

                if (CarDAL.Exist(caridcard))
                {
                    return(SendData(17001, "车牌号码已被注册"));
                }

                if (!CarDAL.Apply(us_id, carname, caridcard, capacity, cartype))
                {
                    return(SendData(20000, "服务错误"));
                }

                return(SendData(200));
            }
            catch (Exception e)
            {
                return(SendData(400, "请求错误", e.ToString()));
            }
        }