コード例 #1
0
ファイル: Profile.aspx.cs プロジェクト: tomdevries/NBFQubica
        protected void btnRemoveAccount_Click(object sender, EventArgs e)
        {
            bool auth = Convert.ToBoolean(Session["auth"]);

            if (!auth)
            {
                Response.Redirect("~/Login.aspx");
            }
            else
            {
                // find the user
                long   id   = Convert.ToInt64(Session["uid"]);
                S_User user = UserManager.GetUserById(id);

                // remove favorits
                FavoritManager.DeleteFavoritsByUserId(user.id);

                // remove competitionplayers
                CompetitionManager.DeleteCompetitionPlayer(user.id);

                // remove user
                UserManager.Delete(user.id);

                Response.Redirect("~/Logout.aspx");
            }
        }
コード例 #2
0
        public Favorit[] GetFavorites(string id)
        {
            logger.Debug(Settings.MethodName());

            List <Favorit> favoritsList = new List <Favorit>();
            long           userid;

            if (isCorrectUser(id))
            {
                try
                {
                    long.TryParse(id, out userid);

                    List <S_Favorit> favorits = FavoritManager.GetFavoritsByUserId(userid);

                    foreach (S_Favorit favorit in favorits)
                    {
                        S_User  user      = UserManager.GetUserById(favorit.favorituserId);
                        Favorit myFavorit = new Favorit();
                        myFavorit.userid = user.id;
                        myFavorit.name   = user.name;
                        myFavorit.scores = GameManager.GetScoresByUser(user);

                        favoritsList.Add(myFavorit);
                    }
                }
                catch
                {
                }
            }

            return(favoritsList.ToArray());
        }
コード例 #3
0
        public FavoritStatus AddFavorite(FavoritRequest favoritRequest)
        {
            logger.Debug(Settings.MethodName());

            FavoritStatus favoritStatus = new FavoritStatus();

            if (isCorrectUser(favoritRequest.userid.ToString()))
            {
                try
                {
                    S_Favorit favorit = new S_Favorit();
                    favorit.userId        = favoritRequest.userid;
                    favorit.favorituserId = favoritRequest.favorituserid;

                    long?i_id = FavoritManager.Insert(favorit);

                    if (i_id != null)
                    {
                        favoritStatus.status       = "Added";
                        favoritStatus.user_message = "Gebruiker toegevoegd aan favorieten";
                    }
                    else
                    {
                        favoritStatus.status = "NotAdded";
                    }
                }
                catch
                {
                    favoritStatus.status = "NotAdded";
                }
            }

            return(favoritStatus);
        }
コード例 #4
0
        public Profile GetProfile(string id, string otheruserid)
        {
            long thisUserId;
            long userid;

            logger.Debug(Settings.MethodName());
            logger.Trace("Parameters: id: " + id + "otheruserid: " + otheruserid);

            if (isCorrectUser(id))
            {
                long.TryParse(id, out thisUserId);

                // voor het opvragen van een profiel van een andere gebruiker, gebruiken we het andere id
                if (!String.IsNullOrEmpty(otheruserid))
                {
                    id = otheruserid;
                }

                long.TryParse(id, out userid);

                S_User user = UserManager.GetUserById(userid);

                if (user != null)
                {
                    Profile profile = new Profile();

                    profile.user          = new User();
                    profile.user.userid   = user.id;
                    profile.user.city     = user.city;
                    profile.user.name     = user.name;
                    profile.user.username = user.username;

                    profile.user.scores = GameManager.GetProfileScores(user.username, user.frequentbowlernumber);
                    if (String.IsNullOrEmpty(otheruserid))
                    {
                        profile.user.is_favorite = false;
                    }
                    else
                    {
                        profile.user.is_favorite = FavoritManager.IsUserFavoritOfUser(thisUserId, userid);
                    }

                    logger.Trace("Return: userid: " + profile.user.userid);
                    logger.Trace("Return: city: " + profile.user.city);
                    logger.Trace("Return: email: " + profile.user.name);
                    logger.Trace("Return: username: "******"Return: is_favorite: " + profile.user.is_favorite);
                    return(profile);
                }
            }

            return(null);
        }
コード例 #5
0
        public FavoritStatus DeleteFavorite(string id, string favoritsid)
        {
            logger.Debug(Settings.MethodName());

            FavoritStatus favoritStatus = new FavoritStatus();

            if (isCorrectUser(id))
            {
                long userid;
                long.TryParse(id, out userid);

                long favorituserid;
                long.TryParse(favoritsid, out favorituserid);
                try
                {
                    long?d_id = FavoritManager.GetFavoritIdByUserIdFavoritId(userid, favorituserid);

                    if (d_id != null)
                    {
                        FavoritManager.Delete((long)d_id);
                        favoritStatus.status       = "Deleted";
                        favoritStatus.user_message = "Gebruiker verwijderd uit favorieten";
                    }
                    else
                    {
                        favoritStatus.status = "NotDeleted";
                    }
                }
                catch
                {
                    favoritStatus.status = "NotDeleted";
                }
            }

            return(favoritStatus);
        }