Esempio n. 1
0
        public ActionResult PayWishlist(Reservations reservation)
        {
            if (ModelState.IsValid)
            {
                Wishlists wishlistInSession = null;
                if (Session["wishlist"] != null)
                {
                    wishlistInSession = (Wishlists)Session["wishlist"];
                }
                List <WishlistViewModel> wishlist = GetActivitiesFromSession();
                if (wishlist != null)
                {
                    wishListRepo.ReservationOfActivities(wishlist, reservation, wishlistInSession);
                    ViewBag.succes = "Betaling voltooid";
                    return(View("Index", GetActivitiesFromSession()));
                }
            }
            ViewBag.errors = "Betaling mislukt!";
            List <string> methodes = new List <string>();

            methodes.Add("Ideal");
            methodes.Add("Paypal");
            methodes.Add("Creditcard");
            PaymentMethodsDropDown();
            return(View());
        }
Esempio n. 2
0
        public ActionResult GetSavedWishlist(string wislistToken)
        {
            Wishlists wishlist = wishListRepo.getWishList(wislistToken);

            if (wishlist == null)
            {
                ViewBag.errors = "Code niet gevonden";
                return(View("Index", GetActivitiesFromSession()));
            }
            Session["wishlist"] = wishlist;
            IEnumerable <WishlistViewModel> activities = wishListRepo.GetActivities(wishlist);

            if (activities.Count() < 1)
            {
                ViewBag.errors = "Code niet gevonden";
                return(View("Index", GetActivitiesFromSession()));
            }
            foreach (var activity in activities)
            {
                AddActivityToSesWishlist(activity.NumberOfPersons, activity.Activity);
            }
            ViewBag.succes = "Wishslist geladen";

            return(View("Index", GetActivitiesFromSession()));
        }
        public async void LoadAllAsync()
        {
            var userId = App.UserViewModel.LoggedUser.Id;
            var list   = await App.UnitOfWork.WishlistRepository
                         .FindAllByUserIdAsync(userId);

            Wishlists.Clear();
            foreach (var l in list)
            {
                Wishlists.Add(l);
            }
        }
Esempio n. 4
0
        public Wishlist AddBook(Book book)
        {
            var existingBook = Wishlists
                               .SingleOrDefault(p => p.BookId == book.Id);

            if (existingBook == null)
            {
                existingBook = new Wishlist(Name, book.Id);
                Wishlists.Add(existingBook);
            }
            return(existingBook);
        }
Esempio n. 5
0
        // GET: Wishlists/Create
        public async Task <IActionResult> Create(string productId, string productName, string description, string link, string image, float price, string soldBy)
        {
            ViewData["UserId"] = new SelectList(_context.AspNetUsers, "Id", "Id");
            var user = await _userManager.GetUserAsync(User);

            Wishlists list = new Wishlists();

            list.ProductName = productName;

            var noItem = await _context.Wishlists
                         .Include(w => w.User)
                         .SingleOrDefaultAsync(m => m.ProductId == productId);

            if (noItem == null)
            {
                var tooManyItems = _context.Wishlists
                                   .Include(w => w.User)
                                   .Where(m => m.UserId == user.Id.ToString())
                                   .ToList();

                if (tooManyItems.Count() >= 20)
                {
                    list.ProductId = "-2";
                }
                else
                {
                    list.ProductId   = productId;
                    list.Description = description;
                    list.Link        = link;
                    list.Image       = image;
                    list.Price       = price;
                    list.SellerName  = soldBy;
                    list.UserId      = user.Id.ToString();

                    _context.Add(list);
                    await _context.SaveChangesAsync();
                }
            }
            else
            {
                list.ProductId = "-1";
            }
            return(View(list));
        }
Esempio n. 6
0
        public IHttpActionResult GetWishList(long UserID)
        {
            List <Wishlists> Wishlist = new List <Wishlists>();

            try
            {
                DataSet       ds              = new DataSet();
                SqlConnection sqlcon          = new SqlConnection(connection);
                string        storedprocedure = "BagByte_01_GetWishList";

                SqlCommand sqlcmd = new SqlCommand(storedprocedure, sqlcon);

                sqlcmd.Parameters.AddWithValue("@UserID", UserID);
                sqlcmd.CommandType = CommandType.StoredProcedure;

                sqlcon.Open();

                SqlDataAdapter adapter = new SqlDataAdapter(sqlcmd);
                adapter.Fill(ds);
                sqlcon.Close();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    Wishlists Tempwihlist = new Wishlists();

                    Tempwihlist.WishList       = long.Parse(ds.Tables[0].Rows[i]["CartID"].ToString());
                    Tempwihlist.ProductID      = long.Parse(ds.Tables[0].Rows[i]["ProductID"].ToString());
                    Tempwihlist.ProductName    = ds.Tables[0].Rows[i]["ProductName"].ToString();
                    Tempwihlist.ProductCatName = ds.Tables[0].Rows[i]["ProductCategoryName"].ToString();
                    Tempwihlist.Price          = decimal.Parse(ds.Tables[0].Rows[i]["ProductPrice"].ToString());
                    Tempwihlist.ProductImage   = ds.Tables[0].Rows[i]["ImageName"].ToString();

                    Wishlist.Add(Tempwihlist);
                }
            }
            catch (Exception ex)
            {
                return(ResponseMessage(Request.CreateResponse(ex.ToString())));
            }

            return(Ok(Wishlist));
        }
Esempio n. 7
0
        public Wishlists SaveActivities(List <WishlistViewModel> wishlist, Reservations reservation, Wishlists wishlistInSession)
        {
            Wishlists wislistToSave;

            //als de wishlist al een keer is opgehaald uit de db, update deze dan.
            if (wishlistInSession != null)
            {
                wislistToSave = wishlistInSession;
                wislistToSave.WishlistItems = null;
                ctx.SaveChanges();
            }
            else
            {
                wislistToSave = new Wishlists();
            }

            wislistToSave.paid = false;
            foreach (WishlistViewModel activity in wishlist)
            {
                WishlistItems wishitems = new WishlistItems();
                //check of de activity daadwerkelijk in db staat
                Activities activiteit = activity.Activity;
                wishitems.activityId      = activiteit.id;
                wishitems.numberOfPersons = activity.NumberOfPersons;
                wislistToSave.WishlistItems.Add(wishitems);
                //wislist.totalPrice = wislist.totalPrice + activiteit.price;
            }
            if (reservation != null)
            {
                wislistToSave.paid = true;
                wislistToSave.Reservations.Add(reservation);
            }
            wislistToSave.token      = Crypto.HashPassword(Crypto.GenerateSalt() + DateTime.Now.Ticks.ToString());
            wislistToSave.totalPrice = wishlist.Sum(w => w.totalprice);
            if (wishlistInSession == null)
            {
                ctx.Wishlists.Add(wislistToSave);
            }
            ctx.SaveChanges();
            return(wislistToSave);
        }
Esempio n. 8
0
        public virtual async Task <Wishlists> Process(CommerceContext commerceContext, string customerId, int take = 10, int skip = 0)
        {
            var customerEntity = await _getCustomerCommand.Process(commerceContext, customerId);

            Wishlists wishlists = new Wishlists();

            wishlists.Wishlist = new List <Entities.WishlistEntity>();
            try
            {
                if (customerEntity != null)
                {
                    if (customerEntity.HasComponent <WishlistComponent>())
                    {
                        var component = customerEntity.GetComponent <WishlistComponent>();
                        if (component?.WishlistCollection != null && component.WishlistCollection.Any())
                        {
                            wishlists.TotalCount = component.WishlistCollection.Count;
                            var customerWishlist = (skip == 0 && take == 0) ? component?.WishlistCollection :
                                                   component?.WishlistCollection.Skip(skip).Take(take);

                            foreach (var item in customerWishlist)
                            {
                                Entities.WishlistEntity wishlistEntity = new Entities.WishlistEntity()
                                {
                                    ProductId    = item.ProductId,
                                    ProductPrice = item.ProductPrice,
                                    ProductTitle = item.ProductTitle
                                };
                                wishlists.Wishlist.Add(wishlistEntity);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                commerceContext.Logger.LogError(ex.StackTrace, ex.Message, ex);
            }
            return(wishlists);
        }
Esempio n. 9
0
 public IEnumerable <WishlistViewModel> GetActivities(Wishlists wishlist)
 {
     return(GetActivities(wishlist.id));
 }
Esempio n. 10
0
 public void ReservationOfActivities(List <WishlistViewModel> wishlist, Reservations reservation, Wishlists wishlistInSession)
 {
     SaveActivities(wishlist, reservation);
 }
Esempio n. 11
0
 public void RemoveWishlist(Wishlist wishlist)
 {
     Wishlists.Remove(wishlist);
 }
Esempio n. 12
0
 public void AddWishlist(Wishlist wishlist)
 {
     Wishlists.Add(wishlist);
 }