예제 #1
0
        private void OfferDeleted(int vmId)
        {
            var foundTicketOfferViewModel =
                Offers.FirstOrDefault(ticketOfferViewModel => ticketOfferViewModel.VmId == vmId);

            InvokeOnMainThread(() => Offers.Remove(foundTicketOfferViewModel));
        }
예제 #2
0
        public async Task Accept()
        {
            string     rating = "";
            RateWindow win    = new RateWindow();

            win.ShowDialog();
            rating = win.Rating;

            BuyOfferDto bOffer = new BuyOfferDto();

            bOffer.Id        = 0;
            bOffer.BuyerId   = _authenticationUser.UserId;
            bOffer.Price     = (decimal?)SelectedOffer.Price;
            bOffer.Amount    = SelectedOffer.Amount;
            bOffer.Name      = "a";
            bOffer.ProductId = SelectedOffer.ProductId;
            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                SellOfferDto   sellOffer   = createOffer(SelectedOffer);
                TransactionDto transaction = new TransactionDto();
                transaction.BuyOffer  = bOffer;
                transaction.SellOffer = sellOffer;
                if (rating == "")
                {
                    transaction.Rating = null;
                }
                else
                {
                    transaction.Rating = Convert.ToInt32(rating);
                }
                var json     = Newtonsoft.Json.JsonConvert.SerializeObject(transaction);
                var url      = new URLBuilder("/AcceptSellTransaction/");
                var request2 = new HttpRequestMessage()
                {
                    RequestUri = new Uri(url.URL),
                    Method     = HttpMethod.Post,
                    Content    = new StringContent(json,
                                                   Encoding.UTF8,
                                                   "application/json")
                };
                request2.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", _authenticationUser.UserId.ToString(), _authenticationUser.Password))));
                var response = await client.SendAsync(request2);

                if (!response.IsSuccessStatusCode)
                {
                    ErrorString = (string)Application.Current.FindResource("TransactionError");
                    return;
                }
                Offers.Remove(SelectedOffer);
            }
        }
        private void DropExistingOffer(Offer offer)
        {
            // Remove offer from local observable collection
            Offers.Remove(offer);

            // Open a database context and drop offer
            using (var ctx = new AssistantContext())
            {
                ctx.Offers.Attach(offer);
                ctx.Offers.Remove(offer);
                ctx.SaveChanges();
            }
        }
        public void RemoveUnavalaibleProducts() // в этом метода надо поменять логику
        //эти товары мне нужны, но их поля дают null =>  надо их заменить на заглушки
        // или все таки надо их убрать.
        {
            Console.WriteLine(Offers.Count);

            for (int i = 0; i < Offers.Count; i++)
            {
                //if (Offers[i].CategoryId == null || Offers[i].CategoryId == "" || Offers[i].CategoryId == " ")
                if (Offers[i].Availabe == "false")
                {
                    Offers.Remove(Offers[i]);
                }
            }
        }
예제 #5
0
        private Task RemoveOutdateOffers()
        {
            return(new Task(() => {
                while (removeOutdatedOffers)
                {
                    var outdatedOffers = Offers.Where(x => x.ValidTo < DateTime.Now);

                    for (int i = 0; i < outdatedOffers.Count(); i++)
                    {
                        Offers.Remove(outdatedOffers.ElementAt(i));
                    }

                    Thread.Sleep(500);
                }
                ;
            }));
        }
예제 #6
0
 public void DeleteOffer()
 {
     Manager.Instance.DeleteOffer(SelectedOffer.Id);
     Offers.Remove(SelectedOffer);
 }
예제 #7
0
 public void PromoteToDeal(Offer offerToRemove, Deal dealToAdd)
 {
     Offers.Remove(offerToRemove);
     CurrentDeals.Add(dealToAdd);
     dealToAdd.Offerer.Notifications.Add(new Notification(dealToAdd.Offerer, "Your offer for " + dealToAdd.Estate.Title + " has been accepted."));
 }