Exemple #1
0
        public ActionResult SaveStockUser(Dictionary <string, string> queryvalues)
        {
            int    GroupID  = queryvalues.ContainsKey("GroupID") ? Convert.ToInt32(queryvalues["GroupID"]) : -1; //库组
            string UserName = queryvalues.ContainsKey("UserName") ? queryvalues["UserName"].ToString() : "";     //用户名

            //检测非法字符
            if (UserName.Contains("'"))
            {
                return(Content("2"));
            }
            //检测用户是否已经被其他的库存分配了
            if (UserName != "")
            {
                IEnumerable <UserStock> users = ServEmailBLL.GetOtherUsers(GroupID, UserName);
                if (users.Count() > 0)
                {
                    return(Content("3"));
                }

                //说明有用户不存在
                IEnumerable <AspNetUser> aspnetUsers = SUBLL.GetAspNetUsersByUserName(UserName);
                int num = UserName.Split(',').Length;
                if (aspnetUsers.Count() != num)
                {
                    return(Content("4"));
                }
            }
            //用户是否存在



            //Oper
            int res = ServEmailBLL.AddStockUser(GroupID, UserName);

            if (res >= 1)
            {
                return(Content("1"));
            }
            else
            {
                return(Content("0"));
            }
        }