Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
Ejemplo n.º 1
0
        public IEnumerable<WinningBid> GenerateNextSequenceOfBidsAfter(Offer offer, WinningBid currentWinningBid)
        {
            var bids = new List<WinningBid>();

            if (currentWinningBid.MaximumBid.IsGreaterThanOrEqualTo(offer.MaximumBid))
            {
                var bidFromOffer = new WinningBid(offer.Bidder, offer.MaximumBid, offer.MaximumBid, offer.TimeOfOffer);
                bids.Add(bidFromOffer);

                bids.Add(CalculateNextBid(bidFromOffer, new Offer(currentWinningBid.Bidder, currentWinningBid.MaximumBid, currentWinningBid.TimeOfBid)));               
            }
            else
            {
                if (currentWinningBid.HasNotReachedMaximumBid())
                {
                    var currentBiddersLastBid = new WinningBid(currentWinningBid.Bidder, currentWinningBid.MaximumBid, currentWinningBid.MaximumBid, currentWinningBid.TimeOfBid);
                    bids.Add(currentBiddersLastBid);

                    bids.Add(CalculateNextBid(currentBiddersLastBid, offer));                   
                }
                else
                    bids.Add(new WinningBid(offer.Bidder, currentWinningBid.CurrentAuctionPrice.BidIncrement(), offer.MaximumBid, offer.TimeOfOffer));
            }

            return bids;
        }
Ejemplo n.º 2
0
    public static void LogOffer(Offer offer)
    {
        System.Console.WriteLine ("-------------------");

        System.Console.WriteLine ("Offer : " + offer.Reference);

        System.Console.WriteLine ("Features : "+offer.Features.Count);
        foreach (var feature in offer.Features)
        {
            LogFeature(feature);
        }

        System.Console.WriteLine("Resources : "+offer.Resources.Count);
        foreach(var res in offer.Resources)
        {
            LogResource(res);
        }

        System.Console.WriteLine("Offer bundles : "+offer.BundlesReferences.Count);
        foreach(var bdl in offer.BundlesReferences)
        {
            System.Console.WriteLine("Bundle : "+bdl);
        }

        System.Console.WriteLine("Offer additional parameters : "+offer.AdditionalParameters.Keys.Count);
        foreach(var param in offer.AdditionalParameters.Keys)
        {
            System.Console.WriteLine("Parameter : " + param + " = " + offer.AdditionalParameters[param]);
        }

        System.Console.WriteLine ("-------------------");
    }
        public IHttpActionResult CreateOffer(OfferInputModel offerInput)
        {
            if (offerInput == null)
            {
                return this.BadRequest("Invalid Offer data");
            }

            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(ModelState);
            }

            var currentUserId = this.User.Identity.GetUserId();

            var offer = new Offer()
            {
                Title = offerInput.Title,
                Description = offerInput.Description,
                Price = offerInput.InitialPrice,
                ExppirationDate = offerInput.ExpirationDate,
                PublishedOn = DateTime.Now,
                UserSellerId = currentUserId
            };

            this.Data.Offers.Add(offer);
            this.Data.SaveChanges();

            return this.CreatedAtRoute(
                "DefaultApi",
                new { id = offer.Id },
                new { offer.Id, Seller = this.User.Identity.GetUserName(), Message = "Offer created" }
                );
        }
        public void ShowOffer(Offer offer)
        {
            textBoxOfferName.Text = offer.Name;
            textBoxOfferTeaser.Text = offer.Teaser;
            textBoxOfferPrice.Text = offer.Price;

        }
Ejemplo n.º 5
0
        public void AddOffer(Offer offer)
        {
            if (offer.SellPrice < offer.Product.BuyPrice)
            {
                throw new InvalidOperationException();
            }

            offers.Add(offer);
        }
Ejemplo n.º 6
0
        public static void Add(Offer offre)
        {
            using (ApplicationDbContext db = new ApplicationDbContext())
            {

                db.Offers.Add(offre);
                db.SaveChanges();
            }
        }
        public EditOfferWindow(Offer offer)
        {
            InitializeComponent();
            _offer = offer;
            _offerController = new OfferController(_offer);
            

            ShowOffer(_offer);
        }
Ejemplo n.º 8
0
        private WinningBid CalculateNextBid(WinningBid winningbid, Offer offer)
        {
            WinningBid bid;

            if (winningbid.CanBeExceededBy(offer.MaximumBid))
                bid = new WinningBid(offer.Bidder, offer.MaximumBid, winningbid.CurrentAuctionPrice.BidIncrement(), offer.TimeOfOffer);
            else
                bid = new WinningBid(offer.Bidder, offer.MaximumBid, offer.MaximumBid, offer.TimeOfOffer);

            return bid;
        }
    public void SetOffer(Offer offer)
    {
        title.text = offer.GetName();
        type.text = "Type: " + offer.GetType();
        points.text = Convert.ToString(offer.GetPoints());

        if(offer.GetTier() != null) {
            tier.text = "Tier: " + offer.GetTier();
        }

        StartCoroutine (DownloadImage (offer.GetLogo()));
    }
Ejemplo n.º 10
0
 public static int AddOffer(Offer offer)
 {
     return SQLDataAccess.ExecuteScalar<int>("[Catalog].[sp_AddOffer]", CommandType.StoredProcedure,
                                   new SqlParameter("@ProductID", offer.ProductId),
                                   new SqlParameter("@ArtNo", offer.ArtNo),
                                   new SqlParameter("@Amount", offer.Amount),
                                   new SqlParameter("@Price", offer.Price),
                                   new SqlParameter("@SupplyPrice", offer.SupplyPrice),
                                   new SqlParameter("@ColorID", offer.ColorID ?? (object)DBNull.Value),
                                   new SqlParameter("@SizeID", offer.SizeID ?? (object)DBNull.Value),
                                   new SqlParameter("@Main", offer.Main));
 }
Ejemplo n.º 11
0
 public static Offer CreateNewOffer( decimal price, ItemAvailability availability, ItemCondition itemCondition )
 {
     var result = new Offer {
     Id = Guid.NewGuid(),
     Availability = availability,
     Condition = itemCondition,
     Currency = "USD",
     Price = price,
     PriceValidityStartDate = System.DateTime.Now,
     PriceValidityEndDate = System.DateTime.Now.AddYears( 100 )
       };
       return result;
 }
Ejemplo n.º 12
0
        public Banner(Offer offer)
        {
            this.Type = offer.Type;
            this.lp = offer.lp;

            this.category = offer.category;
            this.revenuetype = offer.revenuetype;
            this.revenuevalue = offer.revenuevalue;
            this.payouttype = offer.payouttype;
            this.payoutvalue = offer.payoutvalue;
            this.active = offer.active;
            this.staticvalues = offer.staticvalues;
            this.offername = offer.offername;
        }
Ejemplo n.º 13
0
 public OfferViewModel(Offer offer)
 {
     this.Type = offer.Type;
     this.active = offer.active;
     this.advertiserId = offer.advertiser.advertiserid;
     this.categoryId = offer.category.categoryID;
     this.lp = offer.lp;
     this.offerID = offer.offerID;
     this.offername = offer.offername;
     this.payouttypeId = offer.payouttype.dealID;
     this.payoutvalue = offer.payoutvalue;
     this.revenuetypeId = offer.revenuetype.dealID;
     this.revenuevalue = offer.revenuevalue;
     this.staticvalues = offer.staticvalues;
 }
    public void OnPopulateOffers(Offer[] offers)
    {
        int childCount = rewardsGrid.transform.childCount;
        for (int i = childCount - 1; i >= 0; i--) {
            Debug.Log("Deleting i: " + i);
            GameObject.DestroyImmediate(rewardsGrid.transform.GetChild(i).gameObject);
        }

        for (int i = 0; i < offers.Length; i++) {
            Offer offer = offers[i];
            RewardObject rewardGO = (RewardObject) GameObject.Instantiate(rewardObjectPrefab);
            rewardGO.transform.SetParent(rewardsGrid.transform);
            rewardGO.transform.localScale = Vector3.one;
            rewardGO.SetOffer(offer);
        }
    }
Ejemplo n.º 15
0
        public void MakeOffer(Guid propertyId, decimal price, Guid ownerId)
        {
            var property = _propertyRepository.Get(propertyId);
            if(property == null) throw new ArgumentNullException("Cant find property");

            var user = _userRepository.Get(ownerId);

            var offer = new Offer();
            offer.Owner = user;
            offer.OfferedPrice = price;
            offer.Property = property;
            offer.Status = EStatus.Pending;

            _offerRepository.SaveOrUpdate(offer);
            _offerRepository.DbContext.CommitChanges();
        }
Ejemplo n.º 16
0
        public void Bid(Guid auctionId, Guid memberId, decimal amount)
        {            
            using (DomainEvents.Register(OutBid()))
            using (DomainEvents.Register(BidPlaced()))
            {                    
                var member = _memberService.GetMember(memberId);

                if (member.CanBid)
                { 
                    var auction = _auctions.FindBy(auctionId);

                    var bidAmount = new Money(amount);

                    var offer = new Offer(memberId, bidAmount, _clock.Time());

                    auction.PlaceBidFor(offer, _clock.Time());
                }                    
            }                      
        }
Ejemplo n.º 17
0
 public void PrintOffer(O2GOfferTableRow offerRow, string sInstrument)
 {
     Offer offer;
     if (mOffers.FindOffer(offerRow.OfferID, out offer))
     {
         if (offerRow.isTimeValid && offerRow.isBidValid && offerRow.isAskValid)
         {
             offer.Date = offerRow.Time;
             offer.Bid = offerRow.Bid;
             offer.Ask = offerRow.Ask;
         }
     }
     else
     {
         offer = new Offer(offerRow.OfferID, offerRow.Instrument,
                         offerRow.Digits, offerRow.PointSize, offerRow.Time,
                         offerRow.Bid, offerRow.Ask);
         mOffers.AddOffer(offer);
     }
     if (string.IsNullOrEmpty(sInstrument) || offerRow.Instrument.Equals(sInstrument))
     {
         Console.WriteLine("{0}, {1}, Bid={2}, Ask={3}", offer.OfferID, offer.Instrument, offer.Bid, offer.Ask);
     }
 }
Ejemplo n.º 18
0
        /// <summary>
        /// This method will send a confirmation mail to both players in a match
        /// </summary>
        /// <param name="offer"></param>
        private void SendMatchConfirmation(Offer offer)
        {
            var fbContext = FacebookWebContext.Current;
            var tennisUsers = ModelUtils.GetTennisUsers(this.DB);
            TennisUserModel tennisUser1 = tennisUsers.Where(u => u.FacebookId == offer.FacebookId).FirstOrDefault();
            TennisUserModel tennisUser2 = tennisUsers.Where(u => u.FacebookId == offer.AcceptedById).FirstOrDefault();

            string location = OfferModel.GetLocationLink(LocationModel.Create(offer));

            Dictionary<string, string> tokens = new Dictionary<string, string>();
            tokens.Add("FacebookId1", tennisUser1.FacebookId.ToString());
            tokens.Add("Rating1", IndexModel.FormatRating(tennisUser1.Rating));
            tokens.Add("Name1", tennisUser1.Name.ToString());
            tokens.Add("FacebookId2", tennisUser2.FacebookId.ToString());
            tokens.Add("Rating2", IndexModel.FormatRating(tennisUser2.Rating));
            tokens.Add("Name2", tennisUser2.Name.ToString());

            tokens.Add("Date", IndexModel.FormatLongDate(offer.MatchDateUtc, tennisUser1.TimeZoneOffset));
            tokens.Add("Location", location);
            tokens.Add("Comments", offer.Message);
            tokens.Add("OfferId", offer.OfferId.ToString());

            string subject = string.Format("TennisLoop: Match Scheduled and Confirmed");
            string template = Server.MapPath("/content/matchaccepted.htm");

            SendMessage(new long[] { tennisUser1.FacebookId, tennisUser2.FacebookId }, subject, template, tokens);
        }
Ejemplo n.º 19
0
        public void Test_Offer_CRUD()
        {
            #region Arrange
            var tmpCustomer = new CustomerConnector().Create(new Customer()
            {
                Name = "TmpCustomer", CountryCode = "SE", City = "Testopolis"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", Type = ArticleType.Stock, PurchasePrice = 100
            });
            #endregion Arrange

            IOfferConnector connector = new OfferConnector();

            #region CREATE
            var newOffer = new Offer()
            {
                Comments       = "TestOrder",
                CustomerNumber = tmpCustomer.CustomerNumber,
                OfferDate      = new DateTime(2019, 1, 20), //"2019-01-20",
                OfferRows      = new List <OfferRow>()
                {
                    new OfferRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10
                    },
                    new OfferRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20
                    },
                    new OfferRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 15
                    }
                }
            };

            var createdOffer = connector.Create(newOffer);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestOrder", createdOffer.Comments);
            Assert.AreEqual("TmpCustomer", createdOffer.CustomerName);
            Assert.AreEqual(3, createdOffer.OfferRows.Count);

            #endregion CREATE

            #region UPDATE

            createdOffer.Comments = "UpdatedTestOrder";

            var updatedOffer = connector.Update(createdOffer);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestOrder", updatedOffer.Comments);

            #endregion UPDATE

            #region READ / GET

            var retrievedOffer = connector.Get(createdOffer.DocumentNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestOrder", retrievedOffer.Comments);

            #endregion READ / GET

            #region DELETE
            //Not allowed
            #endregion DELETE

            #region Delete arranged resources
            new CustomerConnector().Delete(tmpCustomer.CustomerNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            #endregion Delete arranged resources
        }
Ejemplo n.º 20
0
 public bool deleteOffer(Offer offer)
 {
     if (offers.Exists(o => o.Id == offer.Id))
     {
         int temp = offers.IndexOf(offers.Single(o => o.Id == offer.Id));
         offers.RemoveAt(temp);
         offer.delete();
         if (onOffersChangeHandler != null)
             onOffersChangeHandler();
         return true;
     }
     else
         return false;
 }
Ejemplo n.º 21
0
        public ActionResult CreateOffer(DateTime date, long[] locations, string courtData, string comments, long? opponentId)
        {
            var fbContext = FacebookWebContext.Current;

            TennisUserModel tennisUser = ModelUtils.GetTennisUsers(this.DB).Where(u => u.FacebookId == fbContext.UserId).FirstOrDefault();

            if (null != tennisUser)
            {
                List<long> pushIds = new List<long>();
                Court court = ProcessCourtData(courtData);

                if (!string.IsNullOrEmpty(courtData))
                {
                    CourtJson courtJson = JsonSerializer.Current.DeserializeObject<CourtJson>(courtData);

                    if (null != courtJson && !string.IsNullOrEmpty(courtJson.name))
                    {
                        court = this.DB.Court.Where(c => c.CourtId == courtJson.GuidId).FirstOrDefault();

                        if (null == court)
                        {
                            court = new Court();
                            court.CourtId = courtJson.GuidId;
                            court.Name = courtJson.name;
                            court.Latitude = courtJson.latitude;
                            court.Longitude = courtJson.longitude;

                            this.DB.Court.InsertOnSubmit(court);
                        }
                    }
                }

                //Add the entry, send out the messages
                Offer offer = new Offer();
                offer.OfferId = Guid.NewGuid();
                offer.FacebookId = tennisUser.FacebookId;
                offer.MatchDateUtc = IndexModel.GetUtcDate(date, tennisUser.TimeZoneOffset);
                offer.PostDateUtc = DateTime.UtcNow;
                offer.Message = comments;
                offer.PreferredLocationId = tennisUser.City.LocationId;
                offer.Court = court;
                // BUGBUG: we dont' seem to set the completed flag anywhere currently
                offer.Completed = false;

                User opponent = null;

                if (opponentId.HasValue && opponentId.Value != 0)
                {
                    opponent = this.DB.User.Where(u => u.FacebookId == opponentId.Value).FirstOrDefault();
                }

                if (null != opponent)
                {
                    offer.SpecificOpponentId = opponent.FacebookId;
                    pushIds.Add(opponent.FacebookId);
                }
                else
                {
                    var tennisUsers = ModelUtils.GetTennisUsers(this.DB);
                    var matchUsers = tennisUsers.Where
                    (u =>
                        this.DB.CoordinateDistanceMiles(u.City.Latitude, u.City.Longitude, tennisUser.City.Latitude, tennisUser.City.Longitude) < 15 &&
                        Math.Abs(tennisUser.Rating - u.Rating) <= 0.25 &&
                        u.Gender == tennisUser.Gender &&
                        u.FacebookId != tennisUser.FacebookId &&
                        u.EmailOffers
                    );

                    foreach (var tu in matchUsers)
                    {
                        pushIds.Add(tu.FacebookId);
                    }
                }

                this.DB.Offer.InsertOnSubmit(offer);
                this.DB.SubmitChanges();

                string template = Server.MapPath("/content/matchrequest.htm");
                string subject = string.Format("TennisLoop: Match Requested from <fb:name uid='{0}' capitalize='true'></fb:name>", tennisUser.FacebookId);
                SendMessage(pushIds, subject, template, offer, tennisUser);

                // Send out messages to all matching users

                return Json
                (
                    new
                    {
                        UserOffers = RenderPartialViewToString("UserOffers", ModelUtils.GetModel<UserOffersModel>(FacebookWebContext.Current.UserId, this.DB)),
                        UserChallenges = RenderPartialViewToString("UserChallenges", ModelUtils.GetModel<UserOffersModel>(FacebookWebContext.Current.UserId, this.DB))
                    }
                 );
            }

            return Json("");
        }
Ejemplo n.º 22
0
 public ResponseDetail saveOfferDynamic(Offer offerDetail)
 {
     return(objTransacRepo.saveOfferDynamic(offerDetail));
 }
Ejemplo n.º 23
0
 public ResponseDetail SaveOffer(Offer ObjOffer)
 {
     return(objTransacRepo.SaveOffer(ObjOffer));
 }
Ejemplo n.º 24
0
 public override Offer ApplyOn(Offer offer)
 {
     // implementation coming soon
     return(base.ApplyOn(offer));
 }
Ejemplo n.º 25
0
 public Product(string name, int unitPrice, Offer offer = null)
 {
     this.name      = name;
     this.UnitPrice = unitPrice;
     this.Offer     = offer;
 }
Ejemplo n.º 26
0
 /// <inheritdoc />
 public async Task <Offer> SaveOffer(Offer offer)
 {
     return(await this.offerRepository.SaveOffer(offer).ConfigureAwait(false));
 }
Ejemplo n.º 27
0
        public static List <Offer> GetAllOffers()
        {
            //var ids = GetAllIds();
            var ids = new List <string>()
            {
                "207624"
            };
            List <Offer> offers = new List <Offer>();

            foreach (var id in ids)
            {
                string urlAddress = $"http://www.imoti.bg/bg/adv/view:{id}";

                HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(urlAddress);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream       receiveStream = response.GetResponseStream();
                    StreamReader readStream    = null;

                    if (response.CharacterSet == null)
                    {
                        readStream = new StreamReader(receiveStream);
                    }
                    else
                    {
                        readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
                    }
                    HtmlDocument htmlDoc = new HtmlDocument();
                    htmlDoc.OptionFixNestedTags = true;
                    htmlDoc.Load(readStream);
                    var offer = new Offer();
                    if (htmlDoc.DocumentNode != null)
                    {
                        HtmlNode title = htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[3]/div/div[3]/div[2]/div[2]/div[2]/div/div[2]/h2[1]");
                        if (title != null)
                        {
                            offer.Title = title.InnerText;
                        }

                        HtmlNode price = htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[3]/div/div[3]/div[2]/div[2]/div[2]/div/div[2]/h2[2]");
                        if (price != null)
                        {
                            offer.Price = price.InnerText;
                        }

                        HtmlNode table   = htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[3]/div/div[3]/div[2]/div[2]/div[2]/div/div[2]/table");
                        var      counter = 0;

                        foreach (HtmlNode row in table.SelectNodes("tr"))
                        {
                            foreach (HtmlNode cell in row.SelectNodes("th|td"))
                            {
                                if (counter == 1)
                                {
                                    offer.Area = cell.InnerText;
                                }
                                else if (counter == 3)
                                {
                                    offer.Specs = cell.InnerText;
                                }
                                else if (counter == 5)
                                {
                                    offer.Floor = cell.InnerText;
                                }
                                else if (counter == 7)
                                {
                                    offer.Added = cell.InnerText;
                                }
                                else if (counter == 9)
                                {
                                    offer.Visit = cell.InnerText;
                                }
                                counter++;
                            }
                        }

                        HtmlNode info = htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[3]/div/div[3]/div[2]/div[2]/div[2]/div/div[4]/text()");
                        if (info != null)
                        {
                            offer.Info = info.InnerText;
                        }

                        HtmlNode person = htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[3]/div/div[3]/div[2]/div[2]/div[2]/div/div[6]/div[1]/text()");
                        if (person != null)
                        {
                            offer.Person = person.InnerText;
                        }

                        HtmlNode location = htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[3]/div/div[3]/div[2]/div[2]/div[2]/div/div[6]/div[2]/text()");
                        if (location != null)
                        {
                            offer.Location = location.InnerText;
                        }

                        HtmlNode phone = htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[3]/div/div[3]/div[2]/div[2]/div[2]/div/div[6]/div[3]/text()");
                        if (phone != null)
                        {
                            offer.Phone = phone.InnerText;
                        }
                        offers.Add(offer);
                    }

                    response.Close();
                    readStream.Close();
                }
            }

            return(offers);
        }
Ejemplo n.º 28
0
        private IEnumerable <Offer> GetOffersList()
        {
            var offer_list = new List <Offer>();
            var car_list   = new List <Car>();

            var car1 = new Car()
            {
                Brand          = "Fiat",
                Model          = "Punto",
                Body           = "Hatchback",
                EngineCapacity = 1.2m,
                Type           = AutoCar.Core.Domain.Types.CarType.Passenger,
                FuelType       = Fuel.Benzyna,
                DoorsAmount    = 5,
                Country        = "Polska",
                IsAutomatic    = false,
                EnginePower    = 60,
                IsDamaged      = false,
                Year           = "2003",
                Mileage        = 2480000,
                OwnerAmount    = 1,
                VinNummer      = "F12345UFG88983",
                Price          = 3500,
            };


            var car2 = new Car()
            {
                Brand          = "VW",
                Model          = "Golf",
                Body           = "Hatchback",
                EngineCapacity = 1.6m,
                Type           = AutoCar.Core.Domain.Types.CarType.Passenger,
                FuelType       = Fuel.Benzyna,
                DoorsAmount    = 5,
                Country        = "Niemcy",
                IsAutomatic    = false,
                EnginePower    = 90,
                IsDamaged      = false,
                Year           = "2006",
                Mileage        = 3240000,
                OwnerAmount    = 1,
                VinNummer      = "LDG2233HEDG67726",
                Price          = 5500,
            };

            var personalUserData1 = new PersonalData("Jan", "Kowalski", DateTime.Parse("1988-08-01"), "Warszawa", "Wroclawska 1234", "", "05-001", "111111111", VoivodeList.Mazowieckie);
            var personalUserData2 = new PersonalData("Andrzej", "Kowalski", DateTime.Parse("1987-04-01"), "Wroclaw", "Warszawska 1234", "", "55-001", "222222222", VoivodeList.Dolnoslaskie);


            Offer offer1 = new Offer("Fiat Punto 1.2", "Do sprzedania ładne Punto w świetnym stanie", DateTime.Now,
                                     DateTime.Now.AddDays(30));

            offer1.OfferingUser = new User("punciak123", "*****@*****.**", "User");
            offer1.OfferingUser.SetUserPassword("admin123");
            offer1.CarToOffer = car1;

            offer_list.Add(offer1);


            Offer offer2 = new Offer("VW Golf IV super oferta", "Do sprzedania ładnego golfa w świetnym stanie", DateTime.Now,
                                     DateTime.Now.AddDays(25));

            offer2.OfferingUser = new User("golfiak222", "*****@*****.**", "User");
            offer2.OfferingUser.SetUserPassword("admin123");
            offer2.CarToOffer = car2;

            offer_list.Add(offer2);

            return(offer_list);
        }
Ejemplo n.º 29
0
 public static OfferDto ToDto(this Offer offer)
 => new OfferDto(offer.OfferId);
Ejemplo n.º 30
0
        public ActionResult OfferMaster(string ActionName, string OfferCode)
        {
            List <SelectListItem> Activeoption = new List <SelectListItem>();

            Activeoption.Add(new SelectListItem()
            {
                Text = "Active", Value = "Y"
            });
            Activeoption.Add(new SelectListItem()
            {
                Text = "Deactive", Value = "N"
            });
            ViewBag.ActiveOptions = Activeoption;

            List <SelectListItem> option = new List <SelectListItem>();

            //option.Add(new SelectListItem() { Text = "All", Value = "A" });
            option.Add(new SelectListItem()
            {
                Text = "No", Value = "A"
            });
            option.Add(new SelectListItem()
            {
                Text = "Yes", Value = "Y"
            });
            ViewBag.DropDownOptions = option;

            List <SelectListItem> idStatus = new List <SelectListItem>();

            idStatus.Add(new SelectListItem()
            {
                Text = "All", Value = "A"
            });
            idStatus.Add(new SelectListItem()
            {
                Text = "Active", Value = "Y"
            });
            idStatus.Add(new SelectListItem()
            {
                Text = "Deactive", Value = "N"
            });
            ViewBag.idStatus = idStatus;

            List <SelectListItem> ForBillType = new List <SelectListItem>();

            ForBillType.Add(new SelectListItem()
            {
                Text = "Any Bill", Value = "All"
            });
            ForBillType.Add(new SelectListItem()
            {
                Text = "First Bill", Value = "FirstBill"
            });
            ForBillType.Add(new SelectListItem()
            {
                Text = "Second Bill", Value = "SecondBill"
            });
            ForBillType.Add(new SelectListItem()
            {
                Text = "Third Bill", Value = "ThirdBill"
            });
            ViewBag.ForBillType = ForBillType;

            List <SelectListItem> ForDateType = new List <SelectListItem>();

            ForDateType.Add(new SelectListItem()
            {
                Text = "Range", Value = "R"
            });
            ForDateType.Add(new SelectListItem()
            {
                Text = "Date", Value = "D"
            });
            ViewBag.ForDateType = ForDateType;

            List <SelectListItem> OfferType = new List <SelectListItem>();

            OfferType.Add(new SelectListItem()
            {
                Text = "Offer On Value", Value = "OfferOnValue"
            });
            OfferType.Add(new SelectListItem()
            {
                Text = "Extra PV", Value = "ExtraPV"
            });
            OfferType.Add(new SelectListItem()
            {
                Text = "Buy this Get that", Value = "BuythisGetthat"
            });
            ViewBag.OfferTypeOptions = OfferType;

            List <SelectListItem> Days = new List <SelectListItem>();

            for (int i = 1; i <= 31; i++)
            {
                Days.Add(new SelectListItem()
                {
                    Text = i.ToString(), Value = i.ToString(), Selected = (i == 1?true:false)
                });
            }
            ViewBag.Days = Days;

            List <Offer>          OList            = objTransacManager.GetAllBuyThisGetThatOfferList("Active", true);
            List <SelectListItem> CombineOfferList = new List <SelectListItem>();

            foreach (var rec in OList)
            {
                CombineOfferList.Add(new SelectListItem
                {
                    Text     = rec.OfferName,
                    Value    = rec.AID.ToString(),
                    Selected = false
                });
            }
            ViewBag.CombineOfferListOptions = CombineOfferList;

            Offer objoffer = new Offer();

            objoffer.ActionName = ActionName;

            if (!string.IsNullOrEmpty(OfferCode))
            {
                int code = int.Parse(OfferCode);
                objoffer            = objOfferManager.getOfferDetail(code, null);
                objoffer.ActionName = ActionName;
                if (!string.IsNullOrEmpty(objoffer.CombineWithOffer))
                {
                    var combineList = objoffer.CombineWithOffer.Split(',');
                    foreach (var rec in CombineOfferList)
                    {
                        if (combineList.Contains(rec.Value))
                        {
                            rec.Selected = true;
                        }
                    }
                }
            }

            ViewBag.CombineOfferListOptions = CombineOfferList;


            var AccessTo = new UserController().UserCanAccess((Session["LoginUser"] as User).UserId, "Offers");

            if (!string.IsNullOrEmpty(AccessTo))
            {
                ViewBag.UserCanAccess = AccessTo;
                return(View(objoffer));
            }
            else
            {
                return(RedirectToAction("Dashboard", "Home"));
            }
        }
Ejemplo n.º 31
0
        private bool HandleTradeOfferUpdate(Offer offer)
        {
            if(knownTradeOffers.ContainsKey(offer.TradeOfferId) && knownTradeOffers[offer.TradeOfferId] == offer.TradeOfferState)
            {
                return false;
            }

            //make sure the api loaded correctly sometimes the items are missing
            if(IsOfferValid(offer))
            {
                SendOfferToHandler(offer);
            }
            else
            {
                var resp = webApi.GetTradeOffer(offer.TradeOfferId);
                if(IsOfferValid(resp.Offer))
                {
                    SendOfferToHandler(resp.Offer);
                }
                else
                {
                    Debug.WriteLine("Offer returned from steam api is not valid : " + resp.Offer.TradeOfferId);
                    return false;
                }
            }
            return true;
        }
Ejemplo n.º 32
0
 private void EnqueueAndSuccess(Offer <TOut> offer)
 {
     _buffer.Enqueue(offer.Element);
     offer.CompletionSource.NonBlockingTrySetResult(QueueOfferResult.Enqueued.Instance);
 }
Ejemplo n.º 33
0
 private void SendOfferToHandler(Offer offer)
 {
     knownTradeOffers[offer.TradeOfferId] = offer.TradeOfferState;
     OnTradeOfferUpdated(new TradeOffer(session, offer));
 }
Ejemplo n.º 34
0
            private Action <IInput> Callback()
            {
                return(GetAsyncCallback <IInput>(
                           input =>
                {
                    var offer = input as Offer <TOut>;
                    if (offer != null)
                    {
                        if (_stage._maxBuffer != 0)
                        {
                            BufferElement(offer);
                            if (IsAvailable(_stage.Out))
                            {
                                Push(_stage.Out, _buffer.Dequeue());
                            }
                        }
                        else if (IsAvailable(_stage.Out))
                        {
                            Push(_stage.Out, offer.Element);
                            offer.CompletionSource.NonBlockingTrySetResult(QueueOfferResult.Enqueued.Instance);
                        }
                        else if (_pendingOffer == null)
                        {
                            _pendingOffer = offer;
                        }
                        else
                        {
                            switch (_stage._overflowStrategy)
                            {
                            case OverflowStrategy.DropHead:
                            case OverflowStrategy.DropBuffer:
                                _pendingOffer.CompletionSource.NonBlockingTrySetResult(QueueOfferResult.Dropped.Instance);
                                _pendingOffer = offer;
                                break;

                            case OverflowStrategy.DropTail:
                            case OverflowStrategy.DropNew:
                                offer.CompletionSource.NonBlockingTrySetResult(QueueOfferResult.Dropped.Instance);
                                break;

                            case OverflowStrategy.Backpressure:
                                offer.CompletionSource.NonBlockingTrySetException(
                                    new IllegalStateException(
                                        "You have to wait for previous offer to be resolved to send another request"));
                                break;

                            case OverflowStrategy.Fail:
                                var bufferOverflowException =
                                    new BufferOverflowException(
                                        $"Buffer overflow (max capacity was: {_stage._maxBuffer})!");
                                offer.CompletionSource.NonBlockingTrySetResult(new QueueOfferResult.Failure(bufferOverflowException));
                                _completion.SetException(bufferOverflowException);
                                FailStage(bufferOverflowException);
                                break;

                            default:
                                throw new ArgumentOutOfRangeException();
                            }
                        }
                    }

                    var completion = input as Completion;
                    if (completion != null)
                    {
                        if (_stage._maxBuffer != 0 && _buffer.NonEmpty || _pendingOffer != null)
                        {
                            _terminating = true;
                        }
                        else
                        {
                            _completion.SetResult(new object());
                            CompleteStage();
                        }
                    }

                    var failure = input as Failure;
                    if (failure != null)
                    {
                        _completion.SetException(failure.Ex);
                        FailStage(failure.Ex);
                    }
                }));
            }
Ejemplo n.º 35
0
    private void ProcessXml(XmlDocument doc, string photoPath)
    {
        try
        {
            //var cats = new Dictionary<string, string>();
            //XmlNodeList categories = doc.GetElementsByTagName("Category");
            //if (categories.Count != 0)
            //{
            //    int i = 0;
            //    foreach (XmlNode categoryXml in categories)
            //    {
            //        if (categoryXml.Attributes != null)
            //        {
            //            Category category = CategoryService.GetCategoryFromDbByCategoryId(int.Parse(categoryXml.Attributes["ID"].InnerText));
            //            if (category == null)
            //            {
            //                try
            //                {
            //                    Category cat = new Category();
            //                    cat.Name = categoryXml.Attributes["Name"].InnerText;
            //                    cat.ParentCategoryId = int.Parse(categoryXml.Attributes["ParentCategory"].InnerText);
            //                    cat.Picture = string.Empty;
            //                    cat.SortOrder = Math.Max(Interlocked.Increment(ref i), i - 1);
            //                    cat.Enabled = true;

            //                    cats.Add(categoryXml.Attributes["ID"].InnerText, CategoryService.AddCategory(cat, true).ToString());
            //                    //cats.Add(categoryXml.Attributes["ID"].InnerText,
            //                    //         CategoryService.AddCategory(categoryXml.Attributes["Name"].InnerText,
            //                    //                                     int.Parse(categoryXml.Attributes["ParentCategory"].InnerText), "",
            //                    //                                     Math.Max(Interlocked.Increment(ref i), i - 1), true,
            //                    //                                     true).ToString());
            //                    CategoryService.UpdateCategory(category, true);
            //                }
            //                catch (Exception ex)
            //                {
            //                    AdvantShop.Diagnostics.Debug.LogError(ex);
            //                }
            //            }
            //            else
            //            {
            //                category.Name = categoryXml.Attributes["Name"].InnerText;
            //                category.ParentCategoryId = int.Parse(categoryXml.Attributes["ParentCategory"].InnerText);
            //                CategoryService.UpdateCategory(category, true);
            //                cats.Add(category.CategoryId.ToString(), category.CategoryId.ToString());
            //            }
            //        }
            //    }
            //}
            if (doc.GetElementsByTagName("Products").Count != 0)
            {
                var     products     = new Dictionary <string, Product>();
                var     productCats  = new Dictionary <string, string>();
                var     productUnits = new Dictionary <string, string>();
                XmlNode productsXml  = doc.GetElementsByTagName("Products")[0];
                foreach (XmlNode prodXml in productsXml.ChildNodes)
                {
                    if (prodXml.Attributes != null)
                    {
                        var product = new Product
                        {
                            ArtNo       = prodXml.Attributes["SKU"].InnerText,
                            Name        = prodXml.Attributes["Name"].InnerText,
                            Description = prodXml.Attributes["Description"].InnerText,
                            Unit        = prodXml.Attributes["Unit"].InnerText,
                            Enabled     = true,
                            UrlPath     = UrlService.GetAvailableValidUrl(0, ParamType.Product, prodXml.Attributes["SKU"].InnerText)
                        };
                        productCats.Add(product.ArtNo, prodXml.Attributes["Category"].InnerText);
                        try
                        {
                            products.Add(product.ArtNo, product);
                        }
                        catch (Exception ex)
                        {
                            Log(ex.Message, "InvalidData");
                        }
                    }
                }

                XmlNodeList offers = doc.GetElementsByTagName("Offer");
                if (offers.Count != 0)
                {
                    foreach (XmlNode offer in offers)
                    {
                        if (offer.Attributes != null)
                        {
                            Product product = products[offer.Attributes["ProductSKU"].InnerText];
                            if (product == null)
                            {
                                break;
                            }
                            var   pOffer = new Offer();
                            float price;
                            if (float.TryParse(offer.Attributes["Price"].Value.Replace('.', ','), out price))
                            {
                                pOffer.Price = price;
                            }
                            int amount;
                            if (int.TryParse(offer.Attributes["Amount"].InnerText, out amount))
                            {
                                pOffer.Amount = amount;
                            }

                            if (product.Offers == null)
                            {
                                product.Offers = new List <Offer>();
                            }

                            product.Offers.Add(pOffer);
                        }
                    }
                }

                foreach (Product product in products.Values)
                {
                    UpdateInsertProduct(product, productCats[product.ArtNo]);
                }

                LuceneSearch.CreateAllIndexInBackground();
                ProductService.PreCalcProductParamsMassInBackground();

                if (!string.IsNullOrEmpty(photoPath))
                {
                    XmlNodeList photos = doc.GetElementsByTagName("Photo");
                    if (photos.Count != 0)
                    {
                        FileHelpers.UpdateDirectories();
                        foreach (XmlNode photo in photos)
                        {
                            if (photo.Attributes != null)
                            {
                                var fullfilename = photoPath + photo.Attributes["FileName"].Value;
                                if (File.Exists(fullfilename))
                                {
                                    ProductService.AddProductPhotoByArtNo(photo.Attributes["ProductSKU"].Value, fullfilename, photo.Attributes["Description"].Value, false, null);
                                }
                                File.Delete(fullfilename);
                            }
                        }
                    }
                }
                XmlNodeList props = doc.GetElementsByTagName("Property");
                if (props.Count != 0)
                {
                    foreach (XmlNode prop in props)
                    {
                        if (prop.Attributes != null)
                        {
                            var product = ProductService.GetProduct(prop.Attributes["ProductSKU"].InnerText);
                            if (product.ID == 0)
                            {
                                break;
                            }

                            // TODO use PropertyService
                            //ProductService.AddProperty(product.Id, prop.Attributes["Name"].Value,
                            //                           prop.Attributes["Value"].Value, 0);
                        }
                    }
                }
            }
            Log("Import successfull", "SuccessImport");
        }
        catch (Exception ex)
        {
            Log(ex.Message, "InvalidData");
        }
        CategoryService.RecalculateProductsCountManual();
        CategoryService.ClearCategoryCache();

        XmlElement summary = _sdsLog.CreateElement("LogSummary");
        XmlElement el      = _sdsLog.CreateElement("Added");

        el.InnerText = _added.ToString("d");
        summary.AppendChild(el);
        el           = _sdsLog.CreateElement("Updated");
        el.InnerText = _updated.ToString("d");
        summary.AppendChild(el);
        el           = _sdsLog.CreateElement("Errors");
        el.InnerText = _errors.ToString("d");
        summary.AppendChild(el);
        if (_sdsLog.DocumentElement != null)
        {
            _sdsLog.DocumentElement.AppendChild(summary);
        }
    }
Ejemplo n.º 36
0
        //public async Task<Offer> GetOfferAsync(int id)
        //{
        //    var offer = await offersRepository.GetAsync(o => o.Id == id);
        //    return offer;
        //}

        public void Delete(Offer offer)
        {
            offersRepository.Delete(offer);
        }
Ejemplo n.º 37
0
 public ResponseDetail SaveBuyThisGetThatOffer(Offer ObjOffer)
 {
     return(objTransacRepo.SaveBuyThisGetThatOffer(ObjOffer));
 }
Ejemplo n.º 38
0
 public void CreateOffer(Offer offer)
 {
     offersRepository.Add(offer);
 }
Ejemplo n.º 39
0
 public bool updateOffer(Offer offer)
 {
     if (offers.Exists(o=> o.Id == offer.Id))
     {
         offer.update();
         offers[offers.FindIndex(ind => ind.Id == offer.Id)] = offer;
         if (onOffersChangeHandler != null)
             onOffersChangeHandler();
         return true;
     }
     else   return false;
 }
Ejemplo n.º 40
0
 public void UpdateOffer(Offer offer)
 {
     offersRepository.Update(offer);
 }
Ejemplo n.º 41
0
        public bool addOffer(Offer offer)
        {
            if (offers.Exists(o => o.Id == offer.Id))
                return false;
            else
            {
                Offer offerSaved = offer.save();
                if (offerSaved != null)
                {
                    offers.Add(offerSaved);
                    onOffersChangeHandler();
                    return true;
                }

            }

            return false;
        }
Ejemplo n.º 42
0
 public void Delete(Offer item)
 {
     Db.Offers.Remove(item);
 }
Ejemplo n.º 43
0
        private static bool SendMessage(IEnumerable<long> pushIds, string subject, string templatePath, Offer offer, TennisUserModel tennisUser)
        {
            string location = OfferModel.GetLocationLink(LocationModel.Create(offer));

            Dictionary<string, string> tokens = new Dictionary<string, string>();
            tokens.Add("FacebookId", tennisUser.FacebookId.ToString());
            tokens.Add("Rating", IndexModel.FormatRating(tennisUser.Rating));
            tokens.Add("Date", IndexModel.FormatLongDate(offer.MatchDateUtc, tennisUser.TimeZoneOffset).Replace(",", " @ "));
            tokens.Add("Name", tennisUser.Name.ToString());
            tokens.Add("Location", location);
            tokens.Add("Comments", offer.Message);
            tokens.Add("OfferId", offer.OfferId.ToString());

            return SendMessage(pushIds, subject, templatePath, tokens);
        }
Ejemplo n.º 44
0
        static void Main(string[] args)
        {
            Game game1 = new Game {
                GameID = 1, GameName = "Doom Eternal", GamePrice = 60, GameStock = 451, IsOnSale = false
            };
            Game game2 = new Game {
                GameID = 2, GameName = "Cyberpunk 2077", GamePrice = 70, GameStock = 1332, IsOnSale = false
            };
            Game game3 = new Game {
                GameID = 3, GameName = "GTA V", GamePrice = 30, GameStock = 54, IsOnSale = true
            };
            Game game4 = new Game {
                GameID = 4, GameName = "Civilization VI", GamePrice = 35, GameStock = 12, IsOnSale = true
            };
            Game game5 = new Game {
                GameID = 5, GameName = "Red Dead Redemption", GamePrice = 80, GameStock = 101, IsOnSale = true
            };

            Game[]      games    = new Game[] { game1, game2, game3, game4 };
            List <Game> lstGames = new List <Game> {
                game1, game2, game3, game4
            };

            Customer customer1 = new Customer {
                Id = 1, FirstName = "Ozan", LastName = "Şengül", Password = "******", DateOfBirth = new DateTime(1997, 11, 05), NationalityID = "29300054534"
            };
            Customer customer2 = new Customer {
                Id = 2, FirstName = "Tuncay", LastName = "Göçkon", Password = "******", DateOfBirth = new DateTime(1997, 07, 30), NationalityID = "21568251100"
            };
            Customer customer3 = new Customer {
                Id = 3, FirstName = "Defne", LastName = "Demirbaş", Password = "******", DateOfBirth = new DateTime(1998, 09, 05), NationalityID = "13450066892"
            };

            Customer[] customers = new Customer[] { customer1, customer2, customer3 };

            Offer offer1 = new Offer {
                GameName = "Red Dead Redemption II", Discount = 30, OfferEnds = new DateTime(2021, 04, 01)
            };

            List <Offer> allOffers = new List <Offer> {
                offer1
            };

            OfferManager    offerManager    = new OfferManager();
            GameManager     gameManager     = new GameManager();
            EDevletManager  eDevletManager  = new EDevletManager();
            CustomerManager customerManager = new CustomerManager();

            while (true)
            {
                menu : Console.WriteLine("Please choose an option: \r\n 1. Player Options \r\n 2. Games");
                string o1 = null;
                o1 = Console.ReadLine();

                switch (o1)
                {
                case "1":
                    Console.WriteLine("Please choose an option: \r\n 1. Sign Up \r\n 2. Delete Account \r\n 3. Update Account");
                    string o2 = null;
                    o2 = Console.ReadLine();

                    switch (o2)
                    {
                    case "1":
                        Console.WriteLine("Please enter your Nationality ID Number:");
                        string enteredID = null;
                        enteredID = Console.ReadLine();
                        for (int y = 0; y < customers.Length; y++)
                        {
                            if (enteredID == customers[y].NationalityID)
                            {
                                eDevletManager.IsValidCustomer();
                                customerManager.SignUp(new Customer());
                                goto menu;
                            }
                        }
                        Console.WriteLine("You have entered a wrong Nationality ID Number.");
                        break;

                    case "2":
                        Console.WriteLine("Please enter your password to continue:");
                        customerManager.Delete(Console.ReadLine());
                        break;

                    case "3":
                        customerManager.Update();
                        goto menu;
                    }
                    break;

                case "2":
                    Console.WriteLine("All Games:");
                    gameManager.ListAll(lstGames);
                    Console.WriteLine("------------------");
                    offerManager.ShowOffers(allOffers);
                    Console.WriteLine("------------------");
                    Console.WriteLine("Games on sale:");
                    gameManager.ListOnSale(lstGames);
                    Console.WriteLine("\r\nPlease enter a game ID to continue");
                    int enteredNo = new int();
                    enteredNo = Convert.ToInt32(Console.ReadLine());
                    #region
                    for (int i = 0; i < games.Length; i++)
                    {
                        if (enteredNo == games[i].GameID)
                        {
                            Console.WriteLine("Please choose: \r\n 1. Add to cart \r\n 2. Buy now");
                            string o3 = null;
                            o3 = Console.ReadLine();
                            switch (o3)
                            {
                            case "1":
                                gameManager.AddToCart(game2);
                                Console.WriteLine("You have special offers:");
                                Console.WriteLine("Rather than $" + game2.GamePrice + "\n");
                                offerManager.CalculateOffer(game2);

                                goto menu;

                            case "2":
                                gameManager.BuyNow(game1);
                                Console.WriteLine("You have special offers:");
                                Console.WriteLine("Rather than $" + game1.GamePrice + "\n");
                                offerManager.CalculateOffer(game1);
                                goto menu;
                            }
                        }
                    }
                    Console.WriteLine("You have entered a false game ID");
                    #endregion
                    goto menu;


                case "3":
                    customerManager.Update();
                    goto menu;
                }
            }
        }
Ejemplo n.º 45
0
        public void Test_Find()
        {
            #region Arrange
            var tmpCustomer = new CustomerConnector().Create(new Customer()
            {
                Name = "TmpCustomer", CountryCode = "SE", City = "Testopolis"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", Type = ArticleType.Stock, PurchasePrice = 100
            });
            #endregion Arrange

            IOfferConnector connector = new OfferConnector();
            var             newOffer  = new Offer()
            {
                Comments       = "TestOrder",
                CustomerNumber = tmpCustomer.CustomerNumber,
                OfferDate      = new DateTime(2019, 1, 20), //"2019-01-20",
                OfferRows      = new List <OfferRow>()
                {
                    new OfferRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10
                    },
                    new OfferRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20
                    },
                    new OfferRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 15
                    }
                }
            };

            //Add entries
            for (var i = 0; i < 5; i++)
            {
                connector.Create(newOffer);
                MyAssert.HasNoError(connector);
            }

            //Apply base test filter
            connector.CustomerNumber = tmpCustomer.CustomerNumber;
            var fullCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(5, fullCollection.TotalResources);
            Assert.AreEqual(5, fullCollection.Entities.Count);
            Assert.AreEqual(1, fullCollection.TotalPages);

            Assert.AreEqual(tmpCustomer.CustomerNumber, fullCollection.Entities.First().CustomerNumber);

            //Apply Limit
            connector.Limit = 2;
            var limitedCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(5, limitedCollection.TotalResources);
            Assert.AreEqual(2, limitedCollection.Entities.Count);
            Assert.AreEqual(3, limitedCollection.TotalPages);

            //Delete entries (DELETE not supported)

            #region Delete arranged resources
            new CustomerConnector().Delete(tmpCustomer.CustomerNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            #endregion Delete arranged resources
        }
 private void OffersUpdated(Offer[] offers)
 {
     gui.OnPopulateOffers(offers);
 }
Ejemplo n.º 47
0
 public void Create(Offer item)
 {
     Db.Offers.Add(item);
 }
Ejemplo n.º 48
0
 public static string JsonSerialize(Offer offer)
 {
     return(JsonConvert.SerializeObject(offer));
 }
Ejemplo n.º 49
0
 private bool IsOfferValid(Offer offer)
 {
     bool hasItemsToGive = offer.ItemsToGive != null && offer.ItemsToGive.Count != 0;
     bool hasItemsToReceive = offer.ItemsToReceive != null && offer.ItemsToReceive.Count != 0;
     return hasItemsToGive || hasItemsToReceive;
 }
Ejemplo n.º 50
0
 public Task UpdateOffer(Offer auction)
 {
     return(_offerRepository.Update(auction));
 }
Ejemplo n.º 51
0
 public AddOffer(Offer offer)
 {
     this.offer = offer;
 }
Ejemplo n.º 52
0
 public void Update(Offer item)
 {
     Db.Entry(item).State = EntityState.Modified;
 }
Ejemplo n.º 53
0
    public void UnlockItems(Offer offer)
    {
        LoggerHelper.LogOffer(offer);

        if (offer.Features.Count > 0) {
            UnlockFeatures(offer.Features);
        }

        foreach (var resource in offer.Resources) {
            if (LIVES_REFERENCE.Equals(resource.Reference, StringComparison.InvariantCultureIgnoreCase)) {
                LivesCount += resource.Quantity;
            }
        }
    }
Ejemplo n.º 54
0
        public ActionResult SaveOffer(Offer ObjOffer)
        {
            if (ObjOffer != null)
            {
                ObjOffer.objProductList = new List <OfferProduct>();
                if (!string.IsNullOrEmpty(ObjOffer.ProductString))
                {
                    var objects = JArray.Parse(ObjOffer.ProductString); // parse as array
                    foreach (JObject root in objects)
                    {
                        OfferProduct objTemp = new OfferProduct();
                        foreach (KeyValuePair <String, JToken> app in root)
                        {
                            if (app.Key == "ProdCode")
                            {
                                objTemp.ProductCode = app.Value.ToString();
                            }
                            else if (app.Key == "ProductName")
                            {
                                objTemp.ProductName = app.Value.ToString();
                            }
                            else if (app.Key == "FreeQty")
                            {
                                objTemp.Qty = (decimal)app.Value;
                            }
                            else if (app.Key == "BVApplied")
                            {
                                objTemp.IsBvApplied = app.Value.ToString();
                            }
                            else if (app.Key == "OnMRP")
                            {
                                objTemp.OnMRP = app.Value.ToString();
                            }
                            else if (app.Key == "IsBuyProduct")
                            {
                                objTemp.IsParent = false;
                            }
                            else if (app.Key == "PVVal")
                            {
                                objTemp.PVValue = (decimal?)app.Value;
                            }
                            else if (app.Key == "PVPer")
                            {
                                objTemp.PVPer = (decimal?)app.Value;
                            }
                            else if (app.Key == "Discount")
                            {
                                objTemp.Discount = (decimal?)app.Value; ///Convert.ToDecimal( (string) app.Value );
                            }
                            else if (app.Key == "DiscountPer")
                            {
                                objTemp.DiscountPer = (decimal?)app.Value;
                            }
                            else if (app.Key == "Scheme")
                            {
                                objTemp.Scheme = (string)app.Value;
                            }
                            else if (app.Key == "Rupee")
                            {
                                objTemp.Rupee = (decimal?)app.Value;
                            }
                            else if (app.Key == "Confirm")
                            {
                                objTemp.Confirm = (string)app.Value;
                            }
                        }
                        ObjOffer.objProductList.Add(objTemp);
                    }
                }

                if (!string.IsNullOrEmpty(ObjOffer.ParentProductString))
                {
                    var objects = JArray.Parse(ObjOffer.ParentProductString); // parse as array
                    foreach (JObject root in objects)
                    {
                        OfferProduct objTemp = new OfferProduct();
                        foreach (KeyValuePair <String, JToken> app in root)
                        {
                            if (app.Key == "ProdCode")
                            {
                                objTemp.ProductCode = app.Value.ToString();
                            }
                            else if (app.Key == "ProductName")
                            {
                                objTemp.ProductName = app.Value.ToString();
                            }
                            else if (app.Key == "FreeQty")
                            {
                                objTemp.Qty = (decimal)app.Value;
                            }
                            else if (app.Key == "OnMRP")
                            {
                                objTemp.OnMRP = app.Value.ToString();
                            }
                            else if (app.Key == "IsBuyProduct")
                            {
                                objTemp.IsParent = true;
                            }
                            else if (app.Key == "IEProduct")
                            {
                                var t = app.Value.ToString();
                                if (t == "Include")
                                {
                                    objTemp.IncludeInOffer = true;
                                }
                                else
                                {
                                    objTemp.IncludeInOffer = false;
                                }
                            }
                        }
                        ObjOffer.objProductList.Add(objTemp);
                    }
                }
            }
            var detail = objOfferManager.SaveOffer(ObjOffer);

            if (detail.ResponseStatus == "OK")
            {
                //Added log
                string hostName    = Dns.GetHostName();
                string myIP        = Dns.GetHostEntry(hostName).AddressList[0].ToString();
                string currentDate = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                objLogManager.SaveLog(Session["LoginUser"] as User, ObjOffer.ActionName + "Offer" + ObjOffer.OfferName, myIP + currentDate);
            }
            return(Json(detail, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 55
0
 public void NotifyOfRejectedOffer(Offer.Offer offer)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 56
0
 public IActionResult DeleteOffer(Offer offer)
 {
     offerRepo.Delete(offer);
     return(RedirectToAction("AllOffers", "Offers"));
 }
Ejemplo n.º 57
0
 /// <summary>
 /// Store offers data from response and print it
 /// </summary>
 /// <param name="session"></param>
 /// <param name="response"></param>
 /// <param name="sInstrument"></param>
 public void PrintOffers(O2GSession session, O2GResponse response, string sInstrument)
 {
     O2GResponseReaderFactory readerFactory = session.getResponseReaderFactory();
     if (readerFactory == null)
     {
         throw new Exception("Cannot create response reader factory");
     }
     O2GOffersTableResponseReader responseReader = readerFactory.createOffersTableReader(response);
     for (int i = 0; i < responseReader.Count; i++)
     {
         O2GOfferRow offerRow = responseReader.getRow(i);
         Offer offer;
         if (mOffers.FindOffer(offerRow.OfferID, out offer))
         {
             if (offerRow.isTimeValid && offerRow.isBidValid && offerRow.isAskValid)
             {
                 offer.Date = offerRow.Time;
                 offer.Bid = offerRow.Bid;
                 offer.Ask = offerRow.Ask;
             }
         }
         else
         {
             offer = new Offer(offerRow.OfferID, offerRow.Instrument,
                              offerRow.Digits, offerRow.PointSize, offerRow.Time,
                              offerRow.Bid, offerRow.Ask);
             mOffers.AddOffer(offer);
         }
         if (string.IsNullOrEmpty(sInstrument) || offerRow.Instrument.Equals(sInstrument))
         {
             Console.WriteLine("{0}, {1}, Bid={2}, Ask={3}", offer.OfferID, offer.Instrument, offer.Bid, offer.Ask);
         }
     }
 }
Ejemplo n.º 58
0
        public IActionResult OfferDetails(int id)
        {
            Offer offers = offerRepo.GetOfferByID(id);

            return(View(offers));
        }
Ejemplo n.º 59
0
        public IActionResult DeleteOffer(int id)
        {
            Offer offer = offerRepo.GetOfferByID(id);

            return(View(offer));
        }
Ejemplo n.º 60
0
 public Task CreateOffer(Offer offer)
 {
     return(_offerRepository.Create(offer));
 }