Beispiel #1
0
        public IEnumerable <Batch> ProductsPast75PercentOfShelfLife()
        {
            List <Batch> ProductsInStoreList = new List <Batch>();

            ProductsInStoreList = BatchRepo.GetAll(x => (x.QuantitySold + x.QuantityAuctioned + x.QuantityDisposedOf) < x.QuantityPurchased).ToList();
            List <Batch> SoonToExpireProductsInList = new List <Batch>();

            foreach (var item in ProductsInStoreList)
            {
                DateTime ManufactureDate = item.ManufactureDate;
                DateTime ExpiryDate      = item.ExpiryDate;

                if (ExpiryDate > DateTime.Now)
                {
                    if (IsProductPast75PercentOfShelfLife(item))
                    {
                        if (ProductToBeAuctionedRepo.GetAll(x => x.BatchId == item.Id).FirstOrDefault() == null &&
                            AuctionRepo.GetAll(x => x.BatchId == item.Id).FirstOrDefault() == null)
                        {
                            ProductToBeAuctionedRepo.Add(new ProductToBeAuctioned()
                            {
                                AuctionPrice             = 0,
                                HasBeenReviewedByManager = false,
                                BatchId = item.Id,
                                //StoreId = new StoreManager().GetStoreId(),
                                DateOfAuction = ReturnAuctionDateUsingPercentageOfShelfLife(80, item),
                            });
                        }

                        SoonToExpireProductsInList.Add(item);
                    }
                }
            }
            return(SoonToExpireProductsInList);
        }
        public void createAuction()
        {
            AuctionRepo cp    = new AuctionRepo(_context, new AuctionMapper());
            ArtRepo     ap    = new ArtRepo(_context, new ArtMapper());
            int         artid = getint("Which Art Piece Do You Want to Auction Off?");

            if (ap.GetArt(artid, seller.Id).Name == "")
            {
                Console.WriteLine("this are does not exist in your inventory");
                return;
            }
            Auction au = new Auction();

            au.Artid       = artid;
            au.Sellerid    = seller.Id;
            au.Closingdate = getDate("When Do you want this Auction to close bidding?");
            //au.Minimumamount = getdec("Minimum Bid?");
            au.Minimumamount = 0.00m;
            Auction getA = cp.AddAuction(au);

            BidRepo bp  = new BidRepo(_context, new BidMapper());
            Bid     bid = new Bid();

            bid.Amount      = 0.01m;
            bid.Collectorid = 20;
            bid.Timeofbid   = DateTime.Now;
            bid.Auctionid   = getA.Id;
            bp.AddBid(bid);
        }
Beispiel #3
0
        public ActionResult ViewProduct(Guid id)
        {
            ViewProductVM Record               = new ViewProductVM();
            Auction       Auction              = AuctionRepo.Get(x => x.Id == id);
            var           AvailabelAuctions    = AuctionLogic.ViewProductsOnAuction();
            var           OtherAuctionsByStore = AvailabelAuctions
                                                 .Where(x => x.Batch.Product.StoreId == Auction.Batch.Product.StoreId && x.Batch.Id != Auction.BatchId)
                                                 .ToList();

            var AuctionsWithSimilarExpiryDate = AvailabelAuctions
                                                .Where(x => x.Batch.ExpiryDate == Auction.Batch.ExpiryDate && x.Batch.Id != Auction.BatchId)
                                                .ToList();

            OnAuctionVM ProductAuction = new OnAuctionVM()
            {
                Product = Auction.Batch.Product,
                Auction = Auction,
                Batch   = Auction.Batch
            };

            Record.Product                       = ProductAuction;
            Record.ProductsFromStore             = OtherAuctionsByStore;
            Record.ProductsWithSimilarExpiryDate = AuctionsWithSimilarExpiryDate;

            return(View(Record));
        }
Beispiel #4
0
        public ActionResult AddToCart(Guid id, int quantity)
        {
            int     Quantity       = quantity;
            Auction Auction        = AuctionRepo.Get(x => x.Id == id);
            Batch   Batch          = Auction.Batch;
            int     AvailableUnits = Batch.QuantityPurchased - (Batch.QuantityAuctioned + Batch.QuantityDisposedOf + Batch.QuantitySold);

            if (Quantity < AvailableUnits)
            {
                Cart CurrentCart = CartRepo.Get(x => x.Auction.BatchId == Auction.BatchId && x.CustomerId == LoggedInUser.Id);
                if (CurrentCart != null)
                {
                    CurrentCart.Quantity += Quantity;
                    CartRepo.Update(CurrentCart);
                }
                else
                {
                    CartRepo.Add(new Cart()
                    {
                        AuctionId  = Auction.Id,
                        Quantity   = Quantity,
                        CustomerId = LoggedInUser.Id
                    });
                }
            }
            else
            {
                return(RedirectToAction("StockUnavailable"));
            }

            return(RedirectToAction("MyCart"));
        }
        public void bid()
        {
            Console.Clear();
            listAuctions();

            AuctionRepo cp    = new AuctionRepo(_context, new AuctionMapper());
            int         bd    = getint("Enter the id of the Auction You would like to bid on");
            Auction     A2Bid = cp.GetAuction(bd);

            if (A2Bid == null)
            {
                Console.WriteLine("please choose a valid auction");
                return;
            }
            BidRepo bp  = new BidRepo(_context, new BidMapper());
            Bid     bid = new Bid();

            bid.Amount = getdec("how much would you like to bid?");;
            Bid highBid = cp.GetHighBid(A2Bid);

            if (highBid != null)
            {
                if (bid.Amount <= highBid.Amount)
                {
                    Console.WriteLine($"Highest Bid is {highBid.Amount} please enter a bid of a higher amount");
                    return;
                }
            }
            bid.Collectorid = collector.Id;
            bid.Timeofbid   = DateTime.Now;
            bid.Auctionid   = A2Bid.Id;
            bp.AddBid(bid);
        }
Beispiel #6
0
        public void Execute(IJobExecutionContext context)
        {
            var auctions = new AuctionRepo().GetAuctions().Where(x => !x.IsClose);

            //List<IndexAuction> list = new List<IndexAuction>();
            //List<string> listStr = new List<string>();
            foreach (var item in auctions)
            {
                var      auction = item;
                bool     result = false, startStatus = auction.StartStatus, isclose = auction.IsClose;
                TimeSpan timer       = new TimeSpan();
                TimeSpan time        = new TimeSpan();
                string   colorStatus = "Black";
                //from database
                //Int64 truncated1 = auction.Auction_Time.Ticks;
                //Int64 adjusted = truncated1 << 24;
                //TimeSpan actual = TimeSpan.FromTicks(adjusted);

                var status = auction.Auction_Time.CompareTo(new TimeSpan(0, 0, 0));
                timer = auction.Auction_Time;
                if (!auction.IsClose)
                {
                    if (timer.CompareTo(new TimeSpan(0, 0, 0)) == 0)
                    {
                        time = timer;
                    }
                    else
                    {
                        time = timer.Subtract(TimeSpan.FromSeconds(1));
                    }
                    if (time.CompareTo(new TimeSpan(0, 0, 0)) == 0)//if time==0
                    {
                        if (timer.CompareTo(new TimeSpan(0, 0, 0)) == 0)
                        {
                            if (!auction.StartStatus)
                            {
                                startStatus = true;
                                time        = TimeSpan.FromSeconds(auction.Close_Time);
                            }
                            else
                            {
                                isclose = true;
                            }
                        }
                    }

                    new AuctionRepo().UpdateTimer2(auction.Id, time, startStatus, isclose);
                }
                //colorStatus = startStatus == true ? "Red" : "Black";
                //var model = new IndexAuction
                //{
                //    Auction_Time = auction.Auction_Time.ToString(),
                //    Color = colorStatus,
                //    Id = auction.Id,
                //    Status = auction.StartStatus

                //};
                //list.Add(model);
            }
        }
        public void listAuctions()
        {
            Console.Clear();
            AuctionRepo cp = new AuctionRepo(_context, new AuctionMapper());

            cp.ShowActiveAuctions();
        }
Beispiel #8
0
        public void DeleteAuction(CommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);

            AuctionRepo.DeleteAuction(id);
            View.ListView.EditIndex = -1;
            View.ListView.DataBind();
        }
Beispiel #9
0
        public IEnumerable <Auction> SelectAuctionsList()
        {
            IEnumerable <Auction> list = AuctionRepo.GetAuctions();

            list = list.Where(p => p.status == "otwarte");
            //catgory filtering
            if ((int)View.FilterCategory > 0)
            {
                list = list.Where(p => p.Category == (int)View.FilterCategory);
            }
            //     ((Aukcje.Site)this.Page.Master).changeValueInDropDowCategoryList((int)category);

            if (!String.IsNullOrEmpty(View.SearchedItem))
            {
                list = list.Where(p => (p.Title.IndexOf(View.SearchedItem, StringComparison.OrdinalIgnoreCase) >= 0));
                //     ((Aukcje.Site)this.Page.Master).changeValueInTextSearchBar(SearchedItem);
            }


            list = list.Where(p => p.Price >= View.FilterLowPrice && p.Price <= View.FilterHighPrice);
            //color filtering

            List <Auction> tempList = new List <Auction>();

            if (View.FilterColorCheckBoxList.SelectedIndex > -1)
            {
                foreach (ListItem listItem in View.FilterColorCheckBoxList.Items)
                {
                    if (listItem.Selected)
                    {
                        tempList.AddRange(list.Where(p => p.Color == Convert.ToInt32(listItem.Value)).ToList());
                    }
                }
                list = tempList;
            }
            //brand filtering

            tempList = new List <Auction>();
            if (View.FilterBrandsCheckBoxList.SelectedIndex > -1)
            {
                foreach (ListItem listItem in View.FilterBrandsCheckBoxList.Items)
                {
                    if (listItem.Selected)
                    {
                        tempList.AddRange(list.Where(p => p.Brand == Convert.ToString(listItem.Text)).ToList());
                    }
                }
                list = tempList;
            }


            foreach (Auction auction in list)
            {
                auction.Price = CurrencyConverter.ConvertMoney(auction.Price);
            }
            return(list);
        }
        public IEnumerable <Aukcje.Auction> SelectItems()
        {
            IEnumerable <Auction> list = AuctionRepo.GetAuctionById(Convert.ToInt32(HttpContext.Current.Request.QueryString["ID"]));

            foreach (Auction auction in list)
            {
                auction.Price = CurrencyConverter.ConvertMoney(auction.Price);
            }
            return(list);
        }
Beispiel #11
0
        public IEnumerable ShowHisAuctions()
        {
            IEnumerable <Aukcje.Auction> list;
            string user = View.loggedUser;

            list = AuctionRepo.GetAuctionsByUser(user);
            foreach (Auction auction in list)
            {
                auction.Price = CurrencyConverter.ConvertMoney(auction.Price);
            }
            return(list);
        }
Beispiel #12
0
        public void AddNewItem()
        {
            try
            {
                string _Brand;
                if (View.DropDownDownListBrand.Visible)
                {
                    _Brand = View.TxtBoxInsertNewBrandProp.Text;
                }
                else
                {
                    _Brand = View.DropDownDownListBrand.SelectedItem.Text;
                }
                Auction currentItem = new Auction()
                {
                    Title = View.AuctionName,
                    //Category = (int)View.AuctionCategoryType,     //this is useful validator if User want to add item that category is not added but now when Categories are added dynamically it is useless
                    Category    = View.AuctionCategoryTypeInt,
                    Color       = View.AuctionColorInt,
                    Description = View.AuctionDescrition,
                    Price       = View.AuctionPrice,
                    seller      = System.Web.Security.Membership.GetUser().UserName,
                    status      = "otwarte",
                    Brand       = _Brand,
                    Image       = View.AuctionImageBytes
                };
                if (View.TxtBoxInsertNewColorProp.Visible)
                {
                    FiltersTable newColor = new FiltersTable()
                    {
                        FilterResourceName = View.TxtBoxInsertNewColorProp.Text
                    };
                    ColorRepo.AddColor(newColor);
                }
                AuctionRepo.AddAuctions(currentItem);
            }
            catch
            {
                View.ControlLabel.Visible = true;

                View.ControlLabel.Text      = "Somenthing went wrong try again lter";
                View.ControlLabel.Font.Size = 32;
            }
            ClearLabels();

            View.ControlLabel.Text      = "Congrats! Your Item was succesfully added";
            View.ControlLabel.Font.Size = 32;
        }
        public List <OnAuctionVM> ViewProductsOnAuction()
        {
            OnAuctionVM        AuctionRecords    = new OnAuctionVM();
            List <Auction>     ActiveAuction     = AuctionRepo.GetAll(x => (x.Batch.QuantitySold + x.Batch.QuantityAuctioned) < x.Batch.QuantityPurchased).ToList();
            List <OnAuctionVM> FullAuctionReport = new List <OnAuctionVM>();

            foreach (var item in ActiveAuction)
            {
                FullAuctionReport.Add(new OnAuctionVM()
                {
                    Auction = item,
                    Batch   = item.Batch,
                    Product = item.Batch.Product
                });
            }

            return(FullAuctionReport);
        }
Beispiel #14
0
        public void CheckForWins()
        {
            AuctionRepo ap = new AuctionRepo(_context, new AuctionMapper());

            switch (active)
            {
            case "artist":
                ap.CheckForComission(artist.Id);
                break;

            case "seller":
                ap.CheckForSale(seller.Id);
                break;

            case "collector":
                ap.CheckForWin(collector.Id);
                break;
            }
        }
Beispiel #15
0
        public IEnumerable <Auction> GetFavAuctions()
        {
            List <Auction> list;
            List <Auction> OutterList = new List <Auction>();

            string user   = View.loggedUser;
            string favIds = MembershipRepo.ReturnFavouritesString(user);

            if (!string.IsNullOrEmpty(favIds))
            {
                List <string> favIdsArray = favIds.Split(new char[] { '|' }).ToList <string>();
                favIdsArray.Sort();
                favIdsArray.RemoveAt(0);
                List <int> favIdsArrayInt = new List <int>(favIdsArray.Select(int.Parse));

                list = AuctionRepo.GetAuctions();
                favIdsArrayInt.Sort();
                //  favIdsArrayInt.RemoveAt(0);
                favIdsArray = favIdsArrayInt.Select(p => p.ToString()).ToList();
                foreach (Auction _auc in list)
                {
                    if (Convert.ToString(_auc.ID) == favIdsArray.FirstOrDefault())
                    {
                        OutterList.Add(list.Where(p => p.ID == Convert.ToInt32(favIdsArray.First())).First());
                        favIdsArray.Remove(favIdsArray.First());
                    }
                }
            }

            foreach (Auction auc in OutterList)
            {
                string stat = auc.status;

                //stat = HttpContext.GetGlobalResourceObject("Resource", stat).ToString();
                if (!string.IsNullOrEmpty(stat))
                {
                    auc.status = stat;
                }
            }
            return(OutterList);
        }
Beispiel #16
0
        public PartialViewResult ProductsByStore(Guid id)
        {
            List <OnAuctionVM> AuctionResult = new List <OnAuctionVM>();

            Store          Store    = StoreRepo.Get(x => x.Id == id);
            List <Auction> Auctions = new List <Auction>();

            Auctions = AuctionRepo.GetAll(x => x.Batch.Product.StoreId == id).ToList();

            foreach (var item in Auctions)
            {
                AuctionResult.Add(new OnAuctionVM()
                {
                    Auction = item,
                    Batch   = item.Batch,
                    Product = item.Batch.Product
                });
            }

            ViewBag.storeName = Store.Name;

            ViewBag.categories = AuctionResult.Select(x => x.Product.Category).Distinct().ToList();
            return(PartialView(AuctionResult));
        }
Beispiel #17
0
        public void ListProductsToBeAuctioned()
        {
            List <ProductToBeAuctioned> productsToBeAuctioned = new List <ProductToBeAuctioned>();

            ProductToBeAuctionedRepo.GetAll(x => x.HasBeenReviewedByManager == true).ToList().ForEach(productToBeAuctioned => {
                if (productToBeAuctioned.DateOfAuction.Date == DateTime.Now.Date)
                {
                    productsToBeAuctioned.Add(productToBeAuctioned);
                }
            });

            productsToBeAuctioned.ForEach(product => {
                AuctionRepo.Add(new Auction
                {
                    AuctionPrice = product.AuctionPrice,
                    BatchId      = product.BatchId,
                });
            });

            productsToBeAuctioned.Select(x => x.Id).ToList().ForEach(id =>
            {
                ProductToBeAuctionedRepo.Delete(id);
            });
        }
Beispiel #18
0
        public IEnumerable <Aukcje.Models.CommentWithAuction> SelectComments()
        {
            string sellerName = HttpContext.Current.Request.QueryString["UID"] ?? View.UName;

            return(AuctionRepo.GetClosedAuctions(sellerName));
        }
 public AuctionController()
 {
     _repo = new AuctionRepo();
 }
Beispiel #20
0
 public void UpdateAuction(Aukcje.Auction objAuction)
 {
     AuctionRepo.UpdateAuction(objAuction, View.ImageBytes);
 }