public ViewResult CreateUser(string id) { //Recipe recipe = Recipes.FirstOrDefault(r => r.RecipeId.ToString() == id); recipeReviewCommentModel = new RecipeReviewCommentModel(); recipeReviewCommentModel.Recipe = Recipes.FirstOrDefault(r => r.RecipeId.ToString() == id); recipeReviewCommentModel.ReviewCommentDetail.ReviewDateTime = System.DateTime.Now; return(View("createUser", recipeReviewCommentModel)); }
public ViewResult AddRecipeRivewComment(RecipeReviewCommentModel recipeReviewCommentModel) { /** * Console.WriteLine("recipeReviewCommentModel.Recipe.RecipeId = " + recipeReviewCommentModel.Recipe.RecipeId); * Console.WriteLine("recipeReviewCommentModel.ReviewCommentDetail.Rate = " + recipeReviewCommentModel.ReviewCommentDetail.Rate); * Console.WriteLine("recipeReviewCommentModel.ReviewCommentDetail.RecipeReviewComments = " + recipeReviewCommentModel.ReviewCommentDetail.RecipeReviewComments); * Console.WriteLine("recipeReviewCommentModel.ReviewCommentDetail.ReviewComment = " + recipeReviewCommentModel.ReviewCommentDetail.ReviewComment); * Console.WriteLine("recipeReviewCommentModel.ReviewCommentDetail.ReviewCommentId = " + recipeReviewCommentModel.ReviewCommentDetail.ReviewCommentId); * Console.WriteLine("recipeReviewCommentModel.ReviewCommentDetail.ReviewDateTime = " + recipeReviewCommentModel.ReviewCommentDetail.ReviewDateTime); */ if (ModelState.IsValid) { iReviewCommentDetailRepository.AddReviewCommentDetail(recipeReviewCommentModel.ReviewCommentDetail); iRecipeReviewCommentRepository.AddRecipeReviewComment( recipeReviewCommentModel.Recipe.RecipeId, recipeReviewCommentModel.ReviewCommentDetail); // this userDetailModel is to display for the percific UserDetail by recipeId that the user has been created before userDetailModel = new UserDetailModel(); userDetailModel.AllRecipes = Recipes.ToList <Recipe>(); userDetailModel.AllIngredientDetails = IngredientDetails.ToList <IngredientDetail>(); userDetailModel.AllRecipeIngredients = RecipeIngredients.ToList <RecipeIngredient>(); userDetailModel.AllReviewCommentDetails = ReviewCommentDetails.ToList <ReviewCommentDetail>(); userDetailModel.AllRecipeReviewComments = RecipeReviewComments.ToList <RecipeReviewComment>(); userDetailModel.Recipe = Recipes.FirstOrDefault(r => r.RecipeId.ToString() == recipeReviewCommentModel.Recipe.RecipeId.ToString()); userDetailModel.cntRecipeReviewComments = RecipeReviewComments.ToList <RecipeReviewComment>().Where(rc => rc.RecipeId.ToString() == recipeReviewCommentModel.Recipe.RecipeId.ToString()).Count(); return(View("UserDetail", userDetailModel)); } else { // there is something wrong with the data values return(View("../Home/Index")); } }