public List <Wishlist> Get(WishlistsSearchRequest request) { var query = _context.Set <Database.Wishlists>().AsQueryable(); if (request?.ProductId.HasValue == true) { query = query.Where(x => x.ProductId == request.ProductId); } if (request?.UserId.HasValue == true) { query = query.Where(x => x.UserId == request.UserId); } var list = query.ToList(); return(_mapper.Map <List <Model.Wishlists> >(list)); }
public async Task EditInWishlist(bool item) { if (!item) { WishlistsSearchRequest requestWish = new WishlistsSearchRequest { ProductId = Product.Id, UserId = User.Id }; try { IEnumerable <Wishlists> wishlist = await _wishlistsService.Get <IEnumerable <Wishlists> >(requestWish); foreach (var tmp in wishlist) { await _wishlistsService.Delete <Wishlists>(tmp.Id); } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK"); } } else { WishlistsUpsertRequest requestWish = new WishlistsUpsertRequest { ProductId = Product.Id, UserId = User.Id }; try { await _wishlistsService.Insert <Wishlists>(requestWish); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK"); } } }
public async Task Init() { await Recommend(); int maximum = await Helper.numInStorage(Product.Id); if (Quantity == 0) { _isAvailable = false; } WishlistsSearchRequest requestWish = new WishlistsSearchRequest { ProductId = Product.Id, UserId = User.Id }; try { ICollection <Wishlists> wishlist = await _wishlistsService.Get <ICollection <Wishlists> >(requestWish); if (wishlist.Count == 0) { IsToggled = false; } else { isFirstTime = true; IsToggled = true; } } catch (Exception ex) { IsToggled = false; } ReviewsSearchRequest requestAll = new ReviewsSearchRequest { ProductId = Product.Id }; var listAll = await _reviewsService.Get <IEnumerable <Reviews> >(requestAll); ReviewsList.Clear(); foreach (var item in listAll) { if (item.Description.Equals("")) { item.Description = NO_CONTENT; } ReviewsList.Add(item); } ReviewsSearchRequest requestUser = new ReviewsSearchRequest { ProductId = Product.Id, UserId = User.Id }; var listUser = await _reviewsService.Get <ICollection <Reviews> >(requestUser); ReviewsListUser.Clear(); foreach (var item in listUser) { if (item.Description.Equals("")) { item.Description = NO_CONTENT; } ReviewsListUser.Add(item); } }
public List <Model.Wishlists> Get([FromQuery] WishlistsSearchRequest request) { return(_service.Get(request)); }