Beispiel #1
0
        public void PostRecipe(int recipeId, EventType e)
        {
            var recipe      = this.db.Recipes.Include("Ingredients").Include("Events").Where(r => r.Id == recipeId).FirstOrDefault();
            var postMessage = $"{e.GetDescription()} Recipe: {recipe.Name}\n";

            postMessage += $"Instructions: {recipe.Instructions}\n";
            postMessage += $"Preperation Time: {recipe.PrepTime} minutes\n";
            postMessage += $"Ingredients: {String.Join(", ", recipe.Ingredients.Select(i => i.Ingredient.Name).ToList())}\n";
            postMessage += $"Published By: {recipe.User.FullName}\n\n";

            float usersCount       = this.db.Users.Count();
            float recipeLikesCount = this.db.RecipeUserEvents.Where(rue => rue.RecipeId == recipeId && rue.IsFavorite).Count();

            postMessage += (int)((recipeLikesCount / usersCount) * 100) + "% of the users liked this recipe\n";

            var recipeViews = recipe.Events.Select(rue => rue.Views).Sum();

            postMessage += recipeViews + " users viewed this recipe\n";

            string youtubeVideoURL = null;

            if (recipe.VideoID != null)
            {
                youtubeVideoURL = $"https://www.youtube.com/watch?v={recipe.VideoID}";
                postMessage    += youtubeVideoURL + "\n";
            }

            if (recipe.ImageURL != null)
            {
                postMessage += recipe.ImageURL;
            }

            this.PublishPostToFeed(postMessage, recipe.ImageURL, youtubeVideoURL);
        }
Beispiel #2
0
        private async Task AssertInHistoryAsExistingEventAsync(int tagIdUnderTest, UserType userType, EventType eventType)
        {
            var historyDtos = await TagsControllerTestsHelper.GetHistoryAsync(
                UserType.Preserver, TestFactory.PlantWithAccess,
                tagIdUnderTest);

            // history records are sorted with newest first in list
            var historyDto = historyDtos.First(h => h.Description.StartsWith(eventType.GetDescription()));

            AssertCreatedBy(userType, historyDto);
        }
Beispiel #3
0
        private KeyValuePair <int, string> GetEventTypeValue(EventType statusCode)
        {
            var options = _optionSetHelper.GetStringValues(ars_workorderevent.EntityLogicalName, NameOf.Property(() => ((ars_workorderevent)null).ars_EventType));

            return(options.Single(x => x.Value == statusCode.GetDescription()));
        }