Beispiel #1
0
        public async Task <int> CreateTeam(string teamName, string teamSummary, string avatarToken,
                                           string currentUserMail)
        {
            var currentUserRepoModel = this._userRepository.GetUser(currentUserMail);

            if (currentUserRepoModel == null)
            {
                Enforce.Throw(new LogicErrorException("当前用户已被删除"));
            }

            string teamAvatar = string.Empty;

            if (!string.IsNullOrEmpty(avatarToken))
            {
                teamAvatar = await _attachmentUploadRepository.GetAttachmentFileID(avatarToken, currentUserRepoModel.info.mail);
            }

            T_TEAM Team = new T_TEAM();

            Team.T_TEAM_CODE      = "";
            Team.T_TEAM_NAME      = teamName;
            Team.T_TEAM_SUMMARY   = teamSummary;
            Team.T_TEAM_AVATAR    = teamAvatar;
            Team.T_STATUS         = TeamStatus.Enable;
            Team.CREATE_USER_MAIL = currentUserRepoModel.info.mail;
            Team.CREATE_TIME      = DateTime.Now;
            return(this._teamBll.CreateTeam(Team, currentUserRepoModel.info.userID, currentUserRepoModel.info.mail, currentUserRepoModel.info.userName));
        }
Beispiel #2
0
        public int CreateTeam(T_TEAM team, int userID, string userMail, string userName)
        {
            int id = 0;

            using (var tran = DbContext.DbTransaction)
            {
                try
                {
                    DbContext.Insert(team);
                    var teamMember = new T_TEAM_MEMBER();
                    teamMember.T_TEAM_ID        = team.ID;
                    teamMember.U_USER_ID        = userID;
                    teamMember.U_USER_NAME      = userName;
                    teamMember.U_USER_EMAIL     = userMail;
                    teamMember.R_USER_ROLE_CODE = RoleCode.Owner;
                    teamMember.CREATE_USER_MAIL = userMail;
                    teamMember.CREATE_TIME      = DateTime.Now;
                    teamMember.T_STATE          = 1;
                    DbContext.Insert(teamMember);
                    id = team.ID;
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    if (id > 0)
                    {
                        tran.Commit();
                    }
                    else
                    {
                        tran.Rollback();
                    }
                }
                return(id);
            }
        }