Ejemplo n.º 1
0
        public void SignupTest()
        {
            BmobUser user = new BmobUser();

            user.username = "******";
            user.password = "******";

            // 1
            try
            {
                var future = Bmob.SignupTaskAsync(user);
                FinishedCallback(future.Result, null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            // 2
            try
            {
                var future = Bmob.SignupTaskAsync(user);
                FinishedCallback(future.Result, null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 2
0
        public object PostAddStudent([FromBody] List <User> user1)
        {
            HttpCookie    cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String        Id       = cookie1["CourseId"];
            int           courseId = int.Parse(Id);
            String        a        = "";
            List <User>   error    = new List <User>();
            List <String> list     = new List <String>();

            userList.AddRange(user1);
            int length = userList.Count;

            for (int i = 0; i < userList.Count; i++)
            {
                User user = new User();
                user.username  = userList[i].username;
                user.password  = userList[i].password;
                user.name      = userList[i].name;
                user.identity  = userList[i].identity;
                user.classId   = userList[i].classId;
                user.firstTime = 0;
                user.courseId  = courseId;

                var future = Bmob.SignupTaskAsync(user);
                try
                {
                    String id = future.Result.objectId;
                    list.Add(id);
                }
                catch
                {
                    error.Add(user);
                }
            }
            if (userList.Count == list.Count)
            {
                a = "上传成功";
                return(a);
            }
            else
            {
                return(ResultToJson.toJson(error));
            }
        }
Ejemplo n.º 3
0
        public object PostAddStudent([FromBody] User userInfo)
        {
            HttpCookie cookie1  = HttpContext.Current.Request.Cookies["CurrentCourse"];
            String     Id       = cookie1["CourseId"];
            int        courseId = int.Parse(Id);
            String     id       = "";

            userInfo.identity  = "student";
            userInfo.firstTime = 0;
            userInfo.courseId  = courseId;
            var future = Bmob.SignupTaskAsync(userInfo);

            try
            {
                id = "success";
            }
            catch
            {
                id = "fail";
            }

            return(id);
        }