示例#1
0
 protected void referUser_Click(object sender, EventArgs e)
 {
     message.Visible = true;
     if (FudgeUser != null)
     {
         var user = db.Users.SingleOrDefault(u => u.Email == email.Text.Trim());
         if (user != null)
         {
             message.InnerHtml = String.Format("{0} is already a member on fudge.", Html.LinkToProfile(user.UserId));
         }
         else
         {
             //send the invitation email
             if (FudgeUser.Invite(email.Text))
             {
                 message.Attributes["class"] = "fudge_message";
                 message.InnerText           = "Invitation sent successfully";
             }
             else
             {
                 message.InnerText = "There was an error sending invite, make sure the email is valid";
             }
         }
     }
     else
     {
         message.InnerText = "You must be logged in to invite a user";
     }
     email.Text = String.Empty;
 }
示例#2
0
    protected void joinTeam_Click(object sender, EventArgs e)
    {
        FudgeUser.AcceptTeamInvite(Team.TeamId);
        teamView.DataBind();

        ShowMessage("Successfully joined " + Team.Name);
    }
示例#3
0
    protected void leaveTeam_Click(object sender, EventArgs e)
    {
        FudgeUser.LeaveTeam(Team.TeamId);
        teamView.DataBind();

        ShowMessage("Left " + Team.Name);
    }
示例#4
0
    protected void requestTeam_Click(object sender, EventArgs e)
    {
        FudgeUser.RequestJoinTeam(Team.TeamId);
        teamView.DataBind();

        ShowMessage("Waiting on " + Team.Name + "'s admin to approve request");
    }
示例#5
0
 protected void userProfile_ItemCommand(object sender, FormViewCommandEventArgs e)
 {
     if (e.CommandName == "AddFriend")
     {
         int userId = Convert.ToInt32(e.CommandArgument);
         FudgeUser.AddFriend(userId);
         BindProfile();
     }
     else if (e.CommandName == "RemoveFriend")
     {
         int userId = Convert.ToInt32(e.CommandArgument);
         FudgeUser.RemoveFriend(userId);
         BindProfile();
     }
     if (e.CommandName == "Approve")
     {
         int userId = Convert.ToInt32(e.CommandArgument);
         FudgeUser.ApproveFriend(userId);
         BindProfile();
     }
     else if (e.CommandName == "Reject")
     {
         int userId = Convert.ToInt32(e.CommandArgument);
         FudgeUser.RejectFriend(userId);
         BindProfile();
     }
 }
示例#6
0
    public Teams_Settings()
        : base(MenuItem.Teams)
    {
        VerifyQueryStringInt("id", id => db.Teams.Any(t => t.TeamId == id), "Team does not exist!");

        //user cannot access this page without being an admin
        VerifyQueryStringInt("id", id => FudgeUser.IsAdmin(id), "You do not have permission to edit the settings for this team.");
    }
示例#7
0
    public Teams_View()
        : base(MenuItem.Teams)
    {
        VerifyQueryStringInt("id", id => db.Teams.Any(t => t.TeamId == id), "Team does not exist!");

        //users cannot view teams they were banned from
        VerifyQueryStringInt("id", id => !FudgeUser.IsBanned(id), "You have been banned from this team.");
    }
示例#8
0
    public Contests_Environment()
        : base(MenuItem.Contests)
    {
        VerifyQueryString("name", name => db.Contests.Any(c => c.UrlName == name), "Contest not found");

        VerifyQueryString("name", name => db.Contests.Any(c => c.UrlName == name &&
                                                          SqlMethods.DateDiffSecond(c.StartTime, DateTime.UtcNow) > 0), "Contest has not started.");

        VerifyQueryString("name", name => FudgeUser.IsRegisteredFor(Contest.ContestId), "You are not registered for this contest.");
    }
示例#9
0
 protected void postsSource_Inserted(object sender, LinqDataSourceStatusEventArgs e)
 {
     //insert topic subscription if user preference is set
     if (FudgeUser.IsOptionSet(Fudge.Framework.Database.User.UserOptions.AutomaticallySubscribeToMyTopics))
     {
         FudgeUser.SubscribeForReplies((e.Result as Post).TopicId);
     }
     //redirect
     Response.Redirect("/Community/Forum/Topic/" + Request.QueryString["id"]);
 }
示例#10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Title += ".Contests." + Contest.Name + ".Details";
     if (Contest.IsRunning)
     {
         contestTip.Text       = "Contest is running.";
         contestTip.IsClosable = false;
         if (FudgeUser != null && FudgeUser.IsRegisteredFor(Contest.ContestId) && !Contest.HasEnded)
         {
             contestTip.Text += String.Format(" Click {0} to enter", Html.Link("/Contests/Environment/" + Contest.UrlName, "here"));
         }
         contestTip.Show();
     }
     else if (Contest.HasEnded)
     {
         contestTip.Text       = "Contest has ended.";
         contestTip.IsClosable = false;
         contestTip.Show();
     }
 }
示例#11
0
    protected void contestSchedule_DayRender(object sender, DayRenderEventArgs e)
    {
        var contests = from c in db.Contests.AsEnumerable()
                       let date = FudgeUser == null ? c.StartTime.Date :
                                  FudgeUser.ToUserTimezone(c.StartTime).Date
                                  where date == e.Day.Date
                                  select c;

        e.Cell.Text = String.Empty;
        HtmlGenericControl div = new HtmlGenericControl("div");

        div.Attributes["class"] = "daytext";
        div.InnerHtml           = Html.Link(e.SelectUrl, e.Day.DayNumberText);
        e.Cell.Controls.Add(div);

        if (contests.Any())
        {
            e.Cell.CssClass = "event";
        }
    }
示例#12
0
    void Posts_ItemInserted(object sender, ListViewInsertedEventArgs e)
    {
        if (!Topic.User.IsLoggedOn)
        {
            //only subscribe once
            if (FudgeUser.IsOptionSet(FudgeDatabase.User.UserOptions.AutomaticallySubscribeToTopicsIReplyTo) &&
                !FudgeUser.IsSubscribedTo(Topic.TopicId))
            {
                //subscribe
                FudgeUser.SubscribeForReplies(Topic.TopicId);
            }

            var subscriptions = from s in db.TopicSubscriptions
                                where s.TopicId == Topic.TopicId && s.UserId != FudgeUser.UserId && s.UserId != Topic.UserId
                                select s;

            foreach (var s in subscriptions)
            {
                Email.NotifyNotMyTopicReply.Send(s.User, FudgeUser.FirstName + " replied to " + Topic.Title,
                                                 FudgeUser.FirstName, Topic.Title, Topic.TopicId);
            }
        }

        if (!Topic.User.IsLoggedOn && Topic.User.IsSubscribedTo(Topic.TopicId))
        {
            //send notification to the topic owner
            Notification.Notify(Notification.TopicReply(Topic.TopicId));

            //send and email
            Email.NotifyTopicReply.Send(Topic.User, FudgeUser.FirstName + " replied to your post!",
                                        FudgeUser.FirstName, Topic.Title, Topic.TopicId);
        }
        //go to the last page
        int lastPage = (postsPager.TotalRowCount / postsPager.PageSize) + 1;

        postsPager.CurrentPage = lastPage;
    }
示例#13
0
    protected void Invite_Click(object sender, EventArgs e)
    {
        var badEmails = new List <string>();

        foreach (var address in emails.Text.Split(','))
        {
            //send the invitation email
            if (!FudgeUser.Invite(address))
            {
                badEmails.Add(address);
            }
        }
        message.Visible = true;
        if (badEmails.Count > 0)
        {
            message.InnerText = "There was an error sending invite, to the following emails " + badEmails.Join(",");
        }
        else
        {
            message.Attributes["class"] = "fudge_message";
            message.InnerText           = "Invitation sent successfully";
        }
        emails.Text = String.Empty;
    }
示例#14
0
 protected void rejectTeam_Click(object sender, EventArgs e)
 {
     FudgeUser.RejectTeamInvite(Team.TeamId);
     teamView.DataBind();
 }