Exemplo n.º 1
0
        public void AddUser(FormCollection collection, User user)
        {
            UserBLL ub      = new UserBLL();
            String  message = ub.AddNewUser(collection, user);

            Index();
        }
        public MyResult Post([FromBody] object data)
        {
            JObject obj         = JObject.FromObject(data);
            string  userName    = Convert.ToString(obj["userName"]);
            string  chineseName = Convert.ToString(obj["chineseName"]);
            int     roleId      = Convert.ToInt32(obj["roleId"]);
            bool    isNew       = Convert.ToBoolean(obj["isNew"]);

            if (string.IsNullOrWhiteSpace(userName))
            {
                return(MyResult.Error("用户名不能为空!"));
            }
            if (string.IsNullOrWhiteSpace(chineseName))
            {
                return(MyResult.Error("姓名不能为空!"));
            }

            bool re = isNew ? UserBLL.AddNewUser(userName, chineseName, roleId) : UserBLL.SaveUser(userName, chineseName, roleId);

            return(re ? MyResult.OK() : MyResult.Error());
        }