コード例 #1
0
        /// <summary>
        /// Create a new wish list
        /// </summary>
        /// <param name="userId">User Id</param>
        /// <param name="wishList">List of whishes</param>
        /// <returns>Wish list created</returns>
        public Wish[] Create(long userId, Wish[] wishList)
        {
            // First we add all the items in the list
            foreach (Wish wish in wishList)
            {
                // If these items don't exist we add then
                if (!Exists(userId, wish.IdProduct))
                {
                    wish.SetUserId(userId);
                    _wishRepository.Create(wish);
                }
            }

            // So we save the whole list at once
            _wishRepository.Save();

            return(wishList);
        }