예제 #1
0
        /// <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);
        }
예제 #2
0
 /// <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();
예제 #3
0
 /// <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();
예제 #4
0
 /// <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();