Beispiel #1
0
        public IHttpActionResult PutAuctionDetail(int id, AuctionDetail auctionDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != auctionDetail.Id)
            {
                return(BadRequest());
            }

            db.Entry(auctionDetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AuctionDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult GetAuctionDetail(int id)
        {
            AuctionDetail auctionDetail = db.AuctionDetails.Find(id);

            if (auctionDetail == null)
            {
                return(NotFound());
            }

            return(Ok(auctionDetail));
        }
Beispiel #3
0
        public IHttpActionResult PostAuctionDetail(AuctionDetail auctionDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AuctionDetails.Add(auctionDetail);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = auctionDetail.Id }, auctionDetail));
        }
Beispiel #4
0
        public static AppAuction GetAuctionDetail(AuctionDetail dbAuction)
        {
            var appAuctionDetail = new AppAuction()
            {
                AuctionId   = dbAuction.AuctionId,
                PriceListed = dbAuction.PriceListed,
                BuyoutPrice = dbAuction.BuyoutPrice,
                NumberBids  = dbAuction.NumberBids,
                SellType    = dbAuction.SellType,
                ExpDate     = dbAuction.ExpDate
            };

            return(appAuctionDetail);
        }
Beispiel #5
0
        public IHttpActionResult DeleteAuctionDetail(int id)
        {
            AuctionDetail auctionDetail = db.AuctionDetails.Find(id);

            if (auctionDetail == null)
            {
                return(NotFound());
            }

            db.AuctionDetails.Remove(auctionDetail);
            db.SaveChanges();

            return(Ok(auctionDetail));
        }
        public ActionResult AuctionDetail(long?id, bool?ProxyBidding, decimal?BidAmount, decimal?OutBidAmount)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Category", "Auction"));
            }
            AuctionDetail auction = AuctionRepository.GetAuctionDetail(id.GetValueOrDefault(-1), true);

            if (auction == null)
            {
                return(RedirectToAction("Category", "Auction"));
            }
            if (!auction.IsCurrentEvent || auction.Status == Consts.AuctionStatus.Closed || auction.DateEnd.CompareTo(DateTime.Now) < 0 || (!ProxyBidding.HasValue || !BidAmount.HasValue))
            {
                return(RedirectToAction("AuctionDetail", "Auction", new { @id = auction.LinkParams.ID }));
            }

            PreviewBid previewBid = new PreviewBid
            {
                IsProxy    = ProxyBidding.Value,
                Amount     = BidAmount.Value,
                LinkParams = auction.LinkParams,
                Quantity   = 1
            };

            BidCurrent prevMaxBid = BidRepository.GetTopBidForItem(auction.LinkParams.ID);

            if (prevMaxBid != null)
            {
                previewBid.IsOutBid = previewBid.Amount <= prevMaxBid.Amount && previewBid.Amount <= prevMaxBid.MaxBid;
                if (prevMaxBid.User_ID == AppHelper.CurrentUser.ID)
                {
                    previewBid.IsUpdate       = true;
                    previewBid.PreviousAmount = prevMaxBid.Amount;
                    previewBid.PreviousMaxBid = prevMaxBid.MaxBid;
                    previewBid.RealAmount     = (previewBid.IsProxy) ? prevMaxBid.Amount : previewBid.Amount;
                    previewBid.Amount         = (previewBid.Amount < prevMaxBid.MaxBid) ? prevMaxBid.MaxBid : previewBid.Amount;
                }
                else
                {
                    previewBid.RealAmount = (!previewBid.IsProxy) ? previewBid.Amount : (((!OutBidAmount.HasValue) ? prevMaxBid.Amount : OutBidAmount.Value) + Consts.GetIncrement(prevMaxBid.Amount));
                }
            }
            else
            {
                previewBid.RealAmount = (previewBid.IsProxy) ? auction.Price : previewBid.Amount;
            }
            return(View("PreviewBid", previewBid));
        }
Beispiel #7
0
        //Create an auction
        public async Task <bool> CreateAuction(AppAuction auction)
        {
            if (auction == null)
            {
                return(false);
            }
            else
            {
                //create db objects
                var dbAuction = new Auction
                {
                    AuctionId = auction.AuctionId,
                    SellerId  = auction.SellerId,
                    BuyerId   = auction.BuyerId,
                    CardId    = auction.CardId,
                    PriceSold = auction.PriceSold,
                    SellDate  = auction.SellDate
                };
                var dbAuctionDetail = new AuctionDetail
                {
                    AuctionId   = auction.AuctionId,
                    PriceListed = auction.PriceListed,
                    BuyoutPrice = auction.BuyoutPrice,
                    NumberBids  = auction.NumberBids,
                    SellType    = auction.SellType,
                    ExpDate     = auction.ExpDate
                };

                //Add to db
                try
                {
                    await _context.Auctions.AddAsync(dbAuction);

                    await _context.AuctionDetails.AddAsync(dbAuctionDetail);

                    await _context.SaveChangesAsync();

                    return(true);
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Error Creating Auction: " + e);
                }
            }

            return(false);
        }
        public ActionResult AuctionDetail(long?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Category"));
            }
            InitCurrentEvent();
            Event         evnt    = ViewData["CurrentEvent"] as Event;
            AuctionDetail auction = AuctionRepository.GetAuctionDetail(id.Value, evnt.ID, true);

            if (auction == null)
            {
                return(RedirectToAction("Category"));
            }
            SessionUser cuser = AppHelper.CurrentUser;

            if (auction.Status == Consts.AuctionStatus.Pending || auction.Status == Consts.AuctionStatus.Open)
            {
                AuctionUserInfo aui = new AuctionUserInfo();
                if (cuser != null)
                {
                    aui.IsRegisterForEvent = EventRepository.IsUserRegisterForEvent(cuser.ID, auction.LinkParams.Event_ID);
                    aui.IsInWatchList      = AuctionRepository.IsUserWatchItem(cuser.ID, auction.LinkParams.ID);
                }
                else
                {
                    aui = new AuctionUserInfo {
                        IsInWatchList = false, IsRegisterForEvent = false
                    }
                };
                ViewData["AuctionUserInfo"] = aui;

                AuctionShort ashort = AuctionRepository.GetAuctionDetailResult(auction.LinkParams.ID, true);
                ViewData["AuctionShort"]  = ashort;
                ViewData["BiddingResult"] = BidRepository.CurrentAuctionBiddingResult(auction.LinkParams.ID, cuser == null ? null : (long?)cuser.ID, ashort.Price);
                if (ashort.Bids != 0)
                {
                    if (auction.CloseStep == 1 && cuser != null)
                    {
                        ViewData["IsUserHasRightsToBid"] = BidRepository.IsUserCanParticipateInBidding(auction.LinkParams.ID, cuser.ID);
                    }
                }
            }
            return(View("AuctionDetailNew", auction));
        }
        public ActionResult PlaceBidTest(long?id)
        {
            if (!id.HasValue) // return RedirectToAction("Category", "Auction");
            {
                id = 65414;
            }
            AuctionDetail auction = AuctionRepository.GetAuctionDetail(id.Value, AppHelper.CurrentUser == null ? -1 : AppHelper.CurrentUser.ID, true);

            if (auction == null)
            {
                return(RedirectToAction("Category", "Auction"));
            }
            BiddingResult br  = BidRepository.CurrentAuctionBiddingResult(id.Value, AppHelper.CurrentUser == null ? -1 : AppHelper.CurrentUser.ID, auction.Price);
            decimal       bid = br.MinBid == 0 ? auction.Price : (br.UsersTopBid == null || br.UsersTopBid.MaxBid < br.MinBid) ? br.MinBid : br.UsersTopBid.MaxBid;

            bid = bid + Consts.GetIncrement(bid);
            return(PlaceBid(auction.LinkParams.ID, false, bid, bid));
        }
        public static AuctionDetail ToMvcAuctionDetail(this BllAuction auction, IUserService userService)
        {
            var returnValue = new AuctionDetail()
            {
                AuctionEndDate = auction.Lot.AuctionEndDate,
                CreationDate   = auction.Lot.CreationDate,
                CurrentPrice   = auction.Lot.CurrentPrice,
                Description    = auction.Lot.Description,
                LastUpdateDate = auction.Lot.LastUpdateDate,
                Id             = auction.Lot.Id,
                Photos         = auction.Lot?.Photos?.Split(':') ?? Enumerable.Empty <string>(),
                SellerId       = auction.Lot.Seller,
                Title          = auction.Lot.Title,
                Bids           = auction?.Bids.Select(t => t.ToMvcBid(userService)),
                Comments       = auction?.Comments.Select(t => t.ToMvcComment(userService))
            };

            Task <BllUser> task = Task.Run(() => userService.GetById(auction.Lot.Seller));

            task.Wait();
            returnValue.Seller = task.Result.Login;
            return(returnValue);
        }
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null || id < 1)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var bllAuction = await auctionService.GetTotalAuctionInfo((int)id, 10);

            if (bllAuction == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (TempData["ViewData"] != null)
            {
                ViewData = (ViewDataDictionary)TempData["ViewData"];
            }

            AuctionDetail mvcAuction = bllAuction.ToMvcAuctionDetail(userService);

            return(View(mvcAuction));
        }
        [VauctionAuthorize, Compress, HttpPost, ValidateAntiForgeryTokenWrapper(HttpVerbs.Post)] // AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)
        public ActionResult PlaceBid(long?id, bool?ProxyBidding, decimal?BidAmount, decimal?RealBidAmount)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Category", "Auction"));
            }
            AuctionDetail auction = AuctionRepository.GetAuctionDetail(id.GetValueOrDefault(-1), true);

            if (auction == null)
            {
                return(RedirectToAction("Category", "Auction"));
            }
            if (!auction.IsCurrentEvent || auction.Status == Consts.AuctionStatus.Closed || auction.DateEnd.CompareTo(DateTime.Now) < 0 || (!ProxyBidding.HasValue || !BidAmount.HasValue))
            {
                return(RedirectToAction("AuctionDetail", "Auction", new { @id = auction.LinkParams.ID }));
            }

            SessionUser cuser = AppHelper.CurrentUser;

            if (!AuctionRepository.IsUserWatchItem(cuser.ID, auction.LinkParams.ID))
            {
                AuctionRepository.AddItemToWatchList(cuser.ID, auction.LinkParams.ID);
            }

            PreviewBid previewBid = new PreviewBid
            {
                LinkParams = auction.LinkParams,
                IsProxy    = ProxyBidding.Value,
                Amount     = BidAmount.Value,
                Quantity   = 1,
                RealAmount = RealBidAmount.GetValueOrDefault(0)
            };

            byte       result;
            BidCurrent currentBid = new BidCurrent
            {
                Amount     = BidAmount.GetValueOrDefault(0),
                Auction_ID = id.Value,
                DateMade   = DateTime.Now,
                IP         = Consts.UsersIPAddress,
                IsActive   = true,
                IsProxy    = ProxyBidding.GetValueOrDefault(false),
                MaxBid     = BidAmount.GetValueOrDefault(0),
                Quantity   = 1,
                User_ID    = cuser.ID
            };
            BidCurrent previousBid, loserBid, winnerBid;

            result = BidRepository.BiddingForSingleAuction(auction, currentBid, out previousBid, out loserBid, out winnerBid);

            if (result == 3)
            {
                return(RedirectToAction("AuctionDetail", new { id.Value }));
            }

            AuctionRepository.RemoveAuctionResultsCache(id.Value);

            BidRepository.RemoveTopBidForItemCache(id.Value);

            BidRepository.UpdateUsersTopBidCache(id.Value, cuser.ID, currentBid);

            if (result == 1)
            {
                previewBid.Amount = winnerBid.Amount;
                if (cuser.IsRecievingOutBidNotice && !String.IsNullOrEmpty(cuser.Email) && !cuser.IsHouseBidder)
                {
                    Mail.SendOutBidLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, winnerBid.Amount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl);
                }
                return(View("OutBid", previewBid));
            }

            if (cuser.IsRecievingBidConfirmation && !String.IsNullOrEmpty(cuser.Email) && !cuser.IsHouseBidder)
            {
                if (result == 2)
                {
                    Mail.SendSuccessfulBidUpdateLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, currentBid.Amount.GetCurrency(), currentBid.MaxBid.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl, currentBid.MaxBid > previousBid.MaxBid);
                }
                else
                {
                    Mail.SendSuccessfulBidLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, currentBid.Amount.GetCurrency(), BidAmount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl);
                }
            }

            if (loserBid != null && loserBid.User_ID != cuser.ID)
            {
                User usr = dataProvider.UserRepository.GetUser(loserBid.User_ID, true);
                if (usr.IsRecievingOutBidNotice && !String.IsNullOrEmpty(usr.Email) && !usr.IsHouseBidder)
                {
                    AddressCard ac = dataProvider.UserRepository.GetAddressCard(usr.Billing_AddressCard_ID.GetValueOrDefault(-1), true);
                    Mail.SendOutBidLetter(ac.FirstName, ac.LastName, usr.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, winnerBid.Amount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl);
                }
            }

            /*
             *
             * BidCurrent prevBid = BidRepository.GetUserTopBidForItem(id.Value, cuser.ID, false);
             * if (prevBid != null && (prevBid.IsProxy == ProxyBidding) && prevBid.MaxBid >= BidAmount) return RedirectToAction("AuctionDetail", "Auction", new { @id = id });
             *
             * BidCurrent lastTop = BidRepository.GetTopBidForItem(id.Value);
             * decimal lastMaxBid = (lastTop == null) ? 0 : lastTop.MaxBid;
             * decimal lastamount = (lastTop == null) ? 0 : lastTop.Amount;
             *
             * BiddingObject placedBid = BidRepository.PlaceSingleBid(id.Value, ProxyBidding.Value, BidAmount.Value, cuser.ID, 1, (lastTop != null && lastTop.User_ID == cuser.ID && ProxyBidding.Value), auction.Price, prevBid, lastTop);
             *
             * List<BidLogCurrent> newblogs = new List<BidLogCurrent>();
             * BidRepository.ResolveProxyBiddingSituation(id.Value, cuser.ID, ProxyBidding.Value, placedBid, lastTop, auction.Price, newblogs);
             *
             * BidCurrent currentTop = BidRepository.GetTopBidForItem(id.Value);
             * BidRepository.UpdateUsersTopBid(id.Value, AppSession.CurrentUser.ID, placedBid.Bid);
             * bool IsOutBidden = (lastTop != null && currentTop.MaxBid <= lastTop.MaxBid && currentTop.User_ID != cuser.ID);
             * if (IsOutBidden)
             * {
             * if (placedBid.Bid.Amount >= currentTop.Amount)
             * {
             *  currentTop.Amount = placedBid.Bid.Amount;
             *  BidRepository.UpdateCurrentBid(currentTop);
             * }
             * if (lastamount < currentTop.Amount && newblogs.Where(BL=>BL.User_ID ==currentTop.User_ID && BL.Amount ==currentTop.Amount && BL.MaxBid==currentTop.MaxBid && BL.IsProxy == currentTop.IsProxy).Count()==0)
             *  BidRepository.AddBidLogCurrent(id.Value, currentTop.Quantity, currentTop.User_ID, currentTop.IsProxy, currentTop.Amount, currentTop.MaxBid, false, currentTop.IP);
             * previewBid.Amount = currentTop.Amount;
             * try
             * {
             *  if (cuser.IsRecievingOutBidNotice && !String.IsNullOrEmpty(cuser.Email) && !cuser.IsHouseBidder)
             *    Mail.SendOutBidLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, currentTop.Amount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl);
             * }
             * catch (Exception ex)
             * {
             *  Utils.Lib.Logger.LogException(ex);
             * }
             * AuctionRepository.UpdateAuctionBiddingResult(id.Value, currentTop.User_ID, currentTop.Amount, currentTop.MaxBid);
             * return View("OutBid", previewBid);
             * }
             * AuctionRepository.UpdateAuctionBiddingResult(id.Value, currentTop.User_ID, currentTop.Amount, currentTop.MaxBid);
             * if (lastTop != null && lastTop.User_ID!=cuser.ID)
             * {
             * User usr = dataProvider.UserRepository.GetUser(lastTop.User_ID, true);
             * AddressCard ac = dataProvider.UserRepository.GetAddressCard(usr.Billing_AddressCard_ID.GetValueOrDefault(-1), true);
             * if (usr.IsRecievingOutBidNotice && !String.IsNullOrEmpty(usr.Email) && !usr.IsHouseBidder)
             * {
             *  try
             *  {
             *    Mail.SendOutBidLetter(ac.FirstName, ac.LastName, usr.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, placedBid.Bid.Amount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl);
             *  }
             *  catch (Exception ex)
             *  {
             *    Utils.Lib.Logger.LogException(ex);
             *  }
             * }
             * }
             *
             * try
             * {
             * if (cuser.IsRecievingBidConfirmation && !String.IsNullOrEmpty(cuser.Email) && !cuser.IsHouseBidder)
             * {
             *  if (lastTop == null || lastTop.User_ID != cuser.ID)
             *  {
             *    Mail.SendSuccessfulBidLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, placedBid.Bid.Amount.GetCurrency(), BidAmount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl);
             *  }
             *  else
             *  {
             *    Mail.SendSuccessfulBidUpdateLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, currentTop.Amount.GetCurrency(), currentTop.MaxBid.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl, (lastMaxBid < currentTop.MaxBid));
             *  }
             * }
             * }
             * catch (Exception ex)
             * {
             * Utils.Lib.Logger.LogException(ex);
             * }*/
            return(View("SuccessfulBid", auction));
        }