Example #1
0
        public bool CreateGroup(string name, int profileId)
        {
            Profile profile = profileController.ReadProfile(profileId.ToString(), 1);

            if (profile != null && !name.Equals(""))
            {
                using (IDbTransaction tran = DbConnection.GetInstance().BeginTransaction())
                {
                    try
                    {
                        int activityId = dbActivity.CreateActivity(profileId);
                        int groupId    = dbGroup.CreateGroup(activityId, name);
                        if (AddMember(profile.Nickname, groupId))
                        {
                            tran.Commit();
                            return(true);
                        }
                        else
                        {
                            tran.Rollback();
                            return(false);
                        }
                    }
                    catch (Exception)
                    {
                        tran.Rollback();
                        return(false);
                    }
                }
            }
            else
            {
                return(false);//profile doesnt exist
            }
        }
Example #2
0
        public bool CreateGroup(string name, int profileId)
        {
            SqlConnection con = new DbConnection().GetConnection();

            try
            {
                Profile profile = profileController.ReadProfile(profileId.ToString(), 1, null, con);
                if (profile != null && !name.Equals(""))
                {
                    using (IDbTransaction tran = con.BeginTransaction())
                    {
                        try
                        {
                            int activityId = dbActivity.CreateActivity(profileId, (SqlTransaction)tran, con);
                            int groupId    = dbGroup.CreateGroup(activityId, name, (SqlTransaction)tran, con);
                            if (AddMember(profile.Nickname, groupId, (SqlTransaction)tran, con))
                            {
                                tran.Commit();
                                return(true);
                            }
                            else
                            {
                                tran.Rollback();
                                return(false);
                            }
                        }
                        catch (Exception)
                        {
                            tran.Rollback();
                            return(false);
                        }
                    }
                }
                else
                {
                    return(false);//profile doesnt exist
                }
            }
            finally
            {
                con.Close();
            }
        }