コード例 #1
0
        private ApiResult SaveUserPick(Dictionary <string, string> p)
        {
            ApiResult result = new ApiResult();

            try
            {
                int tournamentId = Convert.ToInt32(p["tournament"]);
                int userId       = Convert.ToInt32(p["user"]);
                int golferId     = Convert.ToInt32(p["golfer"]);

                if (tournamentId > 0 && userId > 0 && golferId > 0)
                {
                    UserPickService.Save(userId, tournamentId, golferId);
                    result.Success = true;
                }
                else
                {
                    result.Success = false;
                    result.Message = "One of the parameters was missing";
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }

            return(result);
        }
コード例 #2
0
        protected void OnSelectGolfer(object sender, EventArgs e)
        {
            var ddl = (DropDownList)sender;

            if (ddl != null)
            {
                int tournamentId = Convert.ToInt32(ddl.Attributes["TournamentId"].ToString());
                int userId       = Convert.ToInt32(user_list.SelectedValue);
                int golferId     = Convert.ToInt32(ddl.SelectedValue);

                UserPickService.Save(userId, tournamentId, golferId);
            }
        }
コード例 #3
0
        protected void OnSavePick(object sender, EventArgs e)
        {
            ////save values
            //SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["default"].ConnectionString);
            //connection.Open();

            //connection.Query("UserPick_Set", new {
            //	TournamentId = tournament_list.SelectedValue,
            //	UserId = user_list.SelectedValue,
            //	GolferId = golfer_list.SelectedValue
            //}, commandType: CommandType.StoredProcedure);

            //connection.Close();

            UserPickService.Save(user_list.SelectedValue, tournament_list.SelectedValue, golfer_list.SelectedValue);
            //should the change log be here, or in the UserPick.Save mehtod?

            message_label_panel.Visible = true;
            message_label.Text          = "Pick was saved";

            BindGrid();
        }
コード例 #4
0
        protected void OnDataBoundUserPicks(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DropDownList golfer_list = (DropDownList)e.Row.FindControl("golfer_list");
                golfer_list.DataSource = GolferService.ListActive();                    //hopefully the caching works
                golfer_list.DataBind();
                golfer_list.Items.Insert(0, "-- Choose a Golfer --");

                //get current pick (if any)
                int tournamentId = Convert.ToInt32(((HiddenField)e.Row.FindControl("userpick_hidden")).Value);
                int userId       = Convert.ToInt32(user_list.SelectedValue);

                var pick = UserPickService.Get(userId, tournamentId);                   //should get all on page load and search through collection (too many db calls)
                try
                {
                    if (pick != null)
                    {
                        golfer_list.SelectedValue = pick.GolferId.ToString();
                    }
                }
                catch { }
            }
        }