partial void DeleteRecipe_Liker(Recipe_Liker instance);
 partial void UpdateRecipe_Liker(Recipe_Liker instance);
 partial void InsertRecipe_Liker(Recipe_Liker instance);
		private void detach_Recipe_Likers(Recipe_Liker entity)
		{
			this.SendPropertyChanging();
			entity.Recipe = null;
		}
		private void attach_Recipe_Likers(Recipe_Liker entity)
		{
			this.SendPropertyChanging();
			entity.Recipe = this;
		}
예제 #6
0
        /// <summary>
        /// Likes a user's recipe.
        /// </summary>
        /// <param name="postID">The recipe to like</param>
        /// <returns>Refreshes the page.</returns>
        public ActionResult LikeRecipe(int postID)
        {
            Recipe_Liker newLiker = new Recipe_Liker();
            newLiker.RecipeId = postID;
            newLiker.UserId = WebSecurity.CurrentUserId;
            if (!db.Recipe_Likers.Contains(newLiker))
            {
                db.Recipe_Likers.InsertOnSubmit(newLiker);
                var recipe = (from recipes in db.Recipes
                              where recipes.RecipeID == postID
                              select recipes).FirstOrDefault();
                recipe.LikeCount++;

                db.SubmitChanges();

                var likerUserName = (from userprofiles in userDb.UserProfiles
                                     where userprofiles.UserId == newLiker.UserId
                                     select userprofiles.UserName).FirstOrDefault();

                var userID = (from recipes in db.Recipes
                              where recipes.RecipeID == postID
                              select recipes.UserID).FirstOrDefault();

                SendSMS(userID, likerUserName + " has liked one of your recipes. Come visit Cookbook and check out which recipe " + likerUserName + " liked!");
                SendEmail(userID, likerUserName + " has liked one of your recipes.", likerUserName + " has liked one of your recipes. Come visit Cookbook and check out which recipe " + likerUserName + " liked!");
            }
            return Redirect(Request.UrlReferrer.AbsoluteUri);
        }