示例#1
0
    protected void RatingSubmit_Click(object sender, EventArgs e)
    {
        DataAccess da = new DataAccess();

        int v = ReadVote();

        if (v > -1 && v < 6)
        {
            da.RateRecipe(RecipeId, v);
        }

        RecipeRatingModel model = da.GetRecipeRatingModel(RecipeId);

        if (model == null)
        {
            model = new RecipeRatingModel()
            {
                HasVotes = false, TotalVotes = 0, Rating = 0
            }
        }
        ;

        WritePage(model.Rating, model.TotalVotes, model.HasVotes, model.HasUserVoted);
    }
}
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DataAccess da = new DataAccess();

        //if (IsPostBack)
        //{
        //    int v = ReadVote();

        //    if(v > -1 && v < 6)
        //        da.RateRecipe(RecipeId, v);
        //}

        RecipeRatingModel model = da.GetRecipeRatingModel(RecipeId);

        if (model == null)
        {
            model = new RecipeRatingModel()
            {
                HasVotes = false, TotalVotes = 0, Rating = 0
            }
        }
        ;

        WritePage(model.Rating, model.TotalVotes, model.HasVotes, model.HasUserVoted);
    }