/// <summary> /// Retrieve the current week. /// </summary> /// <param name="userId">Id of the user.</param> /// <returns></returns> public static Weeks GetWeek(ObjectId userId) { Weeks week = MongoManager.GetAggregate <Weeks>(weeksIndex, x => x.UserId == userId).FirstOrDefault(); if (week == null) { week = new Weeks(); week.Days = new List <Day>(); return(week); } week.Days = week.Days.OrderBy(x => x.Position).ToList(); return(week); }
/// <summary> /// Get the list of all the ingredients of the week. /// </summary> /// <param name="userId"></param> public static WeekIngredients Get(ObjectId userId) => MongoManager.GetAggregate <WeekIngredients>(weekIngredientsIndex, x => x.UserId == userId).FirstOrDefault();
/// <summary> /// Retrieve all the recipes for given UserId. /// </summary> /// <param name="userId">Id of the user.</param> /// <returns>List of the recipes.</returns> public static List <Recipes> List(ObjectId userId) => MongoManager.GetAggregate <Recipes>(recipeIndex, x => x.UserId == userId).ToList().OrderBy(x => x.Name).ToList();
/// <summary> /// Get the recipe by its id. /// </summary> /// <param name="id"></param> /// <returns></returns> public static Recipes Get(ObjectId id) => MongoManager.GetAggregate <Recipes>(recipeIndex, x => x._id == id).FirstOrDefault();