Example #1
0
        public WishListPage()
        {
            var vm = new WishListModel();

            this.BindingContext = vm;
            InitializeComponent();
        }
        public async Task <IActionResult> PutWishListModel([FromRoute] int id, [FromBody] WishListModel wishListModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != wishListModel.ListId)
            {
                return(BadRequest());
            }

            _context.Entry(wishListModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WishListModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #3
0
        //Adds the book from wishlist to cart
        public string addToCart(WishListModel wish)
        {
            string s = "";

            try
            {
                using (var dbcontext = new Orchard9Entities())
                {
                    if ((from e in dbcontext.tblCarts where e.ISBN == wish.ISBN && e.UserId == wish.UserId select e.CartId).ToList().Count > 0)
                    {
                        return("Already present");
                    }
                    else
                    {
                        dbcontext.tblCarts.Add(new tblCart()
                        {
                            CartId    = wish.id,
                            ISBN      = wish.ISBN,
                            UserId    = wish.UserId,
                            PayStatus = true,
                            Quantity  = 1
                        });
                        dbcontext.SaveChanges();
                        return("Added to cart");
                    }
                }
            }
            catch (Exception e)
            {
                s = e.Message;
            }
            return(s);
        }
Example #4
0
        public ActionResult Create(ProductModel product)
        {
            WishListModel wishlish = Mapper.Map <ProductModel, WishListModel>(product);

            db.WishList.Add(wishlish);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
        private void LoadWishLists()
        {
            WishList = WishListRepository.WishListRepository.GetAll();

            UxWishListList.ItemsSource = WishList
                                         .Select(t => WishListModel.ToModel(t))
                                         .ToList();

            UxStatus.Text = $"You currently have {WishList.Count} items in your Wish List";
        }
Example #6
0
        public WishListResponseModel Response(WishListModel wishListModel)
        {
            WishListResponseModel wishList = new WishListResponseModel();

            wishList.WishListId  = wishListModel.WishListID;
            wishList.UserId      = wishListModel.UserId;
            wishList.BookId      = wishListModel.BookId;
            wishList.CreatedDate = wishListModel.CreatedDate;
            return(wishList);
        }
Example #7
0
        public async Task <ActionResult <WishListModel> > CreateWishList(WishListModel wishList)
        {
            try {
                dBContext.WishLists.Add(wishList);
                await dBContext.SaveChangesAsync();

                return(Ok(wishList));
            }
            catch (Exception e) {
                return(StatusCode(410));
            }
        }
        public async Task <IActionResult> PostWishListModel([FromBody] WishListModel wishListModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.WishListModel.Add(wishListModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetWishListModel", new { id = wishListModel.ListId }, wishListModel));
        }
Example #9
0
        private void UxFileNew_Click(object sender, RoutedEventArgs e)
        {
            WishListWindow window = new();

            if (window.ShowDialog() == true)
            {
                WishListModel uiWishListModel = window.WishList;
                WishListRepository.WishListModel repositoryWishListModel = uiWishListModel.ToRepositoryModel();

                WishListRepository.WishListRepository.Add(repositoryWishListModel);
                LoadWishLists();
            }
        }
Example #10
0
        public ActionResult Add(WishListModel WishList)
        {
            try
            {
                WishListCollection.InsertOneAsync(WishList);

                return(RedirectToAction("DestinationsList"));
            }
            catch
            {
                return(View());
            }
        }
Example #11
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     if (WishList != null)
     {
         UxSubmit.Content = "Update";
     }
     else
     {
         WishList = new WishListModel
         {
             CreatedDate = DateTime.Now
         };
     }
     UxGrid.DataContext = WishList;
 }
Example #12
0
        public ActionResult AddToWishList(int id)
        {
            BOOK book = BookModel.FilterBook(id);

            if (book == null)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            if (!WishListModel.Exist(id, loginSession.AuthenticatedUser().USERID))
            {
                WishListModel.AddToWishList(id, loginSession.AuthenticatedUser().USERID);
            }

            return(Json(WishListModel.CountWishList(loginSession.AuthenticatedUser().USERID), JsonRequestBehavior.AllowGet));
        }
Example #13
0
            public void Visit(ILineItem lineItem)
            {
                var name     = lineItem.ExtendedData["WishlistTitle"];
                var wishlist = wishlists.FirstOrDefault(x => x.Title == name);

                if (wishlist == null)
                {
                    wishlist = new WishListModel()
                    {
                        CustomerID = lineItem.ContainerKey,
                        IsPublic   = bool.Parse(lineItem.ExtendedData["IsPublic"])
                    };
                    wishlists.Add(wishlist);
                }
                wishlist.Items.Add(new WishListItemModel()
                {
                    QuantityPurchased = int.Parse(lineItem.ExtendedData["QuantityPurchased"]),
                    QuantityWanted    = lineItem.Quantity,
                    SKU = lineItem.Sku,
                });
            }
Example #14
0
        public async Task <IActionResult> UpdateWishList(WishListModel wishList, long id)
        {
            try {
                if (id != wishList.IdWishList)
                {
                    return(BadRequest());
                }
                dBContext.Entry(wishList).State = EntityState.Modified;
                await dBContext.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception e) {
                bool wishListExist = dBContext.WishLists.Any(e => e.IdWishList == id);
                if (!wishListExist)
                {
                    return(NotFound());
                }
                return(StatusCode(410));
            }
        }
Example #15
0
        //adds the book to wishlist
        public string addToWishList(WishListModel wish)
        {
            string s = "";

            try
            {
                using (var dbcontext = new Orchard9Entities())
                {
                    if ((from e in dbcontext.tblUsers where e.UserId == wish.UserId && e.IsActive == false select e.UserId).ToList().Count > 0)
                    {
                        return("You are Blocked by Admin");
                    }
                    else
                    {
                        if ((from e in dbcontext.tblWishlists where e.ISBN == wish.ISBN && e.UserId == wish.UserId select e.id).ToList().Count > 0)
                        {
                            return("Already present");
                        }
                        else
                        {
                            dbcontext.tblWishlists.Add(new tblWishlist()
                            {
                                id           = wish.id,
                                ISBN         = wish.ISBN,
                                UserId       = wish.UserId,
                                CurrentPrice = wish.price
                            });
                            dbcontext.SaveChanges();
                            return("added successfully");
                        }
                    }
                }
            }

            catch (Exception e)
            {
                s = e.Message;
            }
            return(s);
        }
Example #16
0
        private void UxSearchBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            Regex  regexNums    = new("[^0-9]+");
            string searchBox    = UxSearchBox.Text;
            bool   isRegexMatch = regexNums.IsMatch(searchBox);

            if (!isRegexMatch && searchBox.Length == 4)
            {
                WishList = WishListRepository.WishListRepository.GetAll();

                IEnumerable <WishListRepository.WishListModel> SkuSearch =
                    from w in WishList
                    where w.Sku == UxSearchBox.Text
                    select w;

                UxWishListList.ItemsSource = SkuSearch
                                             .Select(t => WishListModel.ToModel(t))
                                             .ToList();
            }
            else
            {
                LoadWishLists();
            }
        }
Example #17
0
 public ActionResult RemoveWishList(int id)
 {
     WishListModel.RemoveWishList(id);
     return(Json(WishListModel.CountWishList(loginSession.AuthenticatedUser().USERID), JsonRequestBehavior.AllowGet));
 }
Example #18
0
 // GET: WishList
 public ActionResult Index(int?id)
 {
     return(View(WishListModel.GetAll(id)));
 }
        public async void OnAddWishButton_Clicked(object sender, EventArgs e)
        {
            var value = Application.Current.Properties["Username"].ToString();

            Console.WriteLine(value);


            using (SQLiteConnection conn = new SQLiteConnection(App.FilePath))
            {
                try
                {
                    conn.CreateTable <User>();
                    var useridcheck = conn.Table <User>().Where(c => c.Username == value).ToList();


                    var Rows = new ObservableCollection <User>();
                    Rows.Clear();



                    foreach (var entry in useridcheck)
                    {
                        // var test = "***";

                        // entryList just contains values I use to populate row info
                        var row = new User();
                        row.UID = entry.UID;
                        Console.WriteLine("test av UID: " + entry.UID);
                        var uid = entry.UID;

                        Rows.Add(row);



                        var newWishListModel = new WishListModel
                        {
                            UID            = uid,
                            WishId         = WishId,
                            ReferProductID = productId
                        };



                        await InsertintoWishlist(uid);

                        conn.CreateTable <WishListModel>();
                        int rowsAdded = conn.Insert(newWishListModel);

                        await DisplayAlert("Congrats!", "A new product have been added to the wishlist!", "OK");

                        Console.WriteLine(uid.ToString(), ShoppingId, productId);
                        await Navigation.PushAsync(new ProductPage());
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    await DisplayAlert("Alert", "Something went wrong!", "OK");
                }
            }
        }
Example #20
0
 private void UxFileDelete_Click(object sender, RoutedEventArgs e)
 {
     WishListRepository.WishListRepository.Remove(selectedWishList.Id);
     selectedWishList = null;
     LoadWishLists();
 }
Example #21
0
 // detect if selection has been made
 private void UxWishListList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     selectedWishList = (WishListModel)UxWishListList.SelectedValue;
     UxContextFileDelete.IsEnabled = selectedWishList != null;
 }
        public PriceStatus modifybook(WishListModel wish)
        {
            string s = "";

            PriceStatus pr = new PriceStatus();



            try
            {
                using (var dbcontext = new Orchard9Entities())
                {
                    double?amount = 0;
                    if ((from d in dbcontext.tblWishlists where d.ISBN == wish.ISBN select d).Count() > 0)
                    {
                        amount = (from d in dbcontext.tblWishlists where d.ISBN == wish.ISBN select d.CurrentPrice).FirstOrDefault();
                    }
                    else
                    {
                        amount = (from d in dbcontext.tblBooks where d.ISBN == wish.ISBN select d.Price).FirstOrDefault();
                    }
                    var dis = Convert.ToDouble(wish.price);

                    var query = (from e in dbcontext.tblWishlists
                                 join d in dbcontext.tblBooks on e.ISBN equals d.ISBN
                                 join x in dbcontext.tblUsers on e.UserId equals x.UserId
                                 where e.UserId == x.UserId && wish.ISBN == d.ISBN
                                 select new PriceModel()
                    {
                        mailid = x.EmailId
                    }).ToList();



                    if ((from d in dbcontext.tblBooks where d.ISBN == wish.ISBN select d.Price).ToList().Count == 0)
                    {
                        pr.statusMessage = "This book does not exist";

                        return(pr);
                    }
                    if (amount == dis)
                    {
                        pr.statusMessage = "no changes";
                        pr.statusList    = query;
                        pr.changedPrice  = 0;
                        pr.bookName      = wish.BookName;
                    }
                    else if (amount > dis)

                    {
                        pr.changedPrice  = amount - dis;
                        pr.statusList    = query;
                        pr.statusMessage = "reduced";
                        pr.bookName      = wish.BookName;
                    }
                    else
                    {
                        pr.changedPrice  = dis - amount;
                        pr.statusList    = query;
                        pr.bookName      = wish.BookName;
                        pr.statusMessage = "increased";
                    }



                    dbcontext.tblBooks.Where(h => h.ISBN == wish.ISBN).ToList().ForEach(h =>
                    {
                        h.Price        = wish.price;
                        h.Publisher    = wish.Publisher;
                        h.Author       = wish.Author;
                        h.Rating       = wish.rating;
                        h.BookName     = wish.BookName;
                        h.Description  = "jj";
                        h.Category     = "hhh";
                        h.isactive     = true;
                        h.BookImageUrl = wish.BookImageUrl;
                    });
                    dbcontext.tblWishlists.Where(h => h.ISBN == wish.ISBN).ToList().ForEach(h =>
                    {
                        h.CurrentPrice = wish.price;
                    });
                    dbcontext.SaveChanges();
                }
            }

            catch (Exception e)
            {
                s = e.Message;
                pr.statusMessage = s;
            }
            return(pr);
        }
Example #23
0
 public PriceStatus modifybook(WishListModel wish)
 {
     return(iadmin.modifybook(wish));
 }
Example #24
0
 //calls the action in service DAlayer which add books from wishlist to cart
 public string addToCart(WishListModel ins)
 {
     return(service.addToCart(ins));
 }
Example #25
0
 public string addToCart(WishListModel wish)
 {
     return(ser.addToCart(wish));
 }
Example #26
0
 //calls the action in service DAlayer which adds the book to wishlist
 public string addToWishList(WishListModel wish)
 {
     return(service.addToWishList(wish));
 }