// GET: AuctionsAdmin/Create
        public ActionResult Create()
        {
            //ViewBag.Path = "~/Images/";
            ltRollDescription rol          = new ltRollDescription();
            DefaultSetup      defaultSetup = db.DefaultSetups.FirstOrDefault(t => t.Active == true);

            rol.BackgroundColor     = defaultSetup.BackgroundColor;
            rol.FontColor           = defaultSetup.FontColor;
            rol.RefreshTime         = defaultSetup.RefreshTime;
            rol.StartDate           = DateTime.Now;
            rol.EndDate             = DateTime.Now;
            rol.AuctionDelayTime    = 5;
            rol.LogoPath            = defaultSetup.LogoPath;
            rol.LogoName            = defaultSetup.LogoName;
            rol.SmallLogoName       = defaultSetup.SmallLogoName;
            rol.RollImagesPath      = defaultSetup.RollImagesPath;
            rol.SmsNotification     = true;
            rol.LogoBackgroundColor = defaultSetup.LogoBackgroundColor;
            rol.smsOutBidder        = defaultSetup.smsOutBidder;
            rol.RollImagesBackColor = defaultSetup.BackgroundColor;

            rol.HomePeriodDescriptionBackColor = defaultSetup.HomePeriodDescriptionBackColor;
            rol.ActionBackColor          = defaultSetup.ActionBackColor;
            rol.RollActionBidColor       = defaultSetup.RollActionBidColor;
            rol.RollActionBackIndexColor = defaultSetup.RollActionBackIndexColor;



            return(View(rol));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ltRollDescription ltRollDescription = db.ltRollDescriptions.Find(id);

            db.ltRollDescriptions.Remove(ltRollDescription);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,Description,Active,BackgroundColor,FontColor,RefreshTime,StartDate,EndDate,AuctionDelayTime,SortPosition,LogoPath,LogoName,SmallLogoName,RollImagesPath,SmsNotification,LogoBackgroundColor, smsOutBidder, RollImagesBackColor, HomePeriodDescription, HomePeriodDescriptionTextColor, HomePeriodDescriptionBackColor, ActionTextColor, ActionBackColor, RollActionBidColor, RollActionBackIndexColor")] ltRollDescription ltRollDescription)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ltRollDescription).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ltRollDescription));
 }
        // GET: AuctionsAdmin/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ltRollDescription ltRollDescription = db.ltRollDescriptions.Find(id);

            if (ltRollDescription == null)
            {
                return(HttpNotFound());
            }
            return(View(ltRollDescription));
        }
Ejemplo n.º 5
0
        // GET: RollAdmin/Create
        public ActionResult Create()
        {
            int?AuctionID;

            if (Session["SelectedAuctionID"] == null) // IF sesion var not created yet, create
            {
                BidController     bd = new BidController();
                DefaultSetupModel dm = bd.LoadDefs(0);               // Get the default values
                AuctionID = dm.DefaultAuction;
                Session["SelectedAuctionID"] = AuctionID.ToString(); // Set sesion var met wat geselekteer is
            }
            else
            {
                AuctionID = Int32.Parse(Session["SelectedAuctionID"].ToString());
            }

            ViewBag.auctionID = AuctionID;
            ViewBag.RollId    = new SelectList(db.ltRollDescriptions, "ID", "Description", AuctionID);

            //            ViewBag.RollId = new SelectList(db.ltRollDescriptions, "ID", "Description");
            ViewBag.SpeciesCode = new SelectList(db.ltSpecies, "ID", "Description");
            ViewBag.BuyerId     = new SelectList(db.tblCustomers, "ID", "CompanyName");
            ViewBag.SellerId    = new SelectList(db.tblCustomers, "ID", "CompanyName");
            tblRoll           rol = new tblRoll();
            ltRollDescription ltRollDescription = db.ltRollDescriptions.Find(AuctionID);

            if (ltRollDescription != null)
            {
                rol.Quantity_Lot  = "Animal";
                rol.OnAuction     = true;
                rol.DateTimeClose = ltRollDescription.EndDate;
                rol.DateLoaded    = DateTime.Now;
                rol.BidOpen       = true;
            }

            return(View(rol));
        }
Ejemplo n.º 6
0
        // Hier
        public Bid BidLogic(Bid bid)
        {
            currentBuyer.NewBuyerHaveCellNumber = false;
            currentBuyer.OutBuyerHaveCellNumber = false;
            currentBuyer.NewBuyerID             = bid.BuyerId;     // Die nuwe id wat oorkom.

            using (AuctionDBEntities db = new AuctionDBEntities()) // make sure to get the latest info from DB and not the immage of DB.
            {
                tblRoll tblRollAfter = db.tblRolls.Find(bid.ID);   // find the latest info on db.
                if (tblRollAfter.Increments == null)
                {
                    tblRollAfter.Increments = 0;
                }
                if (tblRollAfter.BiddingPrice == null)
                {
                    tblRollAfter.BiddingPrice = 0;
                }
                if (bid.NewBidPrice >= (tblRollAfter.BiddingPrice + tblRollAfter.Increments))
                {
                    double            ExtendBitTime;
                    bool              AuctionSMS         = false;
                    ltRollDescription ltRollDescriptions = db.ltRollDescriptions.Find(bid.RollId);
                    if (ltRollDescriptions != null)
                    {
                        ExtendBitTime = System.Convert.ToDouble(ltRollDescriptions.AuctionDelayTime);
                        AuctionSMS    = ltRollDescriptions.SmsNotification;
                    }
                    else
                    {
                        ExtendBitTime = 5;
                        AuctionSMS    = false;
                    }

                    //

                    bid.BidTotalPrice = bid.NewBidPrice * tblRollAfter.Quantity;
                    if (DateTime.Now <= tblRollAfter.DateTimeClose)
                    {
                        tblRollAfter.DateTimeBid = DateTime.Now;

                        if (DateTime.Now.AddMinutes(ExtendBitTime) >= tblRollAfter.DateTimeClose)
                        {
                            tblRollAfter.DateTimeClose = DateTime.Now.AddMinutes(ExtendBitTime); // add time before close.
                            db.UpdateBidTimeClose(bid.ID, tblRollAfter.DateTimeClose);
                        }
                        // Kan later weer terugsit.
                        //if (currentBuyer.NewBuyerID != tblRollAfter.BuyerId) // Not same outgoing and new bidder.
                        //{
                        // Get outgoing bidder info
                        tblCustomer tblCustomersOut = db.tblCustomers.Find(tblRollAfter.BuyerId);
                        currentBuyer.OutBuyerCell = tblCustomersOut.Phone;
                        if (currentBuyer.OutBuyerCell != null && currentBuyer.OutBuyerCell != "")
                        {
                            currentBuyer.OutBuyerHaveCellNumber = true;
                        }

                        // Get incomming bidder info

                        tblCustomer tblCustomersIn = db.tblCustomers.Find(currentBuyer.NewBuyerID);
                        currentBuyer.NewBuyerCell = tblCustomersIn.Phone;
                        if (currentBuyer.NewBuyerCell != null && currentBuyer.NewBuyerCell != "")
                        {
                            currentBuyer.NewBuyerHaveCellNumber = true;
                        }
                        //                        }

                        // Huidige koper

                        // Laaste voor update.
                        tblRoll tblRollLast = db.tblRolls.Find(bid.ID); // find the latest info on db.
                        if (tblRollLast.Increments == null)
                        {
                            tblRollLast.Increments = 0;
                        }
                        if (tblRollLast.BiddingPrice == null)
                        {
                            tblRollLast.BiddingPrice = 0;
                        }

                        if (bid.NewBidPrice >= (tblRollLast.BiddingPrice + tblRollLast.Increments))
                        {
                            if (tblRollLast.Quantity_Lot == "Lot")
                            {
                                bid.BidTotalPrice = bid.NewBidPrice;
                            }
                            else
                            {
                                bid.BidTotalPrice = bid.NewBidPrice * tblRollAfter.Quantity;
                            }

                            // Kry die Auction Buyer Nommer

                            string AuctionBuyerNumber;

                            BuyerNo buyeNo = db.BuyerNoes.FirstOrDefault(t => t.CustomerID == bid.BuyerId && t.RollID == bid.RollId);
                            if (buyeNo == null)
                            {
                                AuctionBuyerNumber = "INT " + bid.BuyerId.ToString();
                            }
                            else
                            {
                                AuctionBuyerNumber = "B " + buyeNo.BuyerNumber;
                            }

                            db.UpdateBidder(bid.ID, bid.BuyerId, bid.NewBidPrice, bid.BidTotalPrice, tblRollAfter.DateTimeBid, AuctionBuyerNumber);
                            db.AddBidHistory(bid.ID, bid.RollId, tblRollAfter.Lot, tblRollAfter.SellerId, bid.BuyerId, bid.NewBidPrice, bid.BidTotalPrice, tblRollAfter.DateTimeBid, bid.UserID);

                            // Laai defaults

                            DefaultSetupModel dm = LoadDefs(0); // Get the default values vir stuur van sms

                            // Sal net sms stuur as koper cell het, spesifieke auction verys dit en default is aan.

                            // Sms outgoing bidder
                            if (currentBuyer.OutBuyerHaveCellNumber && AuctionSMS && dm.SMSAllFunctionality == true && dm.SMSOutBidder == true)
                            {
                                string x = string.Format("{0:0,000}", bid.NewBidPrice);

                                smsMGT smg           = new smsMGT();
                                string messagestring = $"Silent auction: Your bid for Lot {tblRollAfter.Lot} has been exceeded. Current bid is : R {x}";
                                var    res           = smg.SendSingleSMS("1", currentBuyer.OutBuyerCell, messagestring);
                                if (res != "success")
                                {
                                    string    EmailSubject = "SMS NOT sent successfully";
                                    string    EMailBody    = $"SMS NOT sent successfully to out bidder {tblCustomersOut.CompanyName}" + ".  Error = " + res;
                                    sendEmail sm           = new sendEmail();
                                    string    emalres      = sm.SendEmailFB("*****@*****.**", EmailSubject, EMailBody, null, null);
                                }
                            }

                            // Sms new bidder.
                            if (currentBuyer.NewBuyerHaveCellNumber && AuctionSMS && dm.SMSAllFunctionality == true && dm.SMSNewBidder == true)
                            {
                                string y = string.Format("{0:0,000}", bid.NewBidPrice);

                                smsMGT smg           = new smsMGT();
                                string messagestring = $"Silent auction: Your bid for Lot {tblRollAfter.Lot} has been accepted. Your bid is : R {y}";
                                var    res           = smg.SendSingleSMS("1", currentBuyer.NewBuyerCell, messagestring);

                                if (res != "success")
                                {
                                    string    EmailSubject = "SMS NOT sent successfully";
                                    string    EMailBody    = $"SMS NOT sent successfully to new bidder {tblCustomersIn.CompanyName}" + "  " + res;
                                    sendEmail sm           = new sendEmail();
                                    string    emalres      = sm.SendEmailFB("*****@*****.**", EmailSubject, EMailBody, null, null);
                                }
                            }
                            if (bid.NewBidPrice >= (tblRollAfter.BiddingPrice + (tblRollAfter.Increments * 10)))
                            {
                                // email warning to NWWT
                                sendEmail sm           = new sendEmail();
                                string    y            = string.Format("{0:0,000}", bid.NewBidPrice);
                                string    z            = string.Format("{0:0,000}", tblRollAfter.BiddingPrice);
                                string    EmailSubject = "An extraordinary high bid received";
                                string    EMailBody    = $"An extraordinary high bid was made on Lot {tblRollAfter.Lot} by {tblCustomersIn.CompanyName}. The new bid is : R {y} and the previous bid was R {z}";
                                string    res          = sm.SendEmailFB("*****@*****.**", EmailSubject, EMailBody, null, null);
                            }
                        }
                        else
                        {
                            bid.bidToLow = true;
                        }
                    }
                    else
                    {
                        bid.bidClosed = true;
                    }
                }
                else
                {
                    bid.bidToLow = true;
                }
            }
            return(bid);
        }
Ejemplo n.º 7
0
        public DefaultSetupModel LoadDefs(int?AuctionID)
        {
            DefaultSetupModel ds = new DefaultSetupModel();

            // Laai eers alles vanaf DefaultSetup table.

            DefaultSetup defaultSetup = db.DefaultSetups.FirstOrDefault(t => t.Active == true);

            if (defaultSetup != null)                          // het gekry.
            {
                ds.ID                             = AuctionID; // Het gekry en rollID is dus reg.
                ds.Description                    = defaultSetup.Description;
                ds.BackgroundColor                = defaultSetup.BackgroundColor;
                ds.FontColor                      = defaultSetup.FontColor;
                ds.LogoBackgroundColor            = defaultSetup.LogoBackgroundColor;
                ds.RefreshTime                    = defaultSetup.RefreshTime.ToString();
                ds.RollImagePath                  = defaultSetup.RollImagesPath;
                ds.Active                         = defaultSetup.Active;
                ds.LogoPath                       = defaultSetup.LogoPath;
                ds.LogoName                       = defaultSetup.LogoName;
                ds.SmallLogoName                  = defaultSetup.LogoPath;
                ds.RollImagePath                  = defaultSetup.RollImagesPath;
                ds.AuctionDelayTime               = defaultSetup.AuctionDelayTime.ToString();
                ds.SMSNewBidder                   = defaultSetup.SmsNotification;
                ds.SMSAllFunctionality            = defaultSetup.SMSAllFunctionality;
                ds.SMSCustRegistration            = defaultSetup.SMSCustRegistration;
                ds.SMSConfirmationLoginRequired   = defaultSetup.SMSConfirmationLoginRequired;
                ds.emailConfirmRegistration       = defaultSetup.emailConfirmRegistration;
                ds.emailConfirmationLoginRequired = defaultSetup.emailConfirmationLoginRequired;
                ds.BackgroundColorHome            = defaultSetup.BackgroundColorHome;
                ds.DispLines                      = defaultSetup.DispLines;
                ds.DispColumns                    = defaultSetup.DispColumns;
                ds.pageSize                       = ds.DispLines * ds.DispColumns;
                ds.RollDispRefreshRate            = defaultSetup.RollDispRefreshRate;

                ds.HomePeriodDescription          = defaultSetup.HomePeriodDescription;
                ds.HomePeriodDescriptionTextColor = defaultSetup.HomePeriodDescriptionTextColor;
                ds.HomePeriodDescriptionBackColor = defaultSetup.HomePeriodDescriptionBackColor;
                ds.ActionTextColor = defaultSetup.ActionTextColor;
                ds.ActionBackColor = defaultSetup.ActionBackColor;



                if (defaultSetup.DefaultAuction != null)
                {
                    ds.DefaultAuction = defaultSetup.DefaultAuction;
                }
                else
                {
                    ds.DefaultAuction = 0;
                }
                ds.SMSOutBidder = defaultSetup.smsOutBidder;


                ds.message = "Please select an Auction";
            }

            if (AuctionID != 0) // Laai rol spesifieke inligting
            {
                ltRollDescription ltRollDescriptions = db.ltRollDescriptions.Find(AuctionID);
                if (ltRollDescriptions != null)                         // het gekry.
                {
                    ds.ID                       = AuctionID;            // Het gekry en rollID is dus reg.
                    ds.AuctionID                = AuctionID.ToString(); // String van ID
                    ds.Description              = ltRollDescriptions.Description;
                    ds.BackgroundColor          = ltRollDescriptions.BackgroundColor;
                    ds.FontColor                = ltRollDescriptions.FontColor;
                    ds.LogoBackgroundColor      = ltRollDescriptions.LogoBackgroundColor;
                    ds.RefreshTime              = ltRollDescriptions.RefreshTime.ToString();
                    ds.RollImagePath            = ltRollDescriptions.RollImagesPath;
                    ds.Active                   = ltRollDescriptions.Active;
                    ds.LogoPath                 = ltRollDescriptions.LogoPath;
                    ds.LogoName                 = ltRollDescriptions.LogoName;
                    ds.SmallLogoName            = ltRollDescriptions.LogoPath;
                    ds.RollImagePath            = ltRollDescriptions.RollImagesPath;
                    ds.AuctionDelayTime         = ltRollDescriptions.AuctionDelayTime.ToString();
                    ds.SMSNewBidder             = ltRollDescriptions.SmsNotification;
                    ds.SMSOutBidder             = ltRollDescriptions.smsOutBidder;
                    ds.RollImagesBackColor      = ltRollDescriptions.RollImagesBackColor;
                    ds.RollActionBidColor       = ltRollDescriptions.RollActionBidColor;
                    ds.RollActionBackIndexColor = ltRollDescriptions.RollActionBackIndexColor;

                    ds.HomePeriodDescription          = ltRollDescriptions.HomePeriodDescription;
                    ds.HomePeriodDescriptionTextColor = ltRollDescriptions.HomePeriodDescriptionTextColor;
                    ds.HomePeriodDescriptionBackColor = ltRollDescriptions.HomePeriodDescriptionBackColor;
                    ds.ActionTextColor = ltRollDescriptions.ActionTextColor;
                    ds.ActionBackColor = ltRollDescriptions.ActionBackColor;

                    ds.message = "Roll not loaded yet. Will be available soon!";
                }
            }
            return(ds);
        }