コード例 #1
0
        /// <summary>
        /// Registers the bid.
        /// </summary>
        /// <param name="person">The person.</param>
        /// <param name="bid">The bid.</param>
        /// <param name="auction">The auction.</param>
        /// <exception cref="System.Exception">INVALID BID!</exception>
        public void RegisterBid(Person person, Bid bid, Auction auction)
        {
            IPersonBidderTable personBidderTable = this.tablesProvider.GetPersonBidderTable();
            IBidTable          bidTable          = this.tablesProvider.GetBidTable();

            try
            {
                PersonBidder personBidder = personBidderTable.FetchPersonBidderByIdPerson(person.IdPerson);
                bid.PersonBidder    = personBidder ?? throw new Exception("no person bidder!");
                personBidder.Person = person;

                Bid highest_bid = this.GetHighestBid(auction);
                if (highest_bid != null)
                {
                    highest_bid.PersonBidder = personBidderTable.FetchPersonByIdBid(highest_bid.IdBid);
                    highest_bid.Currency     = auction.Currency;
                    highest_bid.Auction      = auction;
                }

                bool isOkToPostBid = CanBidBePostedToActionCheck.DoCheck(personBidder, bid, auction, highest_bid);
                if (!isOkToPostBid)
                {
                    throw new Exception("INVALID BID!");
                }

                bidTable.InsertBid(personBidder.IdBidder, auction.IdAuction, auction.Currency.IdCurrency, bid);

                Log.Info("bid registered!");
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #2
0
        /// <summary>
        /// Registers the person.
        /// </summary>
        /// <param name="person">The person.</param>
        /// <returns>
        /// true if it succeeds
        /// </returns>
        /// <exception cref="System.Exception">Person is already registered!</exception>
        public Person RegisterPerson(Person person)
        {
            PersonOfferor offeror;
            PersonBidder  bidder;

            IPersonTable        personTable        = this.tablesProvider.GetPersonTable();
            IPersonBidderTable  personBidderTable  = this.tablesProvider.GetPersonBidderTable();
            IPersonOfferorTable personOfferorTable = this.tablesProvider.GetPersonOfferorTable();

            try
            {
                if (person.IdPerson != 0)
                {
                    throw new Exception("Person is already registered!");
                }

                person.ValidateObject();

                Person exists = personTable.FetchPersonByPhone(person.Phone);

                if (exists != null)
                {
                    person = exists; //// to update the id.
                    return(person);
                }
            }
            catch (Exception e)
            {
                Log.Info("RegisterPerson: " + e.Message);
                throw e;
            }

            //// at this point person doesn't exist into db.
            //// the actual insert
            personTable.InsertPerson(person);
            person = personTable.FetchPersonByPhone(person.Phone); //// in order to update Id

            offeror = new PersonOfferor()
            {
                Person = person
            };
            bidder = new PersonBidder()
            {
                Person = person
            };

            personOfferorTable.InsertPersonOfferor(person.IdPerson, offeror);
            personBidderTable.InsertPersonBidder(person.IdPerson, bidder);

            Log.Info("RegisterPerson: " + person.Name + " person id =" + person.IdPerson + " inserted with success.");

            return(person);
        }
コード例 #3
0
        /// <summary>
        /// Prevents a default instance of the <see cref="DomainDataStorage"/> class from being created.
        /// </summary>
        private DomainDataStorage()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString;

            this.databaseConneection = new MySqlConnection(connectionString);

            this.auctionTable       = this.databaseConneection.As <IAuctionTable>();
            this.bidTable           = this.databaseConneection.As <IBidTable>();
            this.categoryTable      = this.databaseConneection.As <ICategoryTable>();
            this.currencyTable      = this.databaseConneection.As <ICurrencyTable>();
            this.personBidderTable  = this.databaseConneection.As <IPersonBidderTable>();
            this.personMarkTable    = this.databaseConneection.As <IPersonMarkTable>();
            this.personOfferorTable = this.databaseConneection.As <IPersonOfferorTable>();
            this.personTable        = this.databaseConneection.As <IPersonTable>();
            this.productTable       = this.databaseConneection.As <IProductTable>();
        }