//[ValidateAntiForgeryToken]
        public async Task <ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var result = await UserManager.ChangePhoneNumberAsync(model.userID, model.PhoneNumber, model.Code);

            if (result.Succeeded)
            {
                var user = await UserManager.FindByIdAsync(model.userID);

                if (user != null)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);
                }
                sendEmail sm           = new sendEmail();
                string    EmailSubject = "FICA requirements for NWWT Silent Auctions";
                string    EMailBody    = $"Thank you {model.CompanyName} for registering for NWWT Silent Auctions.\r\n\r\n Please email a copy of the responsible person’s ID, Company registration certificate (if applicable), proof of address and VAT certificate (if applicable), within 7 days to avoid deregistration, to: [email protected] \r\n \r\n Thank you for your support. \r\n\r\n Kind regards \r\n\r\n \r\n\r\n \r\n\r\n NWWT Silent Auctions Team";
                string    res          = sm.SendEmailFB(model.email, EmailSubject, EMailBody, "*****@*****.**", null);

                return(RedirectToAction("Index", "Home", new { Message = "Cell Phone successfully verified" }));
            }
            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "Failed to verify phone");
            return(View(model));
        }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        firstName = Request.QueryString["fnm"].ToString();
        lastName  = Request.QueryString["lnm"].ToString();
        pass      = Request.QueryString["pass"].ToString();
        string hash = GenerateSHA256String(pass);

        email  = Request.QueryString["email"].ToString();
        adress = Request.QueryString["adr"].ToString();
        phone  = Request.QueryString["phone"].ToString();
        System.Diagnostics.Debug.WriteLine("Begin+ " + email);
        try
        {
            String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebbAppConnString"].ToString();
            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = "";

            queryStr = " INSERT INTO user (email,firstName,lastName,password,address,phone,type ) values ('" + email + "','" + firstName + "','" + lastName + "','" + hash + "','" + adress + "','" + phone + "','user')";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
            cmd.ExecuteReader();
        } catch (Exception mye) {
            Response.Redirect("RegisterNewCustomer.aspx");
        }
        conn.Close();

        sms s = new sms();

        s.Sendsms(phone, "You have been registered att Movie Store");
        System.Diagnostics.Debug.WriteLine("Phone+ " + email);
        sendEmail mail = new sendEmail();

        mail.newuser_mail(email);
    }
        // GET: SendEmail
        public ActionResult Index()
        {
            sendEmail sm           = new sendEmail();
            string    EmailSubject = "FICA requirements for NWWT Silent Auctions";
            string    EMailBody    = "Thank you for registering for NWWT Silent Auctions.\r\n\r\n Please email a copy of the responsible person’s ID, Company registration certificate (if applicable), proof of address and VAT certificate (if applicable), within 7 days to avoid deregistration, to: [email protected] \r\n \r\n Thank you for your support. \r\n\r\n Kind regards \r\n\r\n \r\n\r\n \r\n\r\n NWWT Silent Auctions Team";
            string    res          = sm.SendEmailFB("*****@*****.**", EmailSubject, EMailBody, null, "*****@*****.**");

            return(View());
        }
示例#4
0
        public HttpResponseMessage Post([FromBody] sendEmail db)
        {
            var res = brcdb.sendEmail(db);

            var response = new HttpResponseMessage(HttpStatusCode.Created)
            {
                Content = new StringContent(JsonConvert.SerializeObject(res), System.Text.Encoding.UTF8, "application/json")
            };

            return(response);
        }
        public ActionResult Get(string id)
        {
            sendEmail sE = new sendEmail();
            Hashtable ht = sE.send(id);

            ht.Add("f", "df");
            JavaScriptSerializer js = new JavaScriptSerializer();
            string strJson          = js.Serialize(ht);

            return(Json(ht));
        }
 public String sendForgetPasswordValidationEmailMessage(String toMail, String guid, HttpRequestBase Request)
 {
     sendEmail sendEmail = new sendEmail();
     String retVal = sendEmail.sendEmailMessage(toMail,
         "donotreply",
         "Validate your Account",
         ForgetPasswordEmailBodyContent(Request.Url.Authority, toMail, guid),
         null,
         null,
         "Zestork - Place to boost your Carrer"
         );
     return retVal;
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        c      = new Customers();
        c      = (Customers)Session["myCustomer"];
        movies = (List <Movies>)Session["myMovies"];
        addOrder();
        sms s = new sms();

        s.Sendsms(c.Phone, "Your order att MovieStore have been mabe and payed");
        string emailCustomer = c.Email;

        System.Diagnostics.Debug.WriteLine("sending mail to" + emailCustomer);
        sendEmail email = new sendEmail();

        email.booking_mail(emailCustomer);
    }
        static void Main(string[] args)
        {
            sendData Data = new sendEmail();

            Data._bridgeComponents = new webService();
            Data.send();
            Data._bridgeComponents = new ThirdPartyUI();
            Data.send();


            sendData Data1 = new sendSMS();

            Data1._bridgeComponents = new webService();
            Data1.send();

            //sendData Data = new sendEmail();

            //sendData Data1 = new sendSMS();
            Data1._bridgeComponents = new ThirdPartyUI();
            Data1.send();
        }
        public async Task <ActionResult> AddPhoneNumber(ResentCodeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = await UserManager.FindByNameAsync(model.email);

            if (user != null)
            {
                model.userID = user.Id;
            }
            // Generate the token and send it

            //              var code = await UserManager.GenerateChangePhoneNumberTokenAsync(model.userID, model.PhoneNumber);
            bool smsNotifications = true;

            if (smsNotifications)
            {
                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 customer {user.CompanyName}" + " to change phone " + ".  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"));
                }
            }

            return(RedirectToAction("VerifyPhoneNumber", new { PhoneNumber = model.PhoneNumber, id = user.Id }));
        }
示例#10
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);
        }
    protected void ContinueButton_Clicked(object sender, EventArgs e)
    {
        string cont = "";// Request["emailTo"].ToString();

        sendEmail send = new sendEmail();

        bool success = true;
        int orderIdEmail = 0;
        // Submit Order

        CartDB db = new CartDB();
        if (CurrentCart.Completed == false)
        {
            int order_id, payment_id;
            success = db.Order_Post_Cart(CurrentCart, CartUsers.GetLoginID(), SalesRepFlagCheckbox.Checked ? 1 : 0, out order_id, out payment_id,Convert.ToString(SumaryComents.Value));
            success = db.CartUpdatePaymentOrderIDs(CurrentCart.PaymentId, order_id, payment_id);
            if (Session["TorchInCart"] != null && bool.Parse(Session["TorchInCart"].ToString()) == true)
            {
                ArrayList listSkusDesc = new ArrayList();
                ArrayList listSkus = new ArrayList();
                int orderId = Convert.ToInt32(Session["orderIdForTorch"]);
                SiteProduct product = new SiteProduct();
                DataSet torchData = product.Get_TorchDescription(this.CurrentCart.CartId);
                foreach (DataTable table in torchData.Tables)
                {
                    foreach (DataRow Confdetail in table.Rows)
                    {
                        listSkus.Add(Confdetail["sku"].ToString());
                        listSkusDesc.Add(new LisTorchDescription(Confdetail["sku"].ToString(), Confdetail["description"].ToString()));
                    }
                }
                HashSet hs = new HashSet();
                hs.AddAll(listSkus);
                listSkus.Clear();
                listSkus.AddRange(hs);

                foreach(string sku in listSkus)
                {
                   string finalDescription = "";
                   foreach (LisTorchDescription sku2 in listSkusDesc)
                   {
                       if(sku.Equals(sku2.SKU))
                       {
                           finalDescription += "|" + sku2.Description + "|";

                       }
                   }
                   product.Add_Torch_Description(orderId, finalDescription, sku);
                }
                Session["TorchInCart"] = null;

                Session["orderIdForTorch"] = null;

            }

            if (CartUsers.IsUserLoggedIn(Session) && CurrentCart.BillingLocation != null)
            {
                int login_id = CartUsers.GetLoginID();
                db.LoginUpdBillingAddress(login_id, CurrentCart.BillingLocation.BusinessName, CurrentCart.BillingLocation.Address1, CurrentCart.BillingLocation.Address2, CurrentCart.BillingLocation.City, CurrentCart.BillingLocation.StateCode, CurrentCart.BillingLocation.PostalCode, CurrentCart.BillingLocation.CountryCode, CurrentCart.BillingLocation.Phone);
            }

        }
        CartDB de = new CartDB();

        cont = cont.Replace("\n\r", ""); //before making any substitution, check that there are no new lines in the code. Windows
        cont = cont.Replace("\n", ""); // Unix: note that this code will not change anyting in windows, due to the first line

        cont = cont.Replace("<img src=\"images/buttonEdit.jpg\" alt=\"Edit\" />", "");// Why will I want and edit button in the mail ?"<img src=\"http://www.edresources.com/images/buttonEdit.jpg\" alt=\"Edit\" />");
        cont = cont.Replace("type=\"checkbox\"", "type=\"hidden\"");
        cont = cont.Replace("textarea","div style='display:none;'");
        cont = cont.Replace("TEXTAREA", "div style='display:none;'");
        cont = cont.Replace("Comments", "");
        cont = cont.Replace("/ Special Instructions:", "");

         cont = System.Text.RegularExpressions.Regex.Replace(cont, "<img class=\"first-child", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
         cont = System.Text.RegularExpressions.Regex.Replace(cont, "last-child\" alt=\"Edit\">", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
         cont = System.Text.RegularExpressions.Regex.Replace(cont,"last-child\" alt=Edit src=\"images/buttonEdit.jpg\">","",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
         cont = System.Text.RegularExpressions.Regex.Replace(cont,"last-child\" alt=Edit src=\"images2/buttonEdit.jpg\">","",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
         cont = System.Text.RegularExpressions.Regex.Replace(cont,"last-child\" alt=\"Place Order\" src=\"images/buttonPlaceOrder.jpg\">","<br>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);

           cont = cont.Replace("Special Instructions:", "<b>Special Instructions:</b>");
        if (!SalesRepFlagCheckbox.Checked) {
            cont = cont.Replace("Yes, a sales rep helped me with this order", " ");
        }
        if (success)
        {
            DataSet data2 = new DataSet();
            data2 = de.Get_OrderId_By_Email(CartUsers.GetLoginID());
            foreach (DataTable table2 in data2.Tables)
            {
                foreach (DataRow row2 in table2.Rows)
                {
                    orderIdEmail = Convert.ToInt32(row2["OrderID"]);
                }
            }

            Session["orderpoid"] = orderIdEmail;

            if (CurrentCart.Payment.PaymentType == (int)PaymentType.CC)
            {
                send.toEmail(cont, CurrentCart.BillingLocation.Email, orderIdEmail);
                CurrentCart.MoveNextStep();

            }
            else
            {
                send.toEmail(cont, CurrentCart.BillingLocation.Email, orderIdEmail);
                CurrentCart.MoveToStep((int)Constants.CheckoutStep.PurchaseOrder);
            }

            Response.Redirect(Constants.Pages.CHECKOUT);
        }
    }
示例#12
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));
        }
示例#13
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));
        }
示例#14
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));
            }
        }