Exemple #1
0
        public IActionResult TermsAndConditions(string searchString)
        {
            var user      = WishListService.GetUser(this.HttpContext);
            var userId    = user.UserId;
            var listModel = new WishListViewModel
            {
                ListItems = _wishListService.GetWishListItems(userId),
            };

            var books = _bookService.GetAllBooks();

            if (!String.IsNullOrEmpty(searchString))
            {
                var booklist = _bookService.GetSearchBooks(searchString);
                if (booklist.Count == 0)
                {
                    return(View("NoResults"));
                }

                _myModel.Book    = booklist;
                _myModel.Account = listModel;

                return(View("Index", _myModel));
            }

            return(View());
        }
Exemple #2
0
 public BookController()
 {
     _bookService     = new BookService();
     _wishModel       = new WishListViewModel();
     _wishListService = new WishListService();
     _myModel         = new ExpandoObject();
 }
Exemple #3
0
        public IActionResult Index(string searchString)
        {
            var user      = WishListService.GetUser(this.HttpContext);
            var userId    = user.UserId;
            var listModel = new WishListViewModel
            {
                ListItems = _wishListService.GetWishListItems(userId),
            };

            if (String.IsNullOrEmpty(searchString))
            {
                var newestBooks = _bookService.GetBooksBoughtOrder();

                _myModel.Book    = newestBooks;
                _myModel.Account = listModel;

                return(View(_myModel));
            }

            var booklist = _bookService.GetSearchBooks(searchString);

            if (booklist.Count == 0)
            {
                return(View("NoResults"));
            }

            _myModel.Book    = booklist;
            _myModel.Account = listModel;

            return(View(_myModel));
        }
Exemple #4
0
        public ActionResult Update(WishListViewModel model)
        {
            var domainWishList = Mapper.Map <DomainWishList>(model);

            _wishListService.Update(domainWishList);
            return(RedirectToAction("GetAllWishListsOfUser"));//ManageProfile
        }
        public WishListViewModel Build()
        {
            try
            {
                var itemsViewModelList = new List <WishListItemViewModel>();

                var itemdIDs = wishListPersistence.GetItemsOnWishList();

                foreach (var id in itemdIDs)
                {
                    var jewel = jewelRepository.GetJewelByID(id);
                    if (jewel == null)
                    {
                        continue;
                    }
                    var itemViewModel = mapper.Map <Jewel, WishListItemViewModel>(jewel);
                    itemsViewModelList.Add(itemViewModel);
                }

                var viewModel = new WishListViewModel {
                    Items = itemsViewModelList
                };

                return(viewModel);
            }
            catch (Exception ex)
            {
                throw new Exception("When asked to build the model for the wishlist page an error occured\r\n" + ex.Message);
            }
        }
        public ActionResult DetailsLivre(int id)
        {
            //Livre livre = contextLivre.FindById(id);
            WishListViewModel viewModelWL = new WishListViewModel();

            viewModelWL.book  = contextLivre.FindById(id);
            Session["idBook"] = viewModelWL.book.Id;
            Session["author"] = viewModelWL.book.Author;
            Session["title"]  = viewModelWL.book.Title;
            Session["image"]  = viewModelWL.book.Image;
            var estPresent = true;

            Session["estPresent"] = estPresent;


            int CurrentIdClient = (int)Session["Id"];

            viewModelWL.wishList = ((SQLRepositoryWishList)contextWishList).listWLbyIdClient(CurrentIdClient);

            if (viewModelWL == null)
            {
                return(HttpNotFound());
            }

            // Verif pour savoir si le livre existe deja dans

            Livre livre = ((SQLRepositoryLivre)contextLivre).finByIdWClient(id);

            if (livre.Client.Id == CurrentIdClient)
            {
                // Dans ce cas le livre m'appartient je ne peux pas faire d'échange dessus.
                ViewBag.enCours = 2;
            }
            else
            {
                EchangeLivre ech = echangeService.enCoursEchange(id, CurrentIdClient);
                int          res = 0;

                if (ech == null)
                {
                    res = 0;
                }
                else if (ech.ClientProp.Id == CurrentIdClient)
                {
                    res = 1;
                }
                else
                {
                    res = 2;
                }

                ViewBag.enCours = res;
            }


            return(View(viewModelWL));
        }
Exemple #7
0
        private async Task <WishListViewModel> CreateViewModelFromWishList(WishList wishlist)
        {
            var viewModel = new WishListViewModel();

            viewModel.Id      = wishlist.Id;
            viewModel.BuyerId = wishlist.BuyerId;
            viewModel.Items   = await GetWishListItems(wishlist.Items);;
            return(viewModel);
        }
Exemple #8
0
        public async Task <HttpResponseMessage> GetWishes(string userId)
        {
            var model = new WishListViewModel
            {
                Wishes = wishServ.GetWishes(userId)
            };

            return(Request.CreateResponse(HttpStatusCode.OK, model));
        }
Exemple #9
0
        public async Task <WishListViewModel> CreateViewModelFromWishList(WishList wishList)
        {
            var viewModel = new WishListViewModel();

            viewModel.Id       = wishList.Id;
            viewModel.WisherId = wishList.WisherId;
            viewModel.WishName = wishList.WishName;
            viewModel.Items    = await GetWishListItems(wishList.Items);;
            return(viewModel);
        }
Exemple #10
0
        public IActionResult Index()
        {
            var claimsIdentity         = (ClaimsIdentity)User.Identity;
            var claim                  = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);
            WishListViewModel wishList = new WishListViewModel()
            {
                WishLista = _db.WishList.Include(m => m.MenuItem).Where(m => m.ApplicationUserId == claim.Value).ToList()
            };

            return(View(wishList));
        }
Exemple #11
0
        public ActionResult Index(WishListPage currentPage)
        {
            WishListViewModel viewModel = new WishListViewModel
            {
                ItemCount   = _cartService.GetLineItemsTotalQuantity(),
                CurrentPage = currentPage,
                CartItems   = _cartService.GetCartItems(),
                Total       = _cartService.GetSubTotal()
            };

            return(View(viewModel));
        }
Exemple #12
0
        public ActionResult viewWishList()
        {
            WishListViewModel model = new WishListViewModel
            {
                images   = _imageService.GetAll(),
                products = _productService.Get().Where(m => !m.isDelete),
                status   = _statusService.GetAll(),
                wishList = _wishListService.GetAll().Where(m => m.UserID == User.Identity.GetUserId()).ToList()
            };

            return(View(model));
        }
Exemple #13
0
        public ActionResult AddToWishList([FromBody] WishListViewModel model)
        {
            var store = UnitOfWork.StoreMarketService.Get(model.StoreId);

            model.FilePath = store.StoreImg;
            var user = UserManager.Users.FirstOrDefault(x => x.Id == model.UserId);

            model.StoreName = store.Name;
            model.UserName  = user.UserName;
            UnitOfWork.WishListService.Add(model);
            UnitOfWork.Commit();
            return(Ok(true));
        }
        public void CreateWishListViewModel_WhenCartIsNull_ShouldCreateViewModel()
        {
            var viewModel = _subject.CreateWishListViewModel(null);

            var expectedViewModel = new WishListViewModel
            {
                ItemCount = 0,
                CartItems = new CartItemViewModel[0],
                Total     = new Money(0, Currency.USD)
            };

            viewModel.ShouldBeEquivalentTo(expectedViewModel);
        }
        public ViewResult Index()
        {
            var items = _wishList.GetCartItems();

            _wishList.WishListItems = items;

            var wishListViewModel = new WishListViewModel
            {
                WishList = _wishList
            };

            return(View(wishListViewModel));
        }
        public void CreateWishListViewModel_ShouldCreateViewModel()
        {
            var viewModel = _subject.CreateWishListViewModel(_cart);

            var expectedViewModel = new WishListViewModel
            {
                ItemCount = 1,
                CartItems = _cartItems,
                Total     = _totals.SubTotal
            };

            viewModel.ShouldBeEquivalentTo(expectedViewModel);
        }
Exemple #17
0
        public async void OnDelete(object sender, EventArgs e)
        {
            WishListHelper wishHelper = new WishListHelper();
            var            mi         = ((MenuItem)sender);
            int            x          = (int)((MUpcomingDetails)mi.CommandParameter).Id;
            bool           answer     = await DisplayAlert("Question?", "Are you sure you want to remove this item", "Yes", "No");

            if (answer)
            {
                await wishHelper.DeleteWishList(AuthenticationViewModel.LoggedinUser, x);
                await DisplayAlert("Message", "The item has been deleted", "OK");

                BindingContext = new WishListViewModel();
            }
        }
Exemple #18
0
        public ActionResult WishListInHeader()
        {
            var vm = new WishListViewModel
            {
                Url = WishListUrlProvider.GetWishListUrl(new GetWishListUrlParam
                {
                    CultureInfo = ComposerContext.CultureInfo,
                    BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
                })
            };

            vm.Context.Add("IsAuthenticated", ComposerContext.IsAuthenticated);

            return(View("WishListInHeader", vm));
        }
Exemple #19
0
        //
        // GET: /WishList/
        public async Task <IActionResult> Index()
        {
            WishListFuncties cart;

            cart = UserLogin();

            // Set up our ViewModel
            var viewModel = new WishListViewModel
            {
                WishListItems = await cart.GetWishListItems()
            };

            // Return the view
            return(View(viewModel));
        }
        // GET: Users/Details/5
        public async Task <IActionResult> MyPage()
        {
            var user = await userManager.GetUserAsync(User);

            var vm = new WishListViewModel();

            vm.Username = user.UserName;
            vm.Country  = user.Country;
            var dtosWish = await this.userService.RetreiveWishListAsync(user.Id);

            vm.WishLists = dtosWish.GetViewModels();
            var dtosDrank = await this.userService.RetreiveDrankListAsync(user.Id);

            vm.DrankLists = dtosDrank.GetViewModels();

            return(View(vm));
        }
Exemple #21
0
        public async Task <ActionResult> WishList()
        {
            var currentUser = await _userManager.GetUserAsync(User);

            if (currentUser == null)
            {
                return(Challenge());
            }
            var wishlist = await _context.WishLists.Include(p => p.Product).ThenInclude(c => c.Category)
                           .Where(w => w.UserID.Equals(currentUser.Id)).ToListAsync();

            var wvm = new WishListViewModel();

            wvm.WishList = wishlist;



            return(View(wvm));
        }
Exemple #22
0
        protected virtual async Task <WishListViewModel> CreateWishListViewModelAsync(CreateWishListViewModelParam param)
        {
            var viewModel = new WishListViewModel();
            var lineItems = param.WishList.GetLineItems();

            if (lineItems != null)
            {
                var imageInfo = new ProductImageInfo
                {
                    ImageUrls = await ImageService.GetImageUrlsAsync(lineItems).ConfigureAwait(false),
                };

                viewModel.Items = LineItemViewModelFactory.CreateViewModel(new CreateListOfLineItemDetailViewModelParam {
                    Cart        = param.WishList,
                    LineItems   = lineItems,
                    CultureInfo = param.CultureInfo,
                    ImageInfo   = imageInfo,
                    BaseUrl     = param.BaseUrl
                }).ToList();

                viewModel.Items.Reverse();
                viewModel.TotalQuantity = lineItems.Count;
            }

            var getUrlParam = new GetWishListUrlParam
            {
                BaseUrl     = param.BaseUrl,
                CultureInfo = param.CultureInfo
            };

            viewModel.SignInUrl = WishListUrlProvider.GetSignInUrl(getUrlParam);
            viewModel.ShareUrl  = viewModel.TotalQuantity == 0 ? string.Empty: WishListUrlProvider.GetShareUrl(new GetShareWishListUrlParam
            {
                BaseUrl     = param.BaseUrl,
                CultureInfo = param.CultureInfo,
                CustomerId  = param.WishList.CustomerId,
                Scope       = param.WishList.ScopeId,
                WebsiteId   = param.WebsiteId
            });

            return(viewModel);
        }
Exemple #23
0
        /* public ActionResult WishlistConfirm(int id)
         * {
         *   var movie = _context.Movie.SingleOrDefault(m => m.ID == id);
         *   movie.AddedWishlist = true;
         *   wishList.favItems.Add(movie);
         *
         *   return View(wishList);
         *   "~/Views/WishLists/Wishlist.cshtml"
         * }*/

        public async Task <IActionResult> Wishlist()
        {
            // Use LINQ to get list of genres.
            IQueryable <bool> wishListQuery = from a in _context.Movie
                                              orderby a.AddedWishlist
                                              select a.AddedWishlist;

            var movies = from m in _context.Movie
                         select m;

            movies = movies.Where(x => x.AddedWishlist == true);


            WishListViewModel wishListViewModel = new WishListViewModel();

            wishListViewModel.items    = new SelectList(await wishListQuery.Distinct().ToListAsync());
            wishListViewModel.favItems = await movies.ToListAsync();

            return(View(wishListViewModel));
        }
        public IActionResult Index(string searchString)
        {
            var user      = WishListService.GetUser(this.HttpContext);
            var userId    = user.UserId;
            var listModel = new WishListViewModel
            {
                ListItems = _wishListService.GetWishListItems(userId),
            };

            if (!String.IsNullOrEmpty(searchString))
            {
                var bookList = _bookService.GetSearchBooks(searchString);
                if (bookList.Count == 0)
                {
                    return(View("NoResults"));
                }

                _myModel.Book    = bookList;
                _myModel.Account = listModel;

                return(View("../Home/Index", _myModel));
            }

            var cart         = CartService.GetCart(this.HttpContext);
            var cartId       = cart.ShoppingCartId;
            var shoppingCart = new ShoppingCartViewModel
            {
                CartItems    = _cartService.GetCartItems(cartId),
                CartTotal    = _cartService.GetTotal(cartId),
                CartQuantity = _cartService.GetTotalQuantity(cartId)
            };

            var account = _accountService.GetAllAccounts();
            var books   = _bookService.GetShoppingCartBooks(cartId);

            _myModel.cartItems = shoppingCart;
            _myModel.bookItems = books;
            _myModel.account   = account;

            return(View(_myModel));
        }
Exemple #25
0
        private WishListViewModel GetWishListViewModel(WishList.Data.WishList list)
        {
            var model = new WishListViewModel {
                UserId = list.UserId,
                Wishes = new List <WishInListViewModel>()
            };

            foreach (var wish in list.Wishes)
            {
                model.Wishes.Add(new WishInListViewModel {
                    Id               = wish.Id,
                    Name             = wish.Name,
                    Description      = wish.Description,
                    LinkUrl          = WashUrl(wish.LinkUrl),
                    CalledByUserId   = wish.IsCalled ? (int?)wish.CalledByUser.Id : null,
                    CalledByUserName = wish.IsCalled ? wish.CalledByUser.Name : null
                });
            }

            return(model);
        }
Exemple #26
0
        public async Task <ActionResult> Index()
        {
            var userTemp = await UserManager.FindByEmailAsync(User.Identity.Name);

            var tempProductId = _dbBCDHX.WishLists.Where(x => x.ID_Account == userTemp.Id).Select(x => new { wishListId = x.ID_WishList, ID_Product = x.ID_Product });
            WishListViewModel tempWishListViewModel = new WishListViewModel();
            List <Models.ModelObject.Product> tempWishListProduct = new List <Models.ModelObject.Product>();

            tempWishListViewModel.ID_Account = userTemp.Id;
            foreach (var item in tempProductId)
            {
                var products = (from p in _dbBCDHX.Products
                                join g in _dbBCDHX.Categories on p.ID_Category equals g.ID_Category
                                join e in _dbBCDHX.ImageForProducts on p.ID_Product equals e.ID_Product
                                where p.Quantity > 0
                                orderby p.Name_Product
                                select new Models.ModelObject.Product
                {
                    ID_Product = p.ID_Product,
                    ID_Category = p.ID_Category,
                    Name_Product = p.Name_Product,
                    Quantity = p.Quantity.Value,
                    Price = p.Price.Value.ToString(),
                    Status = p.Status.Value,
                    Sale = p.Sale.Value.ToString(),
                    Img = e.IMG1,
                    Description = p.Description,
                    NameCatogory = g.Name_Category
                }
                                ).Where(x => x.ID_Product == item.ID_Product).SingleOrDefault();

                if (products != null)
                {
                    tempWishListViewModel.IdWishList = item.wishListId;
                    tempWishListProduct.Add(products);
                }
            }
            tempWishListViewModel.ListProductWishList = tempWishListProduct;
            return(View(tempWishListViewModel));
        }
Exemple #27
0
        public ActionResult Create(WishListViewModel model)
        {
            if (User.Identity.GetUserId() == null)
            {
                return(RedirectToAction("Login", "Auth"));
            }

            var user     = _unitOfWork.Users.Get(User.Identity.GetUserId());
            var code     = DateTime.UtcNow.Ticks / 10000;
            var wishList = new WishList
            {
                Code      = code.ToString(),
                Name      = model.Name,
                User      = user,
                CreatedAt = DateTime.UtcNow
            };

            _unitOfWork.WishLists.Save(wishList);
            _unitOfWork.Commit();

            ViewBag.Message = string.Format("<div class='alert alert-success'>Lista criada com sucesso! Código da lista: <strong>{0}</strong></div>", code);
            ModelState.Clear();
            return(View());
        }
Exemple #28
0
        public async Task <IActionResult> AddToCart(WishListViewModel WishListObject)
        {
            if (ModelState.IsValid)
            {
                var          claimsIdentity = (ClaimsIdentity)this.User.Identity;
                var          claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);
                ShoppingCart shop           = new ShoppingCart();


                ShoppingCart cartFromDb = await _db.ShoppingCart.Where(c => c.ApplicationUserId == claim.Value && c.MenuItemId == WishListObject.WishList.MenuItemId).FirstOrDefaultAsync();

                if (cartFromDb == null)
                {
                    var mn = await _db.MenuItem.FirstOrDefaultAsync(m => m.Id == WishListObject.WishList.MenuItemId);

                    shop.ApplicationUserId = claim.Value;
                    shop.Count             = 1;
                    shop.MenuItemId        = mn.Id;
                    await _db.ShoppingCart.AddAsync(shop);
                }
                else
                {
                    return(RedirectToAction("Index", "Cart"));
                }
                await _db.SaveChangesAsync();

                var count = _db.ShoppingCart.Where(c => c.ApplicationUserId == shop.ApplicationUserId).ToList().Count();
                HttpContext.Session.SetInt32("ssCartCount", count);

                return(RedirectToAction("Index", "Cart"));
            }
            else
            {
                return(View());
            }
        }
Exemple #29
0
 public WishList()
 {
     InitializeComponent();
     BindingContext = new WishListViewModel();
 }
Exemple #30
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     BindingContext = new WishListViewModel();
 }