Пример #1
0
 public Boolean StartAuction()
 {
     if (this.state.Equals(KeysUtils.AuctionReady()))
     {
         this.state         = KeysUtils.AuctionOpened();
         this.current_price = this.starting_price;
         this.opened        = DateTime.Now;
         this.closed        = DateTime.Now.AddMilliseconds(this.duration * 1000);
         return(true);
     }
     return(false);
 }
Пример #2
0
        public static List <Auction> Search(int?min, int?max, int?itemsPerPage, string state, string searchString)
        {
            List <Auction> la = null;

            using (Database db = new Database())
            {
                string op_state = KeysUtils.AuctionReady();
                la = db.Auction.Where(a => !a.state.Equals(op_state)).OrderByDescending(a => a.created).ToList();

                if (!String.IsNullOrEmpty(state) && !state.Trim().Equals("Auction State"))
                {
                    la = la.Where(a => a.state.Equals(state.Trim())).ToList();
                }

                if (min != null)
                {
                    la = la.Where(a => a.token_price > min).ToList();
                }
                if (max != null)
                {
                    la = la.Where(a => a.token_price < max).ToList();
                }
                if (!String.IsNullOrWhiteSpace(searchString))
                {
                    string[] tokens = searchString.ToLower().Trim().Split(' ');
                    foreach (string s in tokens)
                    {
                        la = la.Where(a => a.title.ToLower().Contains(s)).ToList();
                    }
                }
                if (itemsPerPage != null)
                {
                    la = la.Take(itemsPerPage.GetValueOrDefault()).ToList();
                }
                else
                {
                    int tt = db.SystemConf.FirstOrDefault().mrp_group;
                    la = la.Take(tt).ToList();
                }
            }

            foreach (Auction a in la)
            {
                a.checkAuctionEnd();
            }
            return(la);
        }
Пример #3
0
        public static Auction Create(FormCreateAuction fcAuction, Guid user_id)
        {
            Auction auction = new Auction();

            auction.title          = fcAuction.title;
            auction.starting_price = fcAuction.starting_price;
            auction.duration       = fcAuction.duration;
            auction.picture        = new byte[fcAuction.image.ContentLength];
            fcAuction.image.InputStream.Read(auction.picture, 0, fcAuction.image.ContentLength);
            auction.current_price = 0;
            auction.created       = DateTime.Now;
            auction.state         = KeysUtils.AuctionReady();
            SystemConf config = SystemConf.GetSystemConf();

            auction.currency    = config.currency;
            auction.tokenValue  = config.token_value;
            auction.token_price = (int)Math.Ceiling(auction.starting_price / auction.tokenValue);
            auction.user_id     = user_id;
            return(auction);
        }