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()); }
//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); }
public ActionResult Create(ProductModel product) { WishListModel wishlish = Mapper.Map <ProductModel, WishListModel>(product); db.WishList.Add(wishlish); db.SaveChanges(); return(RedirectToAction("Index")); }
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"; }
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); }
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)); }
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(); } }
public ActionResult Add(WishListModel WishList) { try { WishListCollection.InsertOneAsync(WishList); return(RedirectToAction("DestinationsList")); } catch { return(View()); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (WishList != null) { UxSubmit.Content = "Update"; } else { WishList = new WishListModel { CreatedDate = DateTime.Now }; } UxGrid.DataContext = WishList; }
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)); }
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, }); }
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)); } }
//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); }
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(); } }
public ActionResult RemoveWishList(int id) { WishListModel.RemoveWishList(id); return(Json(WishListModel.CountWishList(loginSession.AuthenticatedUser().USERID), JsonRequestBehavior.AllowGet)); }
// 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"); } } }
private void UxFileDelete_Click(object sender, RoutedEventArgs e) { WishListRepository.WishListRepository.Remove(selectedWishList.Id); selectedWishList = null; LoadWishLists(); }
// 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); }
public PriceStatus modifybook(WishListModel wish) { return(iadmin.modifybook(wish)); }
//calls the action in service DAlayer which add books from wishlist to cart public string addToCart(WishListModel ins) { return(service.addToCart(ins)); }
public string addToCart(WishListModel wish) { return(ser.addToCart(wish)); }
//calls the action in service DAlayer which adds the book to wishlist public string addToWishList(WishListModel wish) { return(service.addToWishList(wish)); }