/// <summary> /// Cria um novo Wish /// </summary> /// <param name="UserId">Id do Usuario</param> /// <param name="ProductId">Id do Produto</param> /// <returns>True se a operacao deu certo, False ao contrario</returns> public async Task <bool> CreateWishAsync(int UserId, int ProductId) { Task <bool> tCreateWish = new Task <bool>(() => { return(_wishListRepository.Create(UserId, ProductId)); }); tCreateWish.Start(); return(await tCreateWish); }
/// <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); }