public async Task <ResponseEntity> addUserProject(UserProject project, string token = "")
        {
            UserJira user = _userService.getUserByToken(token).Result;
            Project  pro  = _projectRepository.GetSingleByConditionAsync("id", project.projectId).Result;

            if (pro == null)
            {
                return(new ResponseEntity(StatusCodeConstants.NOT_FOUND, "Project is not found!", MessageConstants.MESSAGE_ERROR_404));
            }
            if (pro.creator != user.id)
            {
                return(new ResponseEntity(StatusCodeConstants.FORBIDDEN, "User is unthorization!", MessageConstants.MESSAGE_ERROR_403));
            }
            List <KeyValuePair <string, dynamic> > columns = new List <KeyValuePair <string, dynamic> >();

            columns.Add(new KeyValuePair <string, dynamic>("projectId", project.projectId));
            columns.Add(new KeyValuePair <string, dynamic>("userId", project.userId));


            IEnumerable <Project_User> lstProjectUser = _projectUserRepository.GetMultiByListConditionAndAsync(columns).Result;

            if (lstProjectUser.Count() > 0)
            {
                return(new ResponseEntity(StatusCodeConstants.ERROR_SERVER, "User already exists in the project!", MessageConstants.MESSAGE_ERROR_500));
            }
            Project_User model = new Project_User();

            model.userId    = project.userId;
            model.projectId = project.projectId;
            model.deleted   = false;
            model.alias     = project.userId + "_" + project.projectId;
            await _projectUserRepository.InsertAsync(model);

            return(new ResponseEntity(StatusCodeConstants.OK, "has added the user to the project !", MessageConstants.MESSAGE_SUCCESS_200));
        }
        public bool UserProject_user(Project_User pru)
        {
            string sql = string.Format(@"delete Project_user 
                                    where Project_UserID='{0}'", pru.Project_UserID);

            return(DBHelper.Update(sql));
        }
        protected void rp_zixun_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "del")
            {
                Project_User pry = new Project_User();
                pry.Project_UserID = int.Parse(e.CommandArgument.ToString());
                ItemManageBLL upb = new ItemManageBLL();
                if (upb.UserProject_user(pry))
                {
                    Response.Write("<script>alert('删除成功');</script>");
                    if (Request.QueryString["Investment_state"] == null)
                    {
                        conut(Accounts, "支持的");
                    }
                    else if (Request.QueryString["Investment_state"] != null)
                    {
                        string selectname = Request.QueryString["Investment_state"];
                        Session["Investment_state"] = Request.QueryString["Investment_state"];
                        conut(Accounts, selectname);
                    }
                }
                else
                {
                    Response.Write("<script>alert('删除失败');</script>");
                    if (Request.QueryString["Investment_state"] == null)
                    {
                        conut(Accounts, "支持的");
                    }
                    else if (Request.QueryString["Investment_state"] != null)
                    {
                        string selectname = Request.QueryString["Investment_state"];
                        Session["Investment_state"] = Request.QueryString["Investment_state"];
                        conut(Accounts, selectname);
                    }
                }
            }
            //if (e.CommandName == "bianj")
            //{
            //    //************************************如果是用户发起的才能进行编辑
            //    if (Request.QueryString["Investment_state"] == "发起的")
            //    {
            //        Zd.Project_Xz = 2;
            //        Zd.ProjectID = int.Parse(e.CommandArgument.ToString());
            //        Response.Redirect("information.aspx");
            //    }

            //}
        }
        public bool UserProject_user(Project_User pru)
        {
            ItemManageDAL up = new ItemManageDAL();

            return(up.UserProject_user(pru));
        }
        public async Task <IActionResult> RegisterBot([FromForm] RegisterBotAPIModel formData)
        {
            try
            {
                if (formData.Project_Id == "")
                {
                    return(Ok(new Dictionary <string, string> {
                        { "Code", "101" },
                        { "Message", "Не был указан project_id" }
                    }));
                }
                if (formData.Chat_Id == "")
                {
                    return(Ok(new Dictionary <string, string> {
                        { "Code", "102" },
                        { "Message", "Не был указан chat_id" }
                    }));
                }

                Models.User user = await _context.Users.FirstOrDefaultAsync(u => u.Chat_Id == formData.Chat_Id);

                Models.Project project = await _context.Projects.FirstOrDefaultAsync(p => p.Id.ToString() == formData.Project_Id);

                Project_User pu = null;

                if (user != null && project != null)
                {
                    pu = await _context.Project_Users.FirstOrDefaultAsync(pu => (pu.UserId == user.Id) && (pu.ProjectId == project.Id));
                }
                else
                {
                    if (project == null)
                    {
                        return(Ok(new Dictionary <string, string> {
                            { "Code", "103" },
                            { "Message", "project_id не существует" }
                        }));
                    }
                }

                if ((pu == null) || (user == null && project != null))
                {
                    // добавляем пользователя в бд
                    user = new Models.User
                    {
                        /*
                         * FirstName = "",
                         * LastName = formData.LastName,
                         * City = formData.City,
                         * Email = formData.Email,
                         * Phone = formData.Phone,
                         * Birthday = formData.Birthday,
                         * Name = formData.Email,
                         * Password = formData.Password,
                         */
                        Password = "",
                        Email    = Guid.NewGuid().ToString(),
                        Chat_Id  = formData.Chat_Id,
                        Login    = formData.Login,
                    };

                    user.Project_Users.Add(new Project_User {
                        Project = project, User = user
                    });

                    Role userRole = await _context.Roles.FirstOrDefaultAsync(r => r.Name == "User");

                    if (userRole != null)
                    {
                        user.Role = userRole;
                    }

                    _context.Users.Add(user);

                    await _context.SaveChangesAsync();

                    return(Ok(new Dictionary <string, string> {
                        { "Code", "200" },
                        { "Message", "Пользователь успешно зарегистрирован" }
                    }));
                }
                else
                {
                    return(Ok(new Dictionary <string, string> {
                        { "Code", "104" },
                        { "Message", "Пользователь уже был зарегистрирован в данном проекте" }
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Ok(ex));
            }
        }