Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            StreamReader reader    = new StreamReader(context.Request.InputStream, Encoding.UTF8);
            string       jObjStr   = reader.ReadToEnd();
            DoctorModel  userModel = JsonConvert.DeserializeObject <DoctorModel>(jObjStr);

            JObject jObj = new JObject();

            //检查用户名是否存在
            if (DoctorDAL.CheckUsernameExist(userModel.Name))
            {
                jObj.Add("state", "username exist");
            }
            else
            {
                if (DoctorDAL.Insert(userModel))
                {
                    jObj.Add("state", "success");
                }
                else
                {
                    jObj.Add("state", "failed");
                }
            }
            byte[] buf = Encoding.UTF8.GetBytes(jObj.ToString());
            context.Response.OutputStream.Write(buf, 0, buf.Length);
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            StreamReader reader     = new StreamReader(context.Request.InputStream, Encoding.UTF8);
            string       requestStr = reader.ReadToEnd();

            UserModel userModel = new UserModel();
            JObject   jObj      = JObject.Parse(requestStr);

            userModel.Name     = jObj["name"].ToString();
            userModel.Password = jObj["password"].ToString();

            if (jObj["male"] == null || string.IsNullOrEmpty(jObj["male"].ToString()))
            {
                userModel.Male = null;
            }
            else
            {
                userModel.Male = bool.Parse(jObj["male"].ToString());
            }

            if (jObj["date_of_birth"] == null ||
                string.IsNullOrEmpty(jObj["date_of_birth"].ToString()))
            {
                userModel.Date_of_birth = null;
            }
            else
            {
                userModel.Date_of_birth = DateTime.Parse(jObj["date_of_birth"].ToString());
            }

            JObject jResponse = new JObject();

            //检查用户名是否存在
            if (DoctorDAL.CheckUsernameExist(userModel.Name))
            {
                jResponse.Add("state", "username exist");
            }
            else
            {
                if (UserDAL.Insert(userModel))
                {
                    jResponse.Add("state", "success");
                }
                else
                {
                    jResponse.Add("state", "failed");
                }
            }

            byte[] buf = Encoding.UTF8.GetBytes(jResponse.ToString());
            context.Response.OutputStream.Write(buf, 0, buf.Length);
        }
        public void ProcessRequest(HttpContext context)
        {
            StreamReader reader     = new StreamReader(context.Request.InputStream, Encoding.UTF8);
            string       requestStr = reader.ReadToEnd();

            JObject jObj         = JObject.Parse(requestStr);
            JObject jObjResponse = new JObject();

            if (null != jObj)
            {
                string username = (string)jObj["username"];
                if (DoctorDAL.CheckUsernameExist(username))
                {
                    jObjResponse.Add("state", "exist");
                }
                else
                {
                    jObjResponse.Add("state", "not exist");
                }
            }

            byte[] buf = Encoding.UTF8.GetBytes(jObjResponse.ToString());
            context.Response.OutputStream.Write(buf, 0, buf.Length);
        }