Ejemplo n.º 1
0
        public ActionResult Login(string returnUrl)
        {
            ViewBag.ReturnUrl = returnUrl;

            // FB Added
            string aid = "0";
            int?   rollID;

            if (Session["auctionID"] == null)
            {
                rollID = 0;
            }
            else
            {
                aid    = Session["auctionID"].ToString();
                rollID = Int32.Parse(aid);
            }


            // Find user record for role id.

            BidController     bd = new BidController();
            DefaultSetupModel dm = bd.LoadDefs(rollID); // Get the default values


            ViewBag.BackgroundColor     = dm.BackgroundColor;
            ViewBag.TexColor            = dm.FontColor;
            ViewBag.LogoBackgroundColor = dm.LogoBackgroundColor;
            ViewBag.LogoPath            = dm.LogoPath;
            ViewBag.LogoName            = dm.LogoName;

            return(View());
        }
Ejemplo n.º 2
0
        // GET: RollDisplay
        public ActionResult Index()
        {
            string sessionID = "0";

            if (Session["auctionID"] == null) // Must have selected an auction.
            {
                // Gaan terug na roll
                TempData["msg"] = "<script>alert('Select an auction first');</script>";
                return(RedirectToAction("Index", "Home"));
            }

            sessionID = Session["auctionID"].ToString();
            int AuctionID = AuctionID = Int32.Parse(sessionID);

            BidController     bd = new BidController();
            DefaultSetupModel dm = bd.LoadDefs(AuctionID); // Get the default values

            int?rollID = dm.ID;

            ViewBag.BackgroundColor     = dm.BackgroundColor;
            ViewBag.TexColor            = dm.FontColor;
            ViewBag.LogoBackgroundColor = dm.LogoBackgroundColor;
            ViewBag.ImagePath           = dm.RollImagePath;
            ViewBag.LogoPath            = dm.LogoPath;
            ViewBag.LogoName            = dm.LogoName;
            ViewBag.RefreshTime         = dm.RefreshTime.ToString();
            ViewBag.ImagePath           = dm.RollImagePath;
            ViewBag.emptyMessage        = dm.message;

            string initApp = "Web";

            if (Session["InitApp"] != null)
            {
                initApp = Session["InitApp"].ToString();
            }


            if (initApp == "App")
            {
                ViewBag.Columns = 0;
            }
            else
            {
                ViewBag.Columns = 2;
            }


            var tblRolls = db.tblRolls.Include(t => t.ltRollDescription).Include(t => t.ltRollDescription1).Include(t => t.ltSpecy).Include(t => t.tblCustomer).Where(t => t.RollId == rollID);

            return(View(tblRolls.ToList()));
        }
Ejemplo n.º 3
0
        public ActionResult Bid([Bind(Include = "ID,RollId,Lot,SpeciesCode,TagNr,Age,DateMeasured,HornLength,TipToTip,OtherInfo,DateAvailable,Male,Female,Young,Quantity,Quantity_Lot,SellerId,BuyerId,BiddingPrice,BidDateTime,BidTotalPrice,NewBidPrice,NewBidder,Picture,OnAuction,Sold,DateLoaded,DateSold,PicturePath,PictureName,Increments,ReservePrice,LotQ,DateTimeBid,DateTimeClose,CustomerNumber")] tblRoll tblRoll)
        {
            if (ModelState.IsValid)
            {
                BidController bd  = new BidController();
                Bid           bid = new Bid();
                bid.ID          = tblRoll.ID;
                bid.BuyerId     = Int32.Parse(tblRoll.CustomerNumber);
                bid.NewBidPrice = tblRoll.NewBidPrice;
                bid.RollId      = tblRoll.RollId;

                // Kry die user inligting
                tblCustomer tblCustomersLog = db.tblCustomers.FirstOrDefault(i => i.CustomerID == User.Identity.Name);
                if (tblCustomersLog != null)
                {
                    bid.UserID = tblCustomersLog.ID; // Kry ID van persoon wat ingelog het.
                }

                Bid dm = bd.BidLogic(bid); // Process bid!

                if (bid.bidToLow)
                {
                    TempData["msg"] = "<script>alert('Bidding price must be higher than current bid + increment');</script>";
                    return(RedirectToAction("Bid", tblRoll.ID));
                }
                if (bid.bidClosed)
                {
                    TempData["msg"] = "<script>alert('Bid has closed');</script>"; // Moet dit toets
                    return(RedirectToAction("Bid", tblRoll.ID));
                }

                return(RedirectToAction("Index", new { AuctionID = tblRoll.RollId }));
            }

            ViewBag.RollId  = new SelectList(db.ltRollDescriptions, "ID", "Description", tblRoll.RollId);
            ViewBag.BuyerId = new SelectList(db.tblCustomers, "ID", "CompanyName", tblRoll.BuyerId);
//            ViewBag.CustomerNumber = new SelectList(db.BuyerNoes, "CustomerID", "BuyerNumber", tblRoll.BuyerId);
            ViewBag.CustomerNumber = db.BuyerNoes.OrderBy(t => t.BuyerNumber).Where(g => g.CustomerID != null).Select(rr => new SelectListItem {
                Value = rr.CustomerID.ToString(), Text = rr.BuyerNumber + "   (" + rr.tblCustomer.CompanyName + ")"
            }).ToList();

            return(View(tblRoll));
        }
        // GET: BuyerNumber/Create
        public ActionResult Create(RollAdminModel rollAdminModel)
        {
            if (Session["SelectedAuctionID"] == null) // behoort te bestaan
            {
                BidController     bd = new BidController();
                DefaultSetupModel dm = bd.LoadDefs(0); // Get the default values
                rollAdminModel.AuctionID     = dm.DefaultAuction;
                Session["SelectedAuctionID"] = rollAdminModel.AuctionID.ToString();
            }
            else
            {
                int Selectedauction = Int32.Parse(Session["SelectedAuctionID"].ToString());
                rollAdminModel.AuctionID = Selectedauction;
            }

            ViewBag.CustomerID = new SelectList(db.tblCustomers, "ID", "CompanyName");
            ViewBag.RollID     = new SelectList(db.ltRollDescriptions, "ID", "Description", rollAdminModel.AuctionID);
            ViewBag.rollIDBag  = rollAdminModel.AuctionID;
            return(View());
        }
Ejemplo n.º 5
0
        // GET: RollAdmin
        public ActionResult Index(RollAdminModel rollAdminModel)
        {
            if (Session["SelectedAuctionID"] == null) // IF sesion var not created yet, create
            {
                Session["SelectedAuctionID"] = "0";
            }
            if (rollAdminModel.AuctionID == 0 || rollAdminModel.AuctionID == null) // kry gegewens vanag default table.
            {
                BidController     bd = new BidController();
                DefaultSetupModel dm = bd.LoadDefs(0); // Get the default values
                rollAdminModel.AuctionID = dm.DefaultAuction;
            }

            Session["SelectedAuctionID"] = rollAdminModel.AuctionID.ToString(); // Set sesion var met wat geselekteer is

            ViewBag.rollIDBag = rollAdminModel.AuctionID;
            ViewBag.AuctionID = new SelectList(db.ltRollDescriptions, "Id", "Description", rollAdminModel.AuctionID);

            var tblRolls = db.tblRolls.Include(t => t.ltRollDescription).Include(t => t.ltRollDescription1).Include(t => t.ltSpecy).Include(t => t.tblCustomer).Include(t => t.tblCustomer1).Where(t => t.RollId == rollAdminModel.AuctionID);

            return(View(tblRolls.ToList()));
        }
Ejemplo n.º 6
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.º 7
0
        public ActionResult Bid([Bind(Include = "ID,RollId,Lot,SpeciesCode,TagNr,Age,DateMeasured,HornLength,TipToTip,OtherInfo,DateAvailable,Male,Female,Young,Quantity,Quantity_Lot,SellerId,BuyerId,BiddingPrice,BidDateTime,BidTotalPrice,NewBidPrice,NewBidder,Picture,OnAuction,Sold,DateLoaded,DateSold,PicturePath,PictureName,Increments,ReservePrice,LotQ,DateTimeClose,CustomerNumber")] tblRoll tblRoll)
        {
            if (ModelState.IsValid)
            {
                // nuut
                BidController bd  = new BidController();
                Bid           bid = new Bid();
                bid.ID          = tblRoll.ID;
                bid.NewBidPrice = tblRoll.NewBidPrice;
                bid.RollId      = tblRoll.RollId;
                // Kry die user inligting

                //                var user = UserManager.FindByNameAsync("PIET");

                tblCustomer tblCustomersLog = db.tblCustomers.FirstOrDefault(i => i.CustomerID == User.Identity.Name);

                if (tblCustomersLog.PIN != tblRoll.CustomerNumber)
                {
                    TempData["msg"] = "<script>alert('Incorrect PIN');</script>";
                    return(RedirectToAction("Bid", tblRoll.ID));
                }
                if (tblCustomersLog != null)
                {
                    bid.BuyerId = tblCustomersLog.ID; // Kry ID van persoon wat ingelog het.
                    bid.UserID  = tblCustomersLog.ID; // Buyer is ook User.
                }

                Bid dm = bd.BidLogic(bid); // Process bid!

                if (bid.bidToLow)
                {
                    TempData["msg"] = "<script>alert('Bidding price must be higher than current bid + increment');</script>";
                    return(RedirectToAction("Bid", tblRoll.ID));
                }
                if (bid.bidClosed)
                {
                    TempData["msg"] = "<script>alert('Bid has closed');</script>"; // Moet dit toets
                    return(RedirectToAction("Bid", tblRoll.ID));
                }

                return(RedirectToAction("Index", new { AuctionID = tblRoll.RollId }));

                // end nuut
            }
            else
            {
                string initApp;

                if (Session["InitApp"] == null)
                {
                    Session["InitApp"] = "Web"; // creat InitApp as web init if nothing received
                }
                initApp = Session["InitApp"].ToString();

                if (initApp == "App")
                {
                    return(View("BidApp", tblRoll));
                }
                else
                {
                    return(View(tblRoll));
                }
            }
        }
Ejemplo n.º 8
0
        public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            BidController     loadDefs = new BidController();
            DefaultSetupModel dms      = loadDefs.LoadDefs(0); // Get the default values

            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);

                if (user == null)
                {
                    ViewBag.errorMessage = "Email address provided is not registered. Please use correct email address or register as user";
                    return(View("Error"));
                }

                if (dms.emailConfirmationLoginRequired == true)
                {
                    if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
                    {
                        // Don't reveal that the user does not exist or is not confirmed
                        // return View("ForgotPasswordConfirmation"); // Moet error gee.
                        ViewBag.errorMessage = "Email address not confirmed";
                        return(View("Error"));
                    }
                }
                if (dms.SMSConfirmationLoginRequired == true)
                {
                    if (user == null || !(await UserManager.IsPhoneNumberConfirmedAsync(user.Id)))
                    {
                        // Don't reveal that the user does not exist or is not confirmed
                        //                        return View("ForgotPasswordConfirmation"); // Moet error gee.
                        ViewBag.errorMessage = "Cell Phone number not confirmed";
                        return(View("Error"));
                    }
                }

                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                // Send an email with this link

                //string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                //var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);

                // Fouche
                bool confirmation = false;
                // Stuur confirmation email as nodig
                if (dms.emailConfirmRegistration == true)
                {
                    string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                    //                    string callbackUrl = await SendEmailConfirmationTokenAsync(user.Id, "Confirm your account");
                    var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    ViewBag.Message = "Check your email and confirm your account, you must be confirmed "
                                      + "before you can log in.";
                    confirmation = true;
                    await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
                }
                if (dms.SMSAllFunctionality == true && dms.SMSCustRegistration == true)
                {
                    // Generate OTP
                    var smscode = await UserManager.GenerateChangePhoneNumberTokenAsync(user.Id, user.PhoneNumber);

                    // FB added
                    smsMGT smg           = new smsMGT();
                    string messagestring = "Your security code for Silent Auction is: " + smscode;
                    var    res           = smg.SendSingleSMS("1", user.PhoneNumber, messagestring);
                    if (res != "success")
                    {
                        string    EmailSubject = "OTP SMS NOT sent successfully";
                        string    EMailBody    = $"OTP SMS NOT sent successfully to customer {user.CompanyName}" + " Forgot Password " + ".  Error = " + res;
                        sendEmail sm           = new sendEmail();
                        string    emalres      = sm.SendEmailFB("*****@*****.**", EmailSubject, EMailBody, null, null);
                        ViewBag.errorMessage = "Cell Phone number not correct. Log in and provide correct number or contact NWWT at [email protected]";
                        return(View("Error"));
                    }


                    //
                    confirmation = true;
                    return(RedirectToAction("VerifyPhoneNumberPasswordChange", new { PhoneNumber = user.PhoneNumber, id = user.Id }));
                }
                if (!confirmation)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    //                    return RedirectToAction("Index", "Home");
                    return(RedirectToAction("ForgotPasswordConfirmation", "Account"));
                }
                return(RedirectToAction("ForgotPasswordConfirmation", "Account"));
            }
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Ejemplo n.º 9
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            // FB Added
            string aid = "0";
            int?   rollID;

            if (Session["auctionID"] == null)
            {
                rollID = 0;
            }
            else
            {
                aid    = Session["auctionID"].ToString();
                rollID = Int32.Parse(aid);
            }

            BidController     bd = new BidController();
            DefaultSetupModel dm = bd.LoadDefs(rollID); // Get the default values

            ViewBag.BackgroundColor     = dm.BackgroundColor;
            ViewBag.TexColor            = dm.FontColor;
            ViewBag.LogoBackgroundColor = dm.LogoBackgroundColor;
            ViewBag.LogoPath            = dm.LogoPath;
            ViewBag.LogoName            = dm.LogoName;

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    CompanyName = model.CompanyName, PhoneNumber = model.PhoneNumber, UserName = model.Email, Email = model.Email, CustomerID = model.CustomerID, ContactPerson = model.ContactPerson, ContactCellPhone = model.ContactCellPhone, PIN = model.PIN
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                // User is created in Accounts table

                if (result.Succeeded)
                {
                    UserManager.AddClaim(user.Id, new Claim(ClaimTypes.GivenName, model.CompanyName));

                    // FB added this
                    // User is successfully created in Accounts table.
                    // Create Customer record with Basic info al is die inligting nie bevestig deur email of sms
                    //

                    tblCustomer tblCustomers  = new tblCustomer();
                    tblCustomer tblCustomerEx = db.tblCustomers.FirstOrDefault(i => i.CustomerID == model.Email);
                    string      companyName;
                    string      Email;

                    if (tblCustomerEx == null)                    // voeg by
                    {
                        tblCustomers.CustomerID    = model.Email; // Kan dalk later verander.
                        tblCustomers.CompanyName   = model.CompanyName;
                        tblCustomers.CompanyID     = model.CustomerID;
                        tblCustomers.eMail         = model.Email;
                        tblCustomers.Phone         = model.PhoneNumber;
                        tblCustomers.ContactPerson = model.ContactPerson;
                        tblCustomers.CellPhone     = model.ContactCellPhone;
                        tblCustomers.Active        = true;
                        tblCustomers.VATRegistered = false;
                        tblCustomers.PIN           = model.PIN;
                        companyName = model.CompanyName;
                        Email       = model.Email;

                        db.tblCustomers.Add(tblCustomers);
                        db.SaveChanges();
                    }
                    else
                    {
                        tblCustomer tblCustomersF = db.tblCustomers.FirstOrDefault(i => i.CustomerID == model.Email);
                        db.Entry(tblCustomersF).State = EntityState.Modified;
                        tblCustomersF.CompanyName     = model.CompanyName;
                        tblCustomersF.CompanyID       = model.CustomerID;
                        tblCustomersF.eMail           = model.Email;
                        tblCustomersF.Phone           = model.PhoneNumber;
                        tblCustomersF.ContactPerson   = model.ContactPerson;
                        tblCustomersF.CellPhone       = model.ContactCellPhone;
                        tblCustomersF.Active          = true;
                        tblCustomersF.VATRegistered   = false;
                        tblCustomersF.PIN             = model.PIN;
                        companyName = model.CompanyName;
                        Email       = model.Email;

                        db.SaveChanges();
                    }

                    BidController     loadDefs = new BidController();
                    DefaultSetupModel dms      = loadDefs.LoadDefs(0); // Get the default values
                    bool confirmation          = false;
                    // Stuur confirmation email as nodig
                    if (dms.emailConfirmRegistration == true)
                    {
                        string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                        string callbackUrl = await SendEmailConfirmationTokenAsync(user.Id, "Confirm your account");

                        ViewBag.Message = "Check your email and confirm your account, you must be confirmed "
                                          + "before you can log in.";
                        await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                        confirmation = true;
                    }
                    if (dms.SMSAllFunctionality == true && dms.SMSCustRegistration == true)
                    {
                        // Generate OTP
                        var smscode = await UserManager.GenerateChangePhoneNumberTokenAsync(user.Id, model.PhoneNumber);

                        // FB added
                        smsMGT smg           = new smsMGT();
                        string messagestring = "Your security code for Silent Auction is: " + smscode;
                        var    res           = smg.SendSingleSMS("1", model.PhoneNumber, messagestring);

                        if (res != "success")
                        {
                            string    EmailSubject = "OTP SMS NOT sent successfully";
                            string    EMailBody    = $"OTP SMS NOT sent successfully to new customer {model.CompanyName}" + ".  Error = " + res + " Number " + model.PhoneNumber;
                            sendEmail sm           = new sendEmail();
                            string    emalres      = sm.SendEmailFB("*****@*****.**", EmailSubject, EMailBody, null, null);
                            ViewBag.errorMessage = "Cell Phone number not correct. Log in and provide correct number or contact NWWT at [email protected]";
                            return(View("Error"));
                            /// FB
                        }
                        confirmation = true;
                        return(RedirectToAction("VerifyPhoneNumber", new { PhoneNumber = model.PhoneNumber, id = user.Id, email = Email, compName = companyName }));
                    }
                    if (!confirmation)
                    {
                        await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                        return(RedirectToAction("Index", "Home"));
                    }
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Ejemplo n.º 10
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // FB Added
            string aid = "0";
            int?   rollID;

            if (Session["auctionID"] == null)
            {
                rollID = 0;
            }
            else
            {
                aid    = Session["auctionID"].ToString();
                rollID = Int32.Parse(aid);
            }


            // Find user record for role id.

            BidController     bd = new BidController();
            DefaultSetupModel dm = bd.LoadDefs(rollID); // Get the default values

            ViewBag.BackgroundColor     = dm.BackgroundColor;
            ViewBag.TexColor            = dm.FontColor;
            ViewBag.LogoBackgroundColor = dm.LogoBackgroundColor;
            ViewBag.LogoPath            = dm.LogoPath;
            ViewBag.LogoName            = dm.LogoName;

            // Require the user to have a confirmed email before they can log on.
            var user = await UserManager.FindByNameAsync(model.Email);

            if (user != null)
            {
                if (!await UserManager.IsEmailConfirmedAsync(user.Id) && dm.emailConfirmationLoginRequired == true)
                {
                    string callbackUrl = await SendEmailConfirmationTokenAsync(user.Id, "Confirm your account-Resend");

                    ViewBag.errorMessage = "You must have confirmed your email to log on.";
                    return(View("Error"));
                }

                if (!await UserManager.IsPhoneNumberConfirmedAsync(user.Id) && dm.SMSConfirmationLoginRequired == true)
                {
                    // Stuur weer boodskap.

                    ViewBag.errorMessage = "You must confirmed your details before login. Re-send Code";
                    ViewBag.email        = model.Email;
                    return(View("ResentCode"));
                }
                // Fouche : Adde Active check
                tblCustomer tblCustomerEx = db.tblCustomers.FirstOrDefault(i => i.CustomerID == model.Email);

                if (tblCustomerEx != null)     // Customer bestaan
                {
                    if (!tblCustomerEx.Active) // Customer nie aangelog nie.
                    {
                        ViewBag.errorMessage = "Log in not authorised. Please contact NWWT at [email protected]";

                        // Stuur email vir NWWT
                        // email warning to NWWT
                        sendEmail sm           = new sendEmail();
                        string    EmailSubject = "An attempt to log in was made by a suspended customer";
                        string    EMailBody    = $"An attempt to log in was made by a suspended customer. Customer {tblCustomerEx.CompanyName}.";
                        string    res          = sm.SendEmailFB("*****@*****.**", EmailSubject, EMailBody, null, null);


                        return(View("Error"));
                    }
                }
            }


            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true

            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                return(RedirectToLocal(returnUrl));

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }