public IActionResult Add(AddWishListViewModel addWishListViewModel) { if (ModelState.IsValid) { WishList newWishList = new WishList { Name = addWishListViewModel.Name }; context.WishLists.Add(newWishList); context.SaveChanges(); return(Redirect("/WishList")); } return(View(addWishListViewModel)); }
public WishList Identify(WishList wishList, BookClub bookClub) { foreach (var bookClubBook in bookClub.Books) { foreach (var wishListBook in wishList.Books) { if (wishListBook.Book.IsSameTitleAndAuthor(bookClubBook)) { wishListBook.IsBookClubSelection = true; } } } return wishList; }
public void Setup() { _wishList = new WishList(); _bookClub = new BookClub(); _bookOne = new Book { Title = "someTitle", Author = "someAuthor" }; _bookTwo = new Book { Title = "anotherTitle", Author = "anotherAuthor" }; }
public bool AddToWishList(int productId, string userId) { try { var current = new WishList() { UserId = userId, ProductId = productId, }; _dbContext.WishLists.Add(current); return(true); } catch (Exception e) { return(false); } }
public void RemoveItemPassingCatalogItemId() { var random = new Random(); var numberOfItems = random.Next(1, 10); var removeTheId = random.Next(_testCatalogItemId, _testCatalogItemId + numberOfItems - 1); var wishList = new WishList(); for (var count = 0; count < numberOfItems; count++) { wishList.AddItem(_testCatalogItemId + count, _testUnitPrice, _priceSymbol, _testQuantity); } wishList.RemoveItem(_testCatalogItemId); Assert.Equal(numberOfItems - 1, wishList.Items.Count); }
public IActionResult DeleteWishlist(int id) { //clears individual game from logged in users wish list string activeUserId = GetActiveUser(); var gameToDelete = _gameContext.WishList.Find(id); WishList deleteItem = _gameContext.WishList.Where(uf => uf.UserId == activeUserId && uf.GameId == id).FirstOrDefault(); if (deleteItem != null) { _gameContext.WishList.Remove(deleteItem); _gameContext.SaveChanges(); } return(RedirectToAction("DisplayWishlist")); }
// GET: WishLists/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WishList wishList = db.WishLists.Find(id); List <WishList> listWish = new List <WishList>(); listWish.Add(wishList); if (wishList == null) { return(HttpNotFound()); } ViewBag.AccountId = new SelectList(listWish, "AccountId", "AccountId", wishList.AccountId); return(View(wishList)); }
public JsonResult Add(int? friendId, int serverMediaId) { try { var user = db.Users.First(a => a.UserName == Username.Identity.Name); var wishlist = db.WishLists.FirstOrDefault(a => a.User.UserName == Username.Identity.Name); var serverMedia = db.ServerMedias.First(a => a.Id == serverMediaId); if (wishlist == null) { wishlist = new WishList() { User = user, LastUpdate = DateTime.UtcNow }; db.WishLists.InsertOnSubmit(wishlist); } if (friendId.HasValue) { if (SecurityHelpers.AreFriends(db, Username.Identity.Name, friendId.Value) && serverMedia != null) { var wlf = new WishListFile() { WishList = wishlist, ServerMedia = serverMedia }; db.WishListFiles.InsertOnSubmit(wlf); db.SubmitChanges(); return Json(wlf.Id); } } else { if (user.UserXServers.Select(a => a.ServerId).Contains(serverMedia.ServerId)) { var wlf = new WishListFile() { WishList = wishlist, ServerMedia = serverMedia }; db.WishListFiles.InsertOnSubmit(wlf); db.SubmitChanges(); return Json(wlf.Id); } } return Json(-1); } catch { } return Json(-1); }
public IActionResult ViewWishList(int id) { List <LaptopWishList> items = context .LaptopWishLists .Include(item => item.Laptop) .Where(lw => lw.WishListID == id) .ToList(); WishList wishList = context.WishLists.Single(w => w.ID == id); ViewWishListViewModel viewModel = new ViewWishListViewModel { WishList = wishList, Items = items }; return(View(viewModel)); }
protected void Translate(Cart source, WishList destination) { destination.ExternalId = source.Id; destination.Name = source.Name; destination.ShopName = source.ShopName; if (source.Components != null && source.Components.Any()) { ContactComponent contactComponent = source.Components.OfType <ContactComponent>().FirstOrDefault(); if (contactComponent != null) { // destination.Email = contactComponent.Email ?? string.Empty; destination.UserId = contactComponent.ShopperId ?? string.Empty; destination.CustomerId = string.IsNullOrEmpty(contactComponent.CustomerId) ? contactComponent.ShopperId ?? string.Empty : contactComponent.CustomerId; } } destination.Lines = TranslateLines(source, destination); }
public void AddToWishList(BookListViewModel book, WishList user) { var listItem = (from item in _db.Lists where item.Book.Id == book.Id && item.UserId == user.UserId select item).SingleOrDefault(); if (listItem == null) { listItem = new List { BookId = book.Id, UserId = user.UserId, }; _db.Lists.Add(listItem); } _db.SaveChanges(); }
public ActionResult Create([Bind(Include = "Id,AccountId,DateAdded,Cost,Description,Link,Purchased")] WishList wishList) { if (ModelState.IsValid) { db.WishLists.Add(wishList); db.SaveChanges(); return(RedirectToAction("Index")); } // GET ONLY TEAMS BELONGING TO THE CURRENT USER FOR THE DROPDOWN //string currentlyLoggedInUsername = User.Identity.Name; //var acc = db.Accounts // .Where(x => x.OwnerEmail == currentlyLoggedInUsername // || x.RecipientEmail == currentlyLoggedInUsername).ToList(); //ViewBag.AccountId = new SelectList(acc, "Id", "Name", wishList.AccountId); return(View(wishList)); }
public void ControlWishList(int id) { WishList wl = _wishListConcrete._wishListRepository.GetAll().FirstOrDefault(x => x.CoffeeID == id && x.CustomerID == (Session["OnlineKullanici"] as Customer).ID && x.IsActive == true); if (wl == null) { wl = new WishList() { CoffeeID = id, CustomerID = (Session["OnlineKullanici"] as Customer).ID, IsActive = true }; _wishListConcrete._wishListRepository.Insert(wl); _wishListConcrete._wishListUnitOfWork.SaveChanges(); _wishListConcrete._wishListUnitOfWork.Dispose(); } }
public IActionResult Create([FromBody] WishList item) { if (item == null) { return(BadRequest()); } var currentUser = _userManager.GetUserAsync(User).Result; currentUser.CreateWishList(item); WishListRepository.Add(item); // _userManager.UpdateAsync(currentUser); WishListRepository.SaveChanges(); return(Created($"/api/wishlist/{item.WishListId}", item)); }
public ActionResult AddToWishList(int id) { WishList wl = db.WishLists.FirstOrDefault(x => x.ProductID == id && x.CustomerID == 3 && x.IsActive == true); if (wl == null) { wl = new WishList(); wl.CustomerID = 3; //TODO: Dinamik hale getirilecek.... wl.ProductID = id; wl.IsActive = true; db.WishLists.Add(wl); db.SaveChanges(); } return(View(db.WishLists.Where(x => x.CustomerID == 3 && x.IsActive == true).ToList())); }
public ActionResult AddToWishList(int productid, int size = 0, string attributes = "") { var currentUserId = Convert.ToInt32(GlobalUser.getGlobalUser().UserId); var productSize = _productSizeBusiness.GetListWT(c => c.ProductId == productid).FirstOrDefault(); var defaultSize = productSize == null ? 0 : productSize.Id; if (size == 0) { size = defaultSize; } if (currentUserId > 0) { var count = _WishListBusiness.GetListWT(c => c.UserId == currentUserId && c.ProductId == productid).Count(); if (count <= 0) { WishList wishList = new WishList(); wishList.ProductId = productid; wishList.UserId = currentUserId; _WishListBusiness.Insert(wishList); _unitOfWork.SaveChanges(); } } else { CookieStore mycookie = new CookieStore(); var products = mycookie.GetCookie(Enumerator.CustomerAction.WishList.ToString()); var value = string.Empty; if (string.IsNullOrEmpty(products)) { value = productid.ToString() + "~" + size.ToString() + "~" + attributes.ToString(); } else { if (!products.Split(',').Select(c => c.Split('~')[0]).Contains(productid.ToString())) { value = products + "," + productid.ToString() + "~" + size.ToString() + "~" + attributes.ToString(); } } var expireCookieTimeHr = Convert.ToInt32(ReadConfigData.GetAppSettingsValue("ExpireCookieTimeHr")); mycookie.SetCookie(Enumerator.CustomerAction.WishList.ToString(), value, expireCookieTimeHr); } return(new EmptyResult()); }
static void Main(string[] args) { string filePath = @"C:\Users\mammu\samples"; string fileName = @"WishList.txt"; string fullFilePath = Path.Combine(filePath, fileName); string[] linesFromfile = File.ReadAllLines(fullFilePath); WishList myWishes = new WishList(); foreach (string line in linesFromfile) { string[] tempArray = line.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); string PersonName = tempArray[1]; string PersonWish = tempArray[2]; Console.WriteLine(WishList); myWishes.AddWishesToList(PersonName, PersonWish); } }
public async Task <ValidationResult> ValidateRemoveProductToWishList(RemoveProductToWishListInput input) { ValidationResult validationResult = new(); if (string.IsNullOrWhiteSpace(input.CustomerEmail)) { validationResult.Messages.Add(new(nameof(RemoveProductToWishListInput.CustomerEmail), "Debe indicar un cliente.")); } else { Customer customer = await _customerRepository.GetCustomer(input.CustomerEmail); if (customer is null) { validationResult.Messages.Add(new(nameof(RemoveProductToWishListInput.CustomerEmail), "No existe el cliente.")); } else { WishList wishList = await _wishListRepository.GetByCustomerAsync(input.CustomerEmail); if (wishList is null) { validationResult.Messages.Add(new(nameof(RemoveProductToWishListInput.CustomerEmail), "El cliente no posee una wishlist")); } } } if (string.IsNullOrWhiteSpace(input.ProductId)) { validationResult.Messages.Add(new(nameof(RemoveProductToWishListInput.ProductId), "Debe indicar un producto.")); } else { Product product = await _productRepository.GetAsync(input.ProductId); if (product is null) { validationResult.Messages.Add(new(nameof(RemoveProductToWishListInput.ProductId), "No existe el producto.")); } } return(validationResult); }
private static ShoppingCart WishListToShoppingCart(WishList wishList) { ShoppingCart shoppingCart = new ShoppingCart(); shoppingCart.ShoppingCartItems = new List <ShoppingCartItem>(); foreach (var item in wishList.WishListItems) { if (item.Inventory.Stock > 0) { shoppingCart.ShoppingCartItems.Add(new ShoppingCartItem() { Amount = item.Amount, Inventory = item.Inventory, InventoryId = item.InventoryId }); } } return(shoppingCart); }
public AddToWishListOutputModel Save(AddToWishListInputModel data) { WishListRepository repo = new WishListRepository(db); WishList temp = new WishList(); temp.SiteID = data.SiteID; temp.UserID = data.UserID; temp.SiteItemID = data.SiteItemID; var res = repo.Insert(temp); AddToWishListOutputModel output = new AddToWishListOutputModel(); output.SiteID = data.SiteID; return(output); }
public static WishlistModel ToWishlistModel([NotNull] this WishList wishList, IProductService productService = null) { var cartLineModel = new List <WishlistLineModel>(0); if (wishList.Lines != null && wishList.Lines.Any()) { foreach (var line in wishList.Lines) { cartLineModel.Add(line.ToWishlistLineModel(productService)); } } var wishlitstModel = new WishlistModel() { Lines = cartLineModel }; return(wishlitstModel); }
// GET: WishLists public ActionResult Index() { int?wid; if (wpath == 0) { wid = wflag; wflag = 0; return(RedirectToAction("Details", "Accounts", new { id = wid })); } else { WishList w = db.WishLists.Single(wi => wi.Id == wpath); Account ac = db.Accounts.Single(a => a.Id == w.AccountId); wpath = 0; wflag = 0; return(RedirectToAction("Details", "Accounts", new { id = ac.Id })); } }
public bool AddWishList(int IgraID, int KupacID) { if (ImaWishList(IgraID, KupacID)) { return(false); } WishList wishList = new WishList() { DatumDodavanja = DateTime.Now, KupacID = KupacID, IgraID = IgraID }; db.WishList.Add(wishList); db.SaveChanges(); db.Dispose(); return(true); }
public ActionResult Create(int?gameId, int?userId) { if (!gameId.HasValue || !userId.HasValue) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (!db.Game.Any(g => g.id == gameId) || !db.Member.Any(u => u.id == userId)) { //either id does not exist return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WishList list = new WishList { gameId = gameId.Value, userId = userId.Value, date = System.DateTime.Now.Date }; return(View(list)); }
public WishListSummaryViewModel GetWishListSummary(HttpContext httpContext) { WishList wishList = GetWishList(httpContext, false); WishListSummaryViewModel model = new WishListSummaryViewModel(0); if (wishList != null) { int?wishListCount = (from item in wishList.WishListItems select item.Quanity).Sum(); model.WishListCount = wishListCount ?? 0; return(model); } else { return(model); } }
public async Task Post([FromBody] WishList wish) { int userid = await GetUserId(); // Check if this wished item already exist in the wishlist var checkwish = await wishRepository.Wishes.FirstOrDefaultAsync(a => a.ItemId == wish.ItemId && a.UserId == userid); if (checkwish == null) { // If it does not exist add it to the list wish.UserId = userid; await wishRepository.SaveWishAsync(wish); } else { // If it exists delete it await wishRepository.DeleteWishAsync(checkwish); } }
// GET: Recipe public ActionResult LikeAjax(int id) { db.Configuration.ProxyCreationEnabled = false; if (!Request.IsAuthenticated) { return(Json(new { data = "NotLogIn" }, JsonRequestBehavior.AllowGet)); } Recipe recipe = db.Recipes.Find(id); if (recipe == null || recipe.DeletedAt != null) { return(RedirectToAction("NotFound", "Home")); } var likeCount = db.WishLists.Where(w => w.RecipeId == id).ToList().Count; //var UserManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db)); var userId = User.Identity.GetUserId(); Debug.WriteLine(db.WishLists.Find(id, userId)); if (db.WishLists.Find(id, userId) != null) { return(Json(new { data = likeCount }, JsonRequestBehavior.AllowGet)); } WishList like = new WishList(); like.UserId = User.Identity.GetUserId(); like.RecipeId = id; like.CreatedAt = DateTime.Now; try { db.WishLists.Add(like); db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); throw; } return(Json(new { data = likeCount + 1 }, JsonRequestBehavior.AllowGet)); }
public async Task GetImage_WishExists_ReturnsOperationResultSuccess() { //Arrange var wishlistDirName = "fdsfdsfsdf"; var fileName = "fdsfdsfsd.png"; var wishlist = new WishList() { UserId = 1, Name = "Wishlist 1", Wishes = new List <Wish>() { new Wish() { Name = "Wish 1", Image = new Image() { FileName = fileName, } } } , DirectoryName = wishlistDirName }; DbContext.Wishlists.Add(wishlist); DbContext.SaveChanges(); Directory.CreateDirectory($"{UserDirectory}\\{wishlistDirName}"); var fileDestPath = $"{UserDirectory}\\{wishlistDirName}\\{fileName}"; File.Copy($"{ImageSrcPath}\\image.png", fileDestPath); //Act var actualResult = await uploadService.GetImageAsync(1, UserId); //Assert Assert.IsNotNull(actualResult.Data.Image); Assert.AreEqual(OperationStatus.SUCCESS, actualResult.Status); //Cleanup Directory.Delete($"{UserDirectory}\\{wishlistDirName}", true); }
public async Task AddToWishList_If_Successfull() { var options = TestUtils.GetOptions(nameof(AddToWishList_If_Successfull)); var mockDateTime = new Mock <IDateTimeProvider>(); var user = new User { UserName = "******", }; var beer = new Beer { Name = "Zagorka", }; var wishList = new WishList { BeerId = 1, UserId = 1, }; using (var arrangeContext = new BeeroverflowContext(options)) { await arrangeContext.Users.AddAsync(user); await arrangeContext.Beers.AddAsync(beer); await arrangeContext.WishLists.AddAsync(wishList); await arrangeContext.SaveChangesAsync(); } using (var assertContext = new BeeroverflowContext(options)) { var sut = new UserService(assertContext, mockDateTime.Object); await sut.AddToWishListAsync(1, user, 1); var result = assertContext.WishLists.Where(x => x.BeerId == 1 || x.UserId == 1).FirstOrDefault(); Assert.AreEqual(user.Id, result.UserId); Assert.AreEqual(beer.Id, result.BeerId); } }
public async Task <JsonResult> AddWishList(string productID) { if (productID != null || productID != "") { var userTemp = await UserManager.FindByEmailAsync(User.Identity.Name); if (userTemp != null) { var productExsit = _dbBCDHX.WishLists.AsNoTracking().Where(x => x.ID_Account == userTemp.Id && x.ID_Product == productID).SingleOrDefault(); if (productExsit != null) { return(Json(new { Error = "Sản phẩm đã tồn tại trong wishList", Status = 3 })); } else { var productTemp = _dbBCDHX.Products.AsNoTracking().Where(x => x.ID_Product == productID).SingleOrDefault(); if (productTemp != null) { var wishListID = _randomcode.RandomNumber(4); WishList wishListmodel = new WishList { ID_Account = userTemp.Id, ID_Product = productID, ID_WishList = wishListID }; _dbBCDHX.Entry(wishListmodel).State = System.Data.Entity.EntityState.Added; _dbBCDHX.SaveChanges(); return(Json(new { Error = "Thêm sản phẩm thành công vào wishList", Status = 1 })); } else { return(Json(new { Error = "Lỗi sảy ra", Status = 2 })); } } } else { return(Json(new { Error = "Bạn phải đăng nhập mới thêm sản phẩm vào wishList của mình được!", Status = 4 })); } } else { return(Json(new { Error = "Lỗi sảy ra", Status = 2 })); } }
public override UpdateWishListSendACopyResult Execute(IUnitOfWork unitOfWork, UpdateWishListSendACopyParameter parameter, UpdateWishListSendACopyResult result) { if (parameter.SenderName.IsBlank()) { return(this.CreateErrorServiceResult <UpdateWishListSendACopyResult>(result, SubCode.BadRequest, string.Format(MessageProvider.Current.Field_Required, "SenderName"))); } if (parameter.RecipientEmailAddress.IsBlank()) { return(this.CreateErrorServiceResult <UpdateWishListSendACopyResult>(result, SubCode.BadRequest, MessageProvider.Current.AddressInfo_EmailAddress_Validation)); } string[] array = ( from o in parameter.RecipientEmailAddress.Split(new char[] { ',' }) select o.Trim()).Where <string>(new Func <string, bool>(RegularExpressionLibrary.IsValidEmail)).ToArray <string>(); if (array.Length == 0) { return(this.CreateErrorServiceResult <UpdateWishListSendACopyResult>(result, SubCode.BadRequest, MessageProvider.Current.AddressInfo_EmailAddress_Validation)); } WishList wishList = this.wishListCopyService.Copy(result.GetWishListResult.WishList, true); wishList.ShareOption = "Static"; result.CopiedWishList = wishList; string str = string.Format(this.translationLocalizer.TranslateLabel("{0} has shared a {1} shared list"), parameter.SenderName, SiteContext.Current.WebsiteDto.Name); EmailList orCreateByName = unitOfWork.GetTypedRepository <IEmailListRepository>().GetOrCreateByName("SendAListCopy", "Send A List Copy", ""); dynamic expandoObjects = new ExpandoObject(); expandoObjects.ListName = wishList.Name; expandoObjects.Message = parameter.Message; expandoObjects.DisplayName = parameter.SenderName; //BUSA-1090 Wish list email notification (share) expandoObjects.SenderName = result.GetWishListResult.UserProfile.Email; string str1 = this.websiteUtilities.WebsiteUri(SiteContext.Current.WebsiteDto); expandoObjects.ListUrl = string.Format("{0}/RedirectTo/{1}?id={2}", str1, "StaticListPage", wishList.Id); string[] strArrays = array; for (int i = 0; i < (int)strArrays.Length; i++) { string str2 = strArrays[i]; this.emailService.Value.SendEmailList(orCreateByName.Id, new string[] { str2 }, expandoObjects, str, unitOfWork, SiteContext.Current.WebsiteDto.Id); } return(base.NextHandler.Execute(unitOfWork, parameter, result)); }
public ActionResult Search(Selection selection) { IList <EventType> selectedET; IList <ClosetGarment> closetGarments = new List <ClosetGarment>(); IList <WishGarment> wishGarments = new List <WishGarment>(); MembershipUser mu = Membership.GetUser(); if (mu == null) { selectedET = eventTypeRepository.GetByIds((from e in ClosetState.EventTypes select e.Id).ToList <int>()); } else { WishList wl = wishListRepository.GetForUser(this.ProxyLoggedUser); if (wl != null) { wishGarments = wishListRepository.GetForUser(this.ProxyLoggedUser).Garments; } closetGarments = closetRepository.GetGarmentsForUser(this.ProxyLoggedUser); selectedET = registeredUserRepository.GetByMembershipId(Convert.ToInt32(mu.ProviderUserKey)).EventTypes; } HashSet <jsonGarment> finalResult = new HashSet <jsonGarment>(); HashSet <MasterGarment> result = new HashSet <MasterGarment>( garmentRepository.GetBySelection(silouhetteRepository.Get(selection.SilouhetteId), new Fabric(selection.FabricId), new Pattern(selection.PatternId), selectedET, closetGarments, wishGarments)); if (result != null) { foreach (MasterGarment garment in result) { finalResult.Add(new jsonGarment(garment)); } } return(Json(finalResult)); }
private WishList GetWishList(HttpContext httpContext, bool createIfNull) { string cookieValue = _httpContextAccessor.HttpContext.Request.Cookies[wishListSessionName]; WishList wishList = new WishList(); if (!string.IsNullOrEmpty(cookieValue)) { string wishListId = cookieValue; wishList = wishListContext.Find(wishListId); } else { if (createIfNull) { wishList = CreateNewWishList(httpContext); } } return(wishList); }
public static string addToWishList(string dealID) { if (!UserController.isLoggedIn()) { return "Please Login First."; } WishList wl = new WishList(); wl.DealID = Convert.ToInt16(dealID); wl.UserID = UserController.getCurrentUser().UserID; foreach(Deal wlI in DealsController.getWishList()){ if(wl.DealID == wlI.DealID){ return "This Item is alreay in your wishlist."; } } if (DealsController.saveWishListItem(wl)) { return "Successfully Added to wishlist."; } return "Oops! Something went wrong"; }
private void WishList(string wishListId, WishListBaseJsonResult result) { var response = this.WishListManager.GetWishList(this.CurrentStorefront, this.CurrentVisitorContext, wishListId); var wishList = new WishList(); if (response.ServiceProviderResult.Success && response.Result != null) { wishList = response.Result; } result.Initialize(wishList); result.SetErrors(response.ServiceProviderResult); }
/// <summary> /// Populates the stock information of the given wish list. /// </summary> /// <param name="storefront">The storefront.</param> /// <param name="wishList">The wish list.</param> protected virtual void PopulateStockInformation(CommerceStorefront storefront, WishList wishList) { var productList = wishList.Lines.Select(line => new CommerceInventoryProduct { ProductId = line.Product.ProductId, CatalogName = ((CommerceCartProduct)line.Product).ProductCatalog }).ToList(); var stockInfos = this.InventoryManager.GetStockInformation(storefront, productList, StockDetailsLevel.Status).Result; if (stockInfos == null) { return; } foreach (var line in wishList.Lines) { var stockInfo = stockInfos.ToList().FirstOrDefault(si => si.Product.ProductId.Equals(line.Product.ProductId, StringComparison.OrdinalIgnoreCase)); if (stockInfo == null) { continue; } line.Product.StockStatus = new Sitecore.Commerce.Entities.Inventory.StockStatus(Convert.ToInt32((decimal)stockInfo.Properties["OnHandQuantity"]), stockInfo.Status.Name); this.InventoryManager.VisitedProductStockStatus(storefront, stockInfo, string.Empty); } }
private void GivenAWishList() { _wishList = new WishList(); }
/// <summary> /// Initializes the specified wish list. /// </summary> /// <param name="wishList">The wish list.</param> public virtual void Initialize(WishList wishList) { if (wishList == null) { return; } this.Name = wishList.Name; this.IsFavorite = wishList.IsFavorite; this.ExternalId = wishList.ExternalId; foreach (var line in wishList.Lines) { this._lines.Add(new WishListItemBaseJsonResult(line, wishList.ExternalId)); } }
public static bool saveWishListItem(WishList item) { return dao.insertOrUpdate(item); }
partial void InsertWishList(WishList instance);
public bool insertOrUpdate(WishList item) { if (item.WishListItemID > 0) { return submitChanges(); } else { db.WishLists.InsertOnSubmit(item); return submitChanges(); } }
partial void UpdateWishList(WishList instance);
partial void DeleteWishList(WishList instance);
private void attach_WishLists(WishList entity) { this.SendPropertyChanging(); entity.User = this; }
public ActionResult AddToWishList(int id) { try { //Default message to user TempData["message"] = "This game is already on your wishlist!"; //Check if game is already in user's wishlist IQueryable<WishList> wishList = db.WishLists.Where(w => w.MemberId == CurrentMember.Id && w.GameId == id); if (wishList.Count() == 0) { //Add new wishlist item if user does not have one for this game TempData["message"] = "Game was added to your wishlist!"; WishList newWishList = new WishList(); newWishList.GameId = id; newWishList.MemberId = CurrentMember.Id; db.WishLists.Add(newWishList); db.SaveChanges(); } } catch (Exception e) { TempData["message"] = "Could not add to wish list: " + e.Message; } return RedirectToAction("Details", "Game", new { id = id }); }
public static ShoppingItem Load(WishList.WishListDSRow wishList) { ShoppingItem shoppingItem = new ShoppingItem(); shoppingItem.product = DatabaseUtility.Instance.GetProduct(wishList.product_id); shoppingItem.DurationInMonths = wishList.duration; shoppingItem.Quantity = wishList.quantity; shoppingItem.wishListItemId = wishList.wish_list_id; if(wishList.Isversion_idNull() == false) { shoppingItem.ProductVersion = ShoppingTrolley.Web.Objects.Product.GetVersion(wishList.version_id); } if (wishList.Isproduct_detail_idNull() == false) { shoppingItem.ProductDetail = ShoppingTrolley.Web.Objects.Product.GetProductDetail(wishList.product_detail_id); } return shoppingItem; }
protected void Page_PreRender(object sender, EventArgs e) { if (Session["Cart"] != null) { var oShoppingCart = new ShoppingCart(); var dt = oShoppingCart.Cart(); if (dt.Rows.Count == 0) { lblSummary.Text = "0"; } else { int quantity = 0; double Total = 0; //for (int i = 0; i < dt.Rows.Count; i++) //{ // quantity += int.Parse(dt.Rows[i]["Quantity"].ToString()); //} foreach (DataRow dr in dt.Rows) { var Quantity = Convert.ToInt32(string.IsNullOrEmpty(dr["Quantity"].ToString()) ? "0" : dr["Quantity"]); var Price = Convert.ToDouble(string.IsNullOrEmpty(dr["Price"].ToString()) ? 0 : dr["Price"]); Total += Quantity * Price; quantity += Quantity; } lblSummary.Text = quantity.ToString(); //lblTotalPrice.Text = string.Format("{0:##,###.##}", Total).Replace('.', '*').Replace(',', '.').Replace('*', ',') + "đ"; } } if (Session["IsLogin"] != null) { var oWishList = new WishList(); var dv = oWishList.WishListSelectAll("", "", Session["UserName"].ToString(), "", "", "", "").DefaultView; //lblWishList.Text = dv.Count.ToString(); } }
protected void lstProductHot_ItemCommand(object sender, ListViewCommandEventArgs e) { var item = e.Item as ListViewDataItem; var cmd = e.CommandName; var ProductOptionCategoryID = (item.FindControl("hdnProductOptionCategoryID2") as HiddenField).Value; var ProductOptionCategoryName = (item.FindControl("hdnProductOptionCategoryName2") as HiddenField).Value; var ProductID = (item.FindControl("hdnProductID2") as HiddenField).Value; var ProductName = (item.FindControl("lblProductName2") as Label).Text; var ProductNameEn = (item.FindControl("lblProductNameEn2") as Label).Text; var ImageName = (item.FindControl("hdnImageName2") as HiddenField).Value; var ProductCode = (item.FindControl("hdnProductCode2") as HiddenField).Value; var ProductLengthID = (item.FindControl("hdnProductLengthID2") as HiddenField).Value; var ProductLengthName = (item.FindControl("hdnProductLengthName2") as HiddenField).Value; var Quantity = "1"; double Price = Convert.ToDouble((item.FindControl("hdnPrice2") as HiddenField).Value); string ProductSizeColorID1 = ""; string QuantityList = ""; int SizeColorQuantity1 = 0; var oProductSizeColor = new ProductSizeColor(); if (cmd == "AddToCart") { if (ProductID != "" && ProductLengthID != "" && ProductLengthID != "") { var dv = oProductSizeColor.ProductSizeColorSelectAll(ProductLengthID, ProductOptionCategoryID, ProductID, "True", "True", "", "True").DefaultView; ProductSizeColorID1 = dv[0]["ProductSizeColorID"].ToString(); SizeColorQuantity1 = Convert.ToInt32(dv[0]["Quantity"].ToString()) - Convert.ToInt32(dv[0]["QuantitySale"].ToString()); for (int i = 1; i <= SizeColorQuantity1; i++) { QuantityList = QuantityList + i + ","; } } var oShoppingCart = new ShoppingCart(); oShoppingCart.CreateCart(ProductID, ImageName, ProductName, ProductNameEn, ProductCode, ProductOptionCategoryID, ProductOptionCategoryName, ProductLengthID, ProductLengthName, ProductSizeColorID1, Quantity, SizeColorQuantity1.ToString(), Price, false ); ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "runtime", "myconfirmPopup('" + "<strong>" + ProductName + " - " + ProductCode + " - " + ProductOptionCategoryName + "</strong><br/> đã được thêm vào giỏ hàng" + "')", true); } else if (cmd == "AddToWishList") { if (Session["UserName"] != null) { var oWishList = new WishList(); oWishList.WishListInsert1( ProductID, User.Identity.Name, "1", Price.ToString(), ImageName, ProductName, "", ProductCode, ProductOptionCategoryID, ProductOptionCategoryName, ProductLengthID, ProductLengthName, ProductSizeColorID1, "" ); } else Response.Redirect("~/Login.aspx?returnurl=" + Request.Url.AbsolutePath.Substring(Request.Url.AbsolutePath.LastIndexOf("/") + 1)); } }
private void detach_WishLists(WishList entity) { this.SendPropertyChanging(); entity.User = null; }