Beispiel #1
0
        /// <summary>
        /// Delete wishList
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> OnPostDelete()
        {
            WishListModel = await _wishListViewModelService.GetOrCreateWishListForUser(User.Identity.Name);

            await _wishListService.DeleteWishListAsync(WishListModel.Id);

            WishListModel = await _wishListViewModelService.GetOrCreateWishListForUser(User.Identity.Name);

            return(RedirectToPage());
        }
Beispiel #2
0
 private async Task SetWishListModelAsync()
 {
     if (_signInManager.IsSignedIn(HttpContext.User))
     {
         WishListModel = await _wishlistViewModelService.GetOrCreateWishListForUser(User.Identity.Name);
     }
     else
     {
         GetOrSetWishListCookieAndUserName();
         WishListModel = await _wishlistViewModelService.GetOrCreateWishListForUser(_username);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Update wishList name
        /// </summary>
        /// <param name="wishName"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostUpdateName(string wishName)
        {
            WishListModel = await _wishListViewModelService.GetOrCreateWishListForUser(User.Identity.Name);

            var cleanWishName = string.IsNullOrEmpty(wishName)?"":wishName.Trim();

            if (WishListModel.WishName != cleanWishName)
            {
                await _wishListService.SetWishName(WishListModel.Id, cleanWishName);

                WishListModel = await _wishListViewModelService.GetOrCreateWishListForUser(User.Identity.Name);
            }
            return(RedirectToPage());
        }
Beispiel #4
0
        /// <summary>
        /// Update WishList
        /// </summary>
        /// <param name="catalogItemId"></param>
        /// <param name="notifyCasePriceChanges"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostUpdate(int catalogItemId, bool notifyCasePriceChanges)
        {
            WishListModel = await _wishListViewModelService.GetOrCreateWishListForUser(User.Identity.Name);

            var WishItem = WishListModel.Items.Where(x => x.CatalogItemId == catalogItemId).FirstOrDefault();

            if (WishItem != null && WishItem.NotifyCasePriceChanges != notifyCasePriceChanges)
            {
                await _wishListService.SetNotifies(WishListModel.Id, catalogItemId, notifyCasePriceChanges);

                WishListModel = await _wishListViewModelService.GetOrCreateWishListForUser(User.Identity.Name);
            }
            return(RedirectToPage());
        }
Beispiel #5
0
        /// <summary>
        /// Insert CatalogItem to WishList
        /// Get or creat wish list for user
        /// </summary>
        /// <param name="productDetails"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPost(CatalogItemViewModel productDetails)
        {
            if (productDetails?.Id == null)
            {
                return(RedirectToPage("/Index"));
            }
            if (_signInManager.IsSignedIn(HttpContext.User))
            {
                WishListModel = await _wishListViewModelService.GetOrCreateWishListForUser(User.Identity.Name);

                await _wishListService.AddItemToWishList(WishListModel.Id, productDetails.Id, productDetails.Price, productDetails.PriceSymbol);

                WishListModel = await _wishListViewModelService.GetOrCreateWishListForUser(User.Identity.Name);

                return(RedirectToPage());
            }
            else
            {
                throw new Exception("You don't have valid authentication!");
            }
        }
Beispiel #6
0
 public async Task OnGet()
 {
     WishListModel = await _wishListViewModelService.GetOrCreateWishListForUser(User.Identity.Name);
 }