Пример #1
0
        private async void PostWishList()
        {
            if (WishList.Title == null || WishList.Title.Trim().Equals(""))
            {
                DisplayDialog("Invalid Wishlist name", "Please enter a Wishlist name");
                return;
            }
            else if (WishList.DateOfEvent < DateTime.Now)
            {
                DisplayDialog("Invalid Date", "Please enter a Date in the future");
                return;
            }
            string     wishListJson = JsonConvert.SerializeObject(this.WishList);
            HttpClient client       = new HttpClient();
            var        res          = await client.PostAsync("http://localhost:65172/api/wishlists/", new StringContent(wishListJson, System.Text.Encoding.UTF8, "application/json"));

            Debug.Write(res);
            if (res.Content != null)
            {
                string newWishListJson = await res.Content.ReadAsStringAsync();

                WishLists.Add(JsonConvert.DeserializeObject <WishList>(newWishListJson));
            }
            this._parent.CurrentData = new WishListsViewModel(this._parent);
        }
Пример #2
0
        public void ListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            WishList _wishList = (WishList)e.ClickedItem;

            this._parent.CurrentData = new WishListAccessingViewModel(WishLists.Where(val =>
                                                                                      val.WishListID == _wishList.WishListID).SingleOrDefault(), this._parent);
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("WishId,MemberId,GameId")] WishLists wishLists)
        {
            if (id != wishLists.WishId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(wishLists);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WishListsExists(wishLists.WishId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameId"]   = new SelectList(_context.Games, "GameId", "AvailablePlatforms", wishLists.GameId);
            ViewData["MemberId"] = new SelectList(_context.Members, "MemberId", "MemberId", wishLists.MemberId);
            return(View(wishLists));
        }
Пример #4
0
        public WishLists AddWishlist(int gameId, string memberId)
        {
            //New Wishlist created, supply wishid and memberid to it
            WishLists newWishList = new WishLists();

            newWishList.GameId   = gameId;
            newWishList.MemberId = memberId;

            return(newWishList);
        }
 public void ViewWishes()
 {
     if (WishList == null)
     {
         DisplayDialog();
         return;
     }
     this._parent.CurrentData = new WishListViewModel(WishLists.Where(val =>
                                                                      val.WishListID == WishList.WishListID).SingleOrDefault(), this._parent);
 }
Пример #6
0
        /// <summary>
        /// (콘텐트 뷰) 확인 버튼 (해당 상품 사이즈,수량 등을 웹 통신을 통한 저장)
        /// </summary>
        /// <param name="sender">확인 버튼</param>
        /// <param name="e"></param>
        private void Button_Clicked(object sender, EventArgs e) // ok
        {
            DateTime  dt   = DateTime.Now;
            string    date = "_" + dt.Year + dt.Month + dt.Day + dt.Hour + dt.Minute + dt.Second;
            WishLists wish = new WishLists()
            {
                Wish_ID    = Application.Current.Properties["cus_no"] + date,
                Cus_No     = int.Parse(Application.Current.Properties["cus_no"].ToString()),
                Stock_ID   = stock_id,
                Wish_count = int.Parse(Quantity.SelectedItem.ToString()),
                Wish_price = stock_price * int.Parse(Quantity.SelectedItem.ToString())
            };

            string json = JsonConvert.SerializeObject(wish);
            string url  = "http://jinweb2.azurewebsites.net/FrmInstWishList.aspx?wish_id=" + wish.Wish_ID + "&cus_no=" + wish.Cus_No + "&stock_id=" + wish.Stock_ID + "&wish_count=" +
                          wish.Wish_count + "&wish_price=" + wish.Wish_price;

            WebRequest   myRequest  = WebRequest.Create(url);
            WebResponse  myResponse = myRequest.GetResponse();
            StreamReader sr         = new StreamReader(myResponse.GetResponseStream());
            var          str        = sr.ReadToEnd();

            if (str.Equals("1"))
            {
                DependencyService.Get <IMessage>().Longtime("장바구니에 담겼습니다.");
            }
            else
            {
                DependencyService.Get <IMessage>().Longtime("오류 : 장바구니에 담기지 못했습니다.");
            }
            //using(HttpClient client = new HttpClient())
            //{
            //    StringContent content = new StringContent(json, Encoding.UTF8, "application/json");
            //    var request = new HttpRequestMessage()
            //    {
            //        RequestUri = new Uri(url),
            //        Method = HttpMethod.Post,
            //        Content = content
            //    };
            //    var response = client.SendAsync(request);

            //    //string dataResult = response.Content.ReadAsStringAsync().Result;
            //    //YOUR_RESULT_ENTITY result = JsonConvert.DeserializeObject<YOUR_RESULT_ENTITY>(dataResult);
            //    //return result;
            //}

            overlay.IsVisible  = false;
            Quantity.IsEnabled = false;

            //SizePicker.SelectedItem = null;
            //Quantity.SelectedItem = null;

            SizePicker.Items.Clear();
            Quantity.Items.Clear();
        }
Пример #7
0
        private void Initialize()
        {
            try { context.Entry(game).State = EntityState.Detached; }
            catch (Exception) { }

            wishlist = new WishLists()
            {
                WishId   = r.Next(),
                MemberId = "TestMemberId",
                GameId   = r.Next(),
                Game     = game,
            };
        }
Пример #8
0
        public async Task <IActionResult> Create([Bind("WishId,MemberId,GameId")] WishLists wishLists)
        {
            if (ModelState.IsValid)
            {
                _context.Add(wishLists);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameId"]   = new SelectList(_context.Games, "GameId", "AvailablePlatforms", wishLists.GameId);
            ViewData["MemberId"] = new SelectList(_context.Members, "MemberId", "MemberId", wishLists.MemberId);
            return(View(wishLists));
        }
Пример #9
0
        public async Task <IActionResult> Add(int Id)
        {
            var userId = _db.ApplicationUser.Where(m => m.UserName == User.Identity.Name).SingleOrDefault().Id;
            var game   = await _db.Games.Where(m => m.Id == Id).SingleOrDefaultAsync();

            WishLists wishList = new WishLists()
            {
                GameId            = Id,
                ApplicationUserId = userId
            };

            _db.Add(wishList);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index", "StoreFront", null));
        }
Пример #10
0
        public async void Send(object sender, RoutedEventArgs e)
        {
            if (Wishlistbox.SelectedItem == null)
            {
                ListErr.Text            = "You must select a wishlist!";
                Wishlistbox.BorderBrush = new SolidColorBrush(Colors.Red);
            }

            if (User.Text == null || User.Text == "")
            {
                UserErr.Text     = "Username cannot be empty";
                User.BorderBrush = new SolidColorBrush(Colors.Red);
            }

            if (Wishlistbox.SelectedItem != null && User.Text != null && User.Text != "")
            {
                int selectedWishlist = WishLists.First(wl => wl.Title == (String)Wishlistbox.SelectedItem).WishlistId;
                await wishListService.InvitePerson(selectedWishlist, User.Text);

                Frame.GoBack();
            }
        }