Exemplo n.º 1
0
        public static async Task <OfferBase> GetOfferLoaded(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(null);
            }

            var Url = new Uri(url);

            try
            {
                var x = Offers.Keys.SingleOrDefault(k => k.Contains(Url.Host));
                if (Offers.TryGetValue(Url.Host, out Type type))
                {
                    var offer = Activator.CreateInstance(type, new[] { url }) as OfferBase;
                    await offer.Load();

                    return(offer);
                }
            }
            catch
            {
            }

            return(null);
        }
Exemplo n.º 2
0
        public async Task Load()
        {
            using (var client = new HttpClient())
            {
                URLBuilder url = new URLBuilder(_filter, controler);
                url.URL += "&ShowMyOffers=false";
                var request = new HttpRequestMessage()
                {
                    RequestUri = new Uri(url.URL),
                    Method     = HttpMethod.Get
                };
                request.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(request);

                var contents = await response.Content.ReadAsStringAsync();

                List <SellOfferDto> result = JsonConvert.DeserializeObject <List <SellOfferDto> >(contents);
                Offers.Clear();
                foreach (SellOfferDto bo in result)
                {
                    SellOfferWrapper boffer = bo.createSellOffer();
                    Offers.Add(boffer);
                }
            }
        }
Exemplo n.º 3
0
        public void AddProduct(string name, int quantity = 0, double price = 0, int offerId = 0)
        {
            // Check if existing basket item using the product name as reference
            BasketItem basketItem = BasketItems.FirstOrDefault(item => item.ProductName == name);

            if (basketItem == null)
            {
                // Create new instance of Offer class with default parameters
                Offer linkedOffer = new Offer();
                // If offerId is not set, ignore discount and discount group
                if (offerId != 0)
                {
                    linkedOffer = Offers.Find(offer => offer.OfferId == offerId);
                }

                // if does not exist, instantiate new BasketItem with passed parameters
                BasketItem newProduct = new BasketItem(name, price, quantity, linkedOffer);
                BasketItems.Add(newProduct);
            }
            else
            {
                // If the product already exists in the basket, just increase the quantity
                basketItem.AddItems(quantity);
            }
        }
Exemplo n.º 4
0
        public async Task <ActionResult> DeleteCoupon(int Id)
        {
            int    liSuccess = 0;
            string lsMessage = string.Empty;

            if (Id > 0)
            {
                try
                {
                    Offers objOffers = Repository <Offers> .GetEntityListForQuery(x => x.id == Id).Item1.FirstOrDefault();

                    objOffers.IsDeleted = true;
                    await Repository <Offers> .UpdateEntity(objOffers, (entity) => { return(entity.id); });

                    TempData["SuccessMsg"] = "Coupon has been deleted successfully";
                }
                catch (Exception ex)
                {
                    TempData["ErrorMsg"] = "Something wrong!! Please try after sometime";
                }
            }

            return(this.Json(new OffersViewModel {
                id = liSuccess
            }));
        }
Exemplo n.º 5
0
        private CrossSellViewModel MakeCrossSellViewModel(Offers offers, string shoppingCartLink)
        {
            if (offers == null || offers.Offer == null || offers.Offer.Length == 0)
            {
                return(null);
            }
            var offerViewModels = new List <CrossSellOfferViewModel>();

            foreach (var offer in offers.Offer)
            {
                var offerViewModel = OfferToCrossSellOfferViewModel(offer);
                offerViewModels.Add(offerViewModel);
                if (offerViewModel.ProductOffersOfferViewModels == null || offerViewModel.ProductOffersOfferViewModels.Length == 0)
                {
                    continue;
                }
                foreach (var productOfferViewModel in offerViewModel.ProductOffersOfferViewModels)
                {
                    productOfferViewModel.AddToCartLink = MakeAddToCartLink(productOfferViewModel.Product.Id, offer.Id, shoppingCartLink);
                    productOfferViewModel.ProductLink   =
                        _linkGenerator.GenerateProductLink(productOfferViewModel.Product.Id);
                }
            }
            return(new CrossSellViewModel
            {
                Offers = offerViewModels
            });
        }
Exemplo n.º 6
0
 public bool Equals(Product other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(ProductExId == other.ProductExId &&
            VendorId == other.VendorId &&
            VendorCode == other.VendorCode &&
            Name == other.Name
            //&& Description == other.Description
            && Batteries == other.Batteries &&
            Pack == other.Pack &&
            Material == other.Material &&
            Length == other.Length &&
            Diameter == other.Diameter &&
            CategoryId == other.CategoryId &&
            Function == other.Function &&
            AddFunction == other.AddFunction &&
            Vibration == other.Vibration &&
            Volume == other.Volume &&
            ModelYear == other.ModelYear &&
            VendorCountry == other.VendorCountry &&
            !Offers.Except(other.Offers).Any());
 }
Exemplo n.º 7
0
 //This is repsonsible for completing a transaction
 public Trade(ref Bids bid, ref Offers offer, long quanity)
 {
     UpdateQuanities(ref bid, ref offer, quanity);
     MoneyTransaction(ref bid, ref offer, quanity);
     UpdateDatabase(ref bid, ref offer, quanity);
     AddToTransactionList(ref bid, ref offer, quanity);
 }
Exemplo n.º 8
0
 void MoneyTransaction(ref Bids bid, ref Offers offer, long quanity)
 {
     //if (bid.Price != offer.Price) {
     //    Console.WriteLine("Bid Price and Offer Price not the same!");
     //}
     _TradePrice = bid.Price;
 }
    protected void gvOfferDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Offers       oOffers   = new Offers();
        OffersBLogic oOffersBL = new OffersBLogic();

        Label   tmpofferId    = (Label)gvOfferDetails.Rows[e.RowIndex].FindControl("lblEditoffferID");
        TextBox tmpEOfferText = (TextBox)gvOfferDetails.Rows[e.RowIndex].FindControl("txtEditOfferText");
        TextBox tmpEOfferlink = (TextBox)gvOfferDetails.Rows[e.RowIndex].FindControl("txtEditOfferLink");
        TextBox tmpEValidity  = (TextBox)gvOfferDetails.Rows[e.RowIndex].FindControl("txtEditValidity");

        if (tmpofferId != null)
        {
            oOffers.OfferID   = tmpofferId.Text;
            oOffers.OfferText = tmpEOfferText.Text;
            oOffers.OfferLink = tmpEOfferlink.Text;
            oOffers.Validity  = int.Parse(tmpEValidity.Text);
            oOffersBL.UpdateOffer(oOffers);

            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "<script> alert('Record Updated Successfully.')</script>", false);
            pnlAdd.Visible = true;

            //Rebind the latest data
            gvOfferDetails.EditIndex = -1;
            BindOfferGrid();
        }
    }
Exemplo n.º 10
0
        public async Task <IActionResult> Register(Offers Offers)
        {
            var OfferWithSameName = _dbContext.Offers.SingleOrDefault(u => u.OfferName == Offers.OfferName);

            if (OfferWithSameName != null)
            {
                return(BadRequest("Offer with this name already exists"));
            }
            var OffersObj = new Offers
            {
                OfferID          = Guid.NewGuid(),
                Active           = Offers.Active,
                ItemID           = Offers.ItemID,
                OfferCode        = Offers.OfferCode,
                OfferDescription = Offers.OfferDescription,
                OfferName        = Offers.OfferName,
                Offertype        = Offers.Offertype,
                Price            = Offers.Price
            };

            _dbContext.Offers.Add(OffersObj);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(StatusCodes.Status201Created));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Retrieves the best 70 offers (per side) on the offer book.
        /// </summary>
        /// <param name="blockchain"></param>
        /// <param name="pair"></param>
        /// <param name="contractHash"></param>
        /// <returns></returns>
        public async Task <List <Offers> > GetOffers(string pair, string blockchain = null, string contractHash = null)
        {
            if (string.IsNullOrEmpty(blockchain))
            {
                blockchain = Blockchain;
            }
            if (string.IsNullOrEmpty(contractHash))
            {
                contractHash = ContractHash;
            }
            if (string.IsNullOrEmpty(pair))
            {
                throw new ArgumentNullException(nameof(pair));
            }

            var query = HttpUtility.ParseQueryString(string.Empty);

            query["blockchain"]    = blockchain;
            query["pair"]          = pair;
            query["contract_hash"] = contractHash;
            string queryString = query.ToString().Insert(0, "?");
            var    result      = await ExecuteCall(Utils.ComposeUrl(getOffers, queryString));

            return(Offers.FromJson(result));
        }
Exemplo n.º 12
0
        private void OfferDeleted(int vmId)
        {
            var foundTicketOfferViewModel =
                Offers.FirstOrDefault(ticketOfferViewModel => ticketOfferViewModel.VmId == vmId);

            InvokeOnMainThread(() => Offers.Remove(foundTicketOfferViewModel));
        }
Exemplo n.º 13
0
        public ActionResult CreateOffer()
        {
            Offers offer = new Offers();

            offer.OfferExpirationDate = DateTime.Now;
            return(View(offer));
        }
Exemplo n.º 14
0
        public ServiceResult Add(Offers offer, List <OfferDetail> offerDetails, Guid id)
        {
            //todo: login olana göre güncellenecek
            string password = "******";
            var    sorgu    = (from m in _uow.GetRepository <Members>().GetQuery(m => m.Password == password) select m.MemberId);
            Guid   memberId = (Guid)sorgu.First();

            offer.TaskId      = id;
            offer.OfferId     = Guid.NewGuid();
            offer.MemberId    = memberId;
            offer.IsCancelled = false;

            _uow.GetRepository <Offers>().Add(offer);

            foreach (OfferDetail offerDetail in offerDetails)
            {
                offerDetail.OfferDetailId = Guid.NewGuid();
                offerDetail.OffreId       = offer.OfferId;
                _uow.GetRepository <OfferDetail>().Add(offerDetail);
            }

            int ess = _uow.Save();

            if (ess > 0)
            {
                return(new ServiceResult("Kayıt başarılıdır.", ResultState.Success));
            }
            return(new ServiceResult("Bir hata nedeniyle kayıt gerçekleşmedi.", ResultState.Error));
        }
Exemplo n.º 15
0
        public void ProRata(ref Bids bid, ref List <Offers> offers, int ProRataMinimumAlloaction)
        {
            long TotalQuanityOfOffers = 0;
            long BidQuanity           = bid.Quanity;

            foreach (Offers o in offers)
            {
                TotalQuanityOfOffers += o.Quanity;
            }
            for (int i = 0; i < offers.Count; i++)
            {
                offers[i].ProRata = (float)offers[i].Quanity / (float)TotalQuanityOfOffers;
                int ProRataAmount = (int)(offers[i].ProRata * BidQuanity);
                if (ProRataAmount >= ProRataMinimumAlloaction)
                {
                    if (ProRataAmount > offers[i].Quanity)
                    {
                        Offers o2 = offers[i];
                        new Trade(ref bid, ref o2, offers[i].quanity);
                        offers[i] = o2;
                    }
                    else
                    {
                        Offers o2 = offers[i];
                        new Trade(ref bid, ref o2, ProRataAmount);
                        offers[i] = o2;
                    }
                }
            }
        }
Exemplo n.º 16
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Title,ReleaseDate,Genre,Price")] Offers offers)
        {
            if (id != offers.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(offers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OffersExists(offers.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(offers));
        }
Exemplo n.º 17
0
 // РЕЗУЛЬТАТ ОТ НАЖАТИЯ КНОПКИ "ОТКАЗАТЬ"
 public ActionResult Refuse(int IdOffer, Offers ss)
 {
     ss         = repository2.GetAll().FirstOrDefault(r => r.OfferId == IdOffer);
     ss.StateId = 2;
     repository2.Update(ss);
     return(RedirectToAction("OffersFrom", "Client"));
 }
Exemplo n.º 18
0
        public async Task <IActionResult> Create([Bind("Title,Slug,Image,ImageContent,ImageFile,ImageContentFile,Description,ExpiredAt,FriendRewardType,FriendRewardAmount,FriendRewardIsPercent,FriendRewardExpiredAt,FanRewardType,FanRewardAmount,FanRewardLabel,FanRuleMinReferral,MerchantsId,OfferCategoriesId,Id,CreatedAt,UpdatedAt")] Offers offers)
        {
            if (ModelState.IsValid)
            {
                // Upload image to www/root
                if (offers.ImageFile != null)
                {
                    offers.Image = UploadImages(offers.ImageFile);
                }
                if (offers.ImageContentFile != null)
                {
                    offers.ImageContent = UploadImages(offers.ImageContentFile);
                }

                // Generate slug
                offers.Slug = _helper.GenerateSlug(offers.Title);

                // Insert data
                _context.Add(offers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MerchantsId"]       = new SelectList(_context.Merchants, "Id", "Id", offers.MerchantsId);
            ViewData["OfferCategoriesId"] = new SelectList(_context.OfferCategories, "Id", "Id", offers.OfferCategoriesId);
            return(View(offers));
        }
Exemplo n.º 19
0
        public Auction ToAuction(IAuctionRepository auctionRepository, bool offersFromDb = true, bool productsFromDb = true)
        {
            List <Offer> offerList;

            if (!offersFromDb)
            {
                offerList = Offers.Select(offerJson => offerJson.ToOffer(auctionRepository)).ToList();
            }
            else
            {
                offerList = auctionRepository.Find(Id).Offers.ToList();
            }

            List <Product> productList;

            if (!productsFromDb)
            {
                productList = Products.Select(productJson => productJson.ToProduct()).ToList();
            }
            else
            {
                productList = auctionRepository.Find(Id).Products.ToList();
            }

            return(new Auction
            {
                Id = Id,
                Products = productList,
                Description = Description,
                Owner = Owner.ToUser(),
                Offers = offerList,
                CreationDate = CreationDate
            });
        }
Exemplo n.º 20
0
        public async Task <IActionResult> AddOffers(Offers model)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            ViewBag.UserId = userId;
            if (string.IsNullOrEmpty(model.OffersText))
            {
                _notification.AddErrorToastMessage("مقادیر را پر کنید");
                ViewBag.Error = "پیشنهاد نمی تواند خالی باشد";
                return(View("Offers", model));
            }
            var offers = new Offers()
            {
                OffersText  = model.OffersText,
                UserId      = userId,
                CreatedTime = DateTime.Now
            };
            await _db.OffersRepository.InsertAsync(offers);

            await _db.SaveChangeAsync();

            _notification.AddSuccessToastMessage("پیشنهاد شما ثبت شد");
            ViewBag.Success = "<h2 style='text - align: center; padding: 10px; background: #1b1be1a6; color: white;border-radius: 10px;'>پیشنهاد شما ثبت شد با تشکر</h2>";
            return(View("Offers"));
        }
        public async Task <IActionResult> PutOffers([FromRoute] int id, [FromBody] Offers offers)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != offers.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 22
0
        public void WhenISelectThePurposeOfTheLoan()
        {
            Offers op = new Offers(driver);

            driver.Manage().Window.Maximize();
            op.SelectpurposeoftheLoan();
        }
Exemplo n.º 23
0
        public void ThenThePageNavigatesToTheLoansWebsite()
        {
            Offers op = new Offers(driver);

            op.VerifyAmigo();
            driver.Quit();
        }
Exemplo n.º 24
0
        public Station(XElement station)
            : base(station)
        {
            this._orders = new ObservableCollection <XElement>();
            this._offers = new ObservableCollection <XElement>();
            this._crew   = new ObservableCollection <CMember>();

            IEnumerable <XElement> crewquery =
                from crew in this.Data.Descendants().Elements("component")
                where (string)crew.Attribute("class") == "npc"
                select crew;

            foreach (XElement person in crewquery)
            {
                Crew.Add(new CMember(person));
            }

            foreach (XElement order in this.Data.Elements("trade").Elements("orders").Elements("trade"))
            {
                Orders.Add(order);
            }

            foreach (XElement offer in this.Data.Elements("trade").Elements("offers").Descendants <XElement>().Elements("trade"))
            {
                Offers.Add(offer);
            }
        }
        private OfferListViewModel OffersToOfferListViewModel(OfferListPart offerListPart, Offers offers)
        {
            var offerListViewModel = new OfferListViewModel { Title = offerListPart.Title };
            if (offers == null || offers.Offer == null)
                return offerListViewModel;

            var offer = offers.Offer.FirstOrDefault(o => o.ProductOffers != null && o.ProductOffers.ProductOffer != null && o.ProductOffers.ProductOffer.Length > 0) ??
                        offers.Offer[0];
            offerListViewModel.Title = offerListPart.Title;
            offerListViewModel.Id = offer.Id;
            offerListViewModel.Name = offer.Name;
            offerListViewModel.Type = offer.Type;
            offerListViewModel.Image = offer.Image;
            offerListViewModel.SalesPitch = offer.SalesPitch;
            if (offer.ProductOffers == null || offer.ProductOffers.ProductOffer == null)
                return offerListViewModel;

            if (offer.ProductOffers.ProductOffer.Length > offerListPart.MaxNProducts)
            {
                var limitedProductOffers = new ProductOffer[offerListPart.MaxNProducts];
                for (var i = 0; i < offerListPart.MaxNProducts; i++)
                    limitedProductOffers[i] = offer.ProductOffers.ProductOffer[i];
                offerListViewModel.ProductOfferViewModels = limitedProductOffers.Select(po => ProductOfferToProductOfferViewModel(offer.Id, po)).ToArray();
            }
            else
                offerListViewModel.ProductOfferViewModels = offer.ProductOffers.ProductOffer.Select(po => ProductOfferToProductOfferViewModel(offer.Id, po)).ToArray();
            return offerListViewModel;
        }
Exemplo n.º 26
0
        public async Task <int> UpdateOffersAsync(Offers Offers)
        {
            _dataContext.Offers.Update(Offers);
            var Updated = await _dataContext.SaveChangesAsync();

            return(Updated);
        }
Exemplo n.º 27
0
        async Task ExecuteLoadItemsCommand(int?categoryId = null)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Offers.Clear();

                var items = await DataStore.GetItemsAsync(true, categoryId);

                foreach (var item in items)
                {
                    Offers.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 28
0
        public void ResetFilter(bool applyToOutgoing = true)
        {
            log.Trace($"Resetting filter {(applyToOutgoing ? "Outgoing" : "Incoming")} offers");
            if (applyToOutgoing)
            {
                if (_outgoingOffers != null)
                {
                    OutgoingOffers.Clear();

                    foreach (var offer in _outgoingOffers)
                    {
                        OutgoingOffers.Add(offer);
                    }
                }
            }
            else
            {
                if (_offers != null)
                {
                    Offers.Clear();

                    foreach (var offer in _offers)
                    {
                        Offers.Add(offer);
                    }
                }
            }
        }
Exemplo n.º 29
0
        private Offer GetActiveOffer()
        {
            log.Trace("Getting active offer");
            var offer = Offers.FirstOrDefault(o => o.TradeRequestSent);

            return(offer == null?OutgoingOffers.FirstOrDefault(o => o.TradeRequestSent) : offer);
        }
Exemplo n.º 30
0
        public Offer GetOffer(int id)
        {
            log.Trace($"Getting offer {id}");
            var offer = Offers.FirstOrDefault(e => e.Id == id);

            return(offer == null?OutgoingOffers.FirstOrDefault(e => e.Id == id) : offer);
        }
Exemplo n.º 31
0
        private void btnOfferChange(object sender, RoutedEventArgs e)
        {
            Offers xOffers = new Offers();

            xOffers.Owner = this;
            xOffers.Show();
        }
 private CrossSellViewModel MakeCrossSellViewModel(Offers offers, string shoppingCartLink)
 {
     if (offers == null || offers.Offer == null || offers.Offer.Length == 0)
         return null;
     var offerViewModels = new List<CrossSellOfferViewModel>();
     foreach (var offer in offers.Offer)
     {
         var offerViewModel = OfferToCrossSellOfferViewModel(offer);
         offerViewModels.Add(offerViewModel);
         if (offerViewModel.ProductOffersOfferViewModels == null || offerViewModel.ProductOffersOfferViewModels.Length == 0) continue;
         foreach (var productOfferViewModel in offerViewModel.ProductOffersOfferViewModels)
         {
             productOfferViewModel.AddToCartLink = MakeAddToCartLink(productOfferViewModel.Product.Id, offer.Id, shoppingCartLink);
             productOfferViewModel.ProductLink =
                 _linkGenerator.GenerateProductLink(productOfferViewModel.Product.Id);
         }
     }
     return new CrossSellViewModel
     {
         Offers = offerViewModels
     };
 }