Exemplo n.º 1
0
        public IHttpActionResult AddBid([FromBody] int[] biddata)
        {
            //,int bidamount, int UID
            bid newBid = new bid();
            int cid    = biddata[0];
            var name   = db.crops.Where(u => u.CID == cid).FirstOrDefault();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                newBid.CID       = cid;
                newBid.crop_name = name.crop_name;
                newBid.bid1      = biddata[1];
                newBid.UID       = biddata[2];
                db.bids.Add(newBid);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Ok(newBid));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("id,DatePosted,email,phone,BidAmount")] bid bid)
        {
            if (id != bid.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bid);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!bidExists(bid.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bid));
        }
Exemplo n.º 3
0
        public ActionResult Create(TeamModel model)
        {
            team   info        = model.info;
            String memberNames = model.memberNames;
            bid    bidInfo     = model.bidInfo;

            if (CheckSession())
            {
                model.info.purchaseId  = model.bidInfo.purchaseId;
                model.info.team_time   = DateTime.Now;
                model.bidInfo.bid_time = DateTime.Now;
                model.info.createId    = (Int32)Session["user_id"];
                var result = CreateRecord <team>(info);
                if (result.first)
                {
                    var memberNmaeList = memberNames.Split(',').Distinct().ToList();
                    CreateMembers(result.second.teamId, memberNmaeList);
                    var bidderResult = Utility.CreateBidder(result.second.teamId, UserType.Team);
                    if (bidderResult.first)
                    {
                        const String uploadFieldName = "bidinfo.bid_content";
                        Utility.FillBidRecord(bidInfo, bidderResult.second, Request, uploadFieldName);
                        var bidResult = CreateRecord <bid>(bidInfo);
                        if (bidResult.first)
                        {
                            return(RedirectToAction("Detail", "Bid", new { id = bidResult.second.bidId }));
                        }
                    }
                }
            }
            return(RedirectToAction("Detail", "Purchase", new { id = info.purchaseId }));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> IndexII()
        {
            bid bid1 = new bid()
            {
                AgentInfo  = agent1,
                DatePosted = DateTime.Now,
                BidAmount  = 3000
            };

            bid bid2 = new bid()
            {
                AgentInfo  = agent3,
                DatePosted = DateTime.Now,
                BidAmount  = 2900
            };

            if (await _context.bid.CountAsync() == 2)
            {
                _context.bid.Add(bid1);
                _context.bid.Add(bid2);

                //_context.SaveChanges();
            }

            return(View(await _context.bid.Include(x => x.AgentInfo).ToListAsync()));
        }
Exemplo n.º 5
0
 public static BidRecordInfo GetBidUser(bidder info, bid bidInfo)
 {
     if (info.bidder_is_team)
     {
         var result = GetSingleTableRecord <team>(x => x.teamId == info.tendererId);
         Assert(result != null);
         return(new BidRecordInfo
         {
             name = result.team_name,
             introduction = result.team_introduction,
             staute = BidStatus(bidInfo.purchaseId, bidInfo.bidId)
         });
     }
     else
     {
         var result = GetSingleTableRecord <vendor>(x => x.vendorId == info.tendererId);
         Assert(result != null);
         return(new BidRecordInfo
         {
             name = result.user.user_name,
             introduction = result.user.user_introduction,
             staute = BidStatus(bidInfo.purchaseId, bidInfo.bidId)
         });
     }
 }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("id,DatePosted,email,phone,BidAmount")] bid bid)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bid);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bid));
        }
Exemplo n.º 7
0
        public bidWCF convertToWCF(bid b)
        {
            bidWCF bid = new bidWCF();

            bid.id        = b.id;
            bid.item_id   = b.item_id;
            bid.bidder_id = b.bidder_id;
            bid.amount    = b.amount;


            return(bid);
        }
Exemplo n.º 8
0
        //获取标书详情
        public ActionResult Create(int purchaseId)
        {
            var info = new bid();

            if (CheckVendorSession())
            {
                info.purchaseId       = purchaseId;
                ViewBag.purchaseTitle = Utility.GetSingleTableRecord <purchase>(x => x.purchaseId == purchaseId).purchase_title;
                return(View(info));
            }
            Assert(Request.UrlReferrer != null);
            return(Redirect(Request.UrlReferrer.ToString()));
        }
        private void bidstagesViewSource_Filter(object sender, FilterEventArgs e)
        {
            bid _bid = e.Item as bid;

            if ((_bid != null) & (SelectedMethod != null) & (SelectedStage != null))
            {
                // Filter logic here
                if ((_bid.MethodRef == SelectedMethod.MethodId) & (_bid.StageRef == SelectedStage.StageId))
                {
                    e.Accepted = true;
                }
                else
                {
                    e.Accepted = false;
                }
            }
        }
Exemplo n.º 10
0
 public ActionResult Create(bid info)
 {
     //只有Vendor走这里
     if (CheckVendorSession())
     {
         Assert((UserType)Session["user_type"] == UserType.Vendor);
         var bidderResult = CreateBidder((Int32)Session["user_id"], UserType.Vendor);
         if (ModelState.IsValid && bidderResult.first)
         {
             const String uploadFieldName = "bid_content";
             Utility.FillBidRecord(info, bidderResult.second, Request, uploadFieldName);
             var result = new Pair <bool, bid>();
             result = CreateRecord <bid>(info);
             if (result.first)
             {
                 return(RedirectToAction("Detail", new { id = result.second.bidId }));
             }
         }
     }
     Assert(Request.UrlReferrer != null);
     return(Redirect(Request.UrlReferrer.ToString()));
 }
Exemplo n.º 11
0
        private void Delivered_Clicked(object sender, EventArgs e)
        {
            username.IsVisible       = false;
            Login.online             = true;
            readyForPickup.IsVisible = true;
            delivered.IsVisible      = false;
            offline.IsVisible        = false;
            orderslist.IsVisible     = false;
            readyForPickup.Text      = "Доставка оформленна!" + Environment.NewLine + "Для начала работы нажмите сюда";

            try
            {
                HttpClient client  = new HttpClient();
                var        makebid = new bid {
                    userName = _name, userKey = _pass, currentbid = "Delivered", loadID = _loadid
                };
                string url      = "http://bakunexpress.com/api/loads1/";
                var    json     = JsonConvert.SerializeObject(makebid);
                var    resp     = new StringContent(json, Encoding.UTF8, "application/json");
                var    response = client.PutAsync(url, resp).Result;


                //if (response.StatusCode==HttpStatusCode.OK)
                //{



                //}

                //else
                //{

                //}
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 12
0
        public IHttpActionResult AddBid([FromBody] bid newbid, int id)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                var uid = db.crops.Where(u => u.CID == id).FirstOrDefault();


                db.bids.Add(newbid);
                newbid.UID = uid.UID;
                newbid.CID = id;

                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Ok(newbid));
        }
Exemplo n.º 13
0
        public static String UploadFileGetUrl(bid info, HttpRequestBase request, String uploadName)
        {
            // uploadName = "bid_content";
            Assert(request.Files[uploadName] != null);

            var file = request.Files[uploadName];

            Assert(request.Files.Count == 1);
            string path     = "/Uploads/";
            string fileName = Path.GetFileName(file.FileName);
            Regex  regex    = new Regex(@"\.(pdf|txt|ppt|doc|wps|xls)");

            Assert(fileName != null);
            if (!regex.IsMatch(fileName))
            {
                Assert(false);
            }
            path = Path.Combine(path, fileName);
            var fullPath = AppDomain.CurrentDomain.BaseDirectory + path;

            file.SaveAs(fullPath);
            return(path);
        }
Exemplo n.º 14
0
        private void _submit(object sender, EventArgs e)
        {
            try
            {
                HttpClient client  = new HttpClient();
                var        makebid = new bid {
                    userName = _username, userKey = _secKey, currentbid = bid.Text, loadID = _loadID, milesaway = _milesaway
                };
                string url      = "http://bakunexpress.com/api/loads1/";
                var    json     = JsonConvert.SerializeObject(makebid);
                var    resp     = new StringContent(json, Encoding.UTF8, "application/json");
                var    response = client.PutAsync(url, resp).Result;


                if (response.StatusCode == HttpStatusCode.OK)
                {
                    MainPage.refuse    = false;
                    MainPage.intransit = false;

                    MainPage.bid         = true;
                    App.Current.MainPage = new NavigationPage(new MainPage(_username, _pass, _loadID));
                }

                else
                {
                    MainPage.bid         = false;
                    MainPage.intransit   = false;
                    MainPage.refuse      = true;
                    App.Current.MainPage = new NavigationPage(new MainPage(_username, _pass, _loadID));
                }
            }
            catch (Exception)
            {
                MainPage.refuse      = true;
                App.Current.MainPage = new NavigationPage(new MainPage(_username, _pass, _loadID));
            }
        }
Exemplo n.º 15
0
 internal bool Place()
 {
     try
     {
         RealEntities db  = new RealEntities();
         bid          bid = new bid();
         bid.property_id = PropertyId;
         bid.buyer_id    = BuyerId;
         bid.status      = ( int )Status;
         db.bids.Add(bid);
         db.SaveChanges();
         bid_price bp = new bid_price();
         bp.bid_id          = bid.bid_id;
         bp.apartment_price = HousePrice;
         bp.plot_price      = LandPrice;
         db.bid_price.Add(bp);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
     }
     return(false);
 }
Exemplo n.º 16
0
        public ActionResult Index(addBid addBid)
        {
            string json = new WebClient().DownloadString("http://uptime-auction-api.azurewebsites.net/api/Auction").Replace("product", "").Replace("bidding", "");

            product Product = JsonConvert.DeserializeObject <List <product> >(json).Find(a => a.Id == addBid.Id);

            if (Product == null)
            {
                return(Json("ERROR: Auction has expired"));
            }

            bid Bid = new bid
            {
                Product = Product,
                User    = new user
                {
                    Forname = addBid.Forname,
                    Surname = addBid.Surname
                },
                BidDate = DateTime.Now,
            };

            if (!float.TryParse(addBid.Amount, out float amount))
            {
                return(Json("ERROR: Amount has to be a number"));
            }

            bool Decimal       = false;
            int  DecimalPoints = 0;

            foreach (char c in addBid.Amount)
            {
                if (Decimal)
                {
                    DecimalPoints++;
                }
                if (c == char.Parse("."))
                {
                    Decimal = true;
                }
            }

            if (DecimalPoints > 2)
            {
                return(Json("ERROR: Amount can't have more then 2 deciaml spaces"));
            }

            Bid.Amount = amount;

            Debug.WriteLine(Bid.User.Forname);
            Debug.WriteLine(Bid.User.Surname);
            Debug.WriteLine(Bid.Amount);

            string path = Path.GetDirectoryName(this.GetType().Assembly.Location) + "/../bids.json";

            List <bid> Bids = new List <bid>();

            if (System.IO.File.Exists(path))
            {
                Bids = JsonConvert.DeserializeObject <List <bid> >(System.IO.File.ReadAllText(path, System.Text.Encoding.UTF8));
            }

            foreach (bid item in Bids)
            {
                if (item.Product.Id == Bid.Product.Id && item.User.Forname == Bid.User.Forname && item.User.Surname == Bid.User.Surname)
                {
                    if (item.Amount > Bid.Amount)
                    {
                        return(Json("ERROR: You already have a bid with larger amount"));
                    }
                }
            }

            Bids.Add(Bid);

            System.IO.File.WriteAllText(path, JsonConvert.SerializeObject(Bids));

            return(Json("SUCCESS: Your bid was successfull"));
        }
Exemplo n.º 17
0
 public static void FillBidRecord(bid info, bidder bidderInfo, HttpRequestBase request, String uploadName)
 {
     info.bidderId    = bidderInfo.bidderId;
     info.bid_content = UploadFileGetUrl(info, request, uploadName);
     info.bid_time    = DateTime.Now;
 }
Exemplo n.º 18
0
        public void BidAuction(Guid auctionID, string userID, out string fullName, out string newPrice, out bool tokens, out double timeRemaining)
        {
            try
            {
                auction auction = null;
                User    user    = null;
                using (var context = new AuctionsDB())
                {
                    using (var trans = context.Database.BeginTransaction(IsolationLevel.Serializable))
                    {
                        try
                        {
                            auction = context.auction.Find(auctionID);
                            user    = context.User.Find(userID);


                            if ((auction != null) && (user != null))
                            {
                                //cena da ulozimo jos jedan token
                                int minNext   = (int)(auction.currentPrice + AdminParams.T);
                                int userMoney = (int)(user.NumberOfTokens * AdminParams.T);
                                if ((userMoney >= minNext) && (auction.status.Contains("OPENED")))
                                {
                                    tokens = false;
                                    //kako korisnik da bira koliko?
                                    int price        = minNext;
                                    int tokensNeeded = (int)Math.Ceiling(minNext / AdminParams.T);

                                    /*
                                     * double remaining = ((DateTime)auction.closedAt - DateTime.Now).TotalSeconds;
                                     *
                                     * DateTime newClosed = (DateTime)auction.closedAt;
                                     * if (remaining <= 10)
                                     * {
                                     *  double increment = remaining * (-1);
                                     *  increment += 10;
                                     *
                                     *  newClosed = newClosed.AddSeconds(increment);
                                     * }
                                     *
                                     * auction.closedAt = newClosed;
                                     * timeRemaining =  ((DateTime)auction.closedAt - DateTime.Now).TotalSeconds;
                                     */
                                    timeRemaining = 1;
                                    //umanjujemo za onoliko koliko potrebno tokena
                                    user.NumberOfTokens       = user.NumberOfTokens - tokensNeeded;
                                    context.Entry(user).State = System.Data.Entity.EntityState.Modified;
                                    context.SaveChanges();
                                    bid latestBid = new bid()
                                    {
                                        id        = Guid.NewGuid(),
                                        numTokens = tokensNeeded,
                                        placedAt  = DateTime.Now,
                                        idUser    = userID,
                                        idAuction = auctionID
                                    };
                                    auction.bidId = latestBid.id;
                                    //mozda povecamo za 10 posto?
                                    auction.currentPrice = price;
                                    //? sta je ovo auction.bid.Add(latestBid);

                                    context.Entry(auction).State = System.Data.Entity.EntityState.Modified;
                                    context.SaveChanges();

                                    context.bid.Add(latestBid);
                                    context.SaveChanges();
                                    trans.Commit();
                                    fullName = user.FirstName + " " + user.LastName;
                                    newPrice = "" + price;
                                }
                                else
                                {
                                    fullName = newPrice = null;

                                    if (!auction.status.Contains("OPENED"))
                                    {
                                        tokens        = false;
                                        timeRemaining = -1;
                                    }
                                    else
                                    {
                                        tokens        = true;
                                        timeRemaining = 1;
                                    }
                                }
                            }
                            else
                            {
                                fullName      = newPrice = null;
                                tokens        = true;
                                timeRemaining = -1;
                                throw new Exception();
                            }
                        }
                        catch (Exception ex)
                        {
                            trans.Rollback();
                            fullName      = newPrice = null;
                            tokens        = true;
                            timeRemaining = -1;
                        }
                    }
                }
            }
            catch (FormatException)
            {
                fullName      = newPrice = null;
                tokens        = true;
                timeRemaining = -1;
                Console.WriteLine("Error with bidding.");
            }
        }
Exemplo n.º 19
0
 public async Task <bool> AddBid(bid b)
 {
     return(await Task.Factory.FromAsync(service.BeginAddBid, service.EndAddBid, convertToWCF(b), TaskCreationOptions.None));
 }