Beispiel #1
0
        public JSONResult DeleteUser([FromBody] User user)
        {
            int row = _userService.DeleteUser(user.Id);

            if (row == 0)
            {
                return(JSONResult.ErrorMsg(""));
            }
            return(JSONResult.Ok());
        }
Beispiel #2
0
        public JSONResult Register([FromBody] User user)
        {
            if (user == null)
            {
                return(JSONResult.ErrorMsg("注册失败"));
            }
            int row = _userService.SaveUser(user);

            if (row == 0)
            {
                return(JSONResult.ErrorMsg("注册失败."));
            }
            return(JSONResult.Ok());
        }
        public JSONResult Check([FromBody] Poll poll)
        {
            if (poll == null)
            {
                return(JSONResult.ErrorMsg(""));
            }
            User user = HttpContext.Session.Get <User>("user");

            poll.Uid = user.Id;
            bool flag = _pollService.CheckPoll(poll);

            if (flag)
            {
                return(JSONResult.ErrorMsg(""));
            }
            return(JSONResult.Ok());
        }
        public JSONResult Add([FromBody] Poll poll)
        {
            if (poll == null)
            {
                return(JSONResult.ErrorMsg("投票失败"));
            }
            User user = HttpContext.Session.Get <User>("user");

            poll.Uid = user.Id;
            Console.WriteLine(poll.Uid + " " + poll.Vid + "  " + poll.Oids[0]);
            int row = _pollService.SavePoll(poll);

            if (row == 0)
            {
                return(JSONResult.ErrorMsg("投票失败."));
            }
            return(JSONResult.Ok());
        }
        public JSONResult login([FromBody] User user)
        {
            if (user.Username.Length == 0 || user.Password.Length == 0)
            {
                return(JSONResult.ErrorMsg(""));
            }
            SessionUser suser = _userService.CheckUser(user.Username, user.Password);

            if (suser == null)
            {
                return(JSONResult.ErrorMsg("用户名或密码错误"));
            }
            HttpContext.Session.Set("user", suser);
            if (suser.Type == true)
            {
                return(JSONResult.Ok(true));
            }
            return(JSONResult.Ok(false));
        }
Beispiel #6
0
        public JSONResult DeleteUsers([FromBody] List <User> users)
        {
            string delStr = "(";
            int    len    = users.Count();

            for (int i = 0; i < len; i++)
            {
                if (i != 0)
                {
                    delStr += ',';
                }
                delStr += users[i].Id;
            }
            delStr += ')';
            Console.WriteLine(delStr);
            int row = _userService.DeleteUsers(delStr);

            if (row == 0)
            {
                return(JSONResult.ErrorMsg(""));
            }
            return(JSONResult.Ok());
        }