public ActionResult Create([Bind(Include = "FirstName,LastName,Email,Contact,DOB,Password,SecurityQue,Answer,RegisterTime,IsActive,Roal,UserId")] Register register)
        {
            if (ModelState.IsValid)
            {
                /* register.RegisterTime = DateTime.Now;
                 * db.Registers.Add(register);
                 * db.SaveChanges();
                 * return RedirectToAction("Index");*/


                using (EkartEntities1 db = new EkartEntities1())
                {
                    var v = db.Registers.Where(a => a.Email.Equals(register.Email) || a.Contact.Equals(register.Contact)).FirstOrDefault();
                    if (v != null)
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('Email Or Contact Is already Register Please Enter Different Data !!!'); window.location.replace('Create');</script>"));
                    }
                    else
                    {
                        register.RegisterTime = DateTimeOffset.Now;
                        db.Registers.Add(register);
                        db.SaveChanges();
                        return(Content("<script language='javascript' type='text/javascript'>alert('Your Registration Successful Please Login !!!'); window.location.replace('Login');</script>"));
                    }
                }
            }

            return(View(register));
        }
示例#2
0
        public ActionResult ForgotPass(Register register)
        {
            using (EkartEntities1 dc = new EkartEntities1())
            {
                var v = dc.Registers.Where(a => a.Contact.Equals(register.Contact)).FirstOrDefault();
                if (v != null)
                {
                    int    _min = 0000;
                    int    _max = 9999;
                    Random _rdm = new Random();
                    int    otp  = _rdm.Next(_min, _max);
                    Session["OTP"] = otp;
                    var client  = new RestClient("https://www.fast2sms.com/dev/bulkV2");
                    var request = new RestRequest(Method.POST);
                    request.AddHeader("content-type", "application/x-www-form-urlencoded");
                    request.AddHeader("authorization", "WM7EV9OTgK1qoP2J4ltzfvNC0cL5rhmbdXSHjuZAU8IGFyYsQRyp5htjnO3BfMkuZiPFco1bS74NQrJU");
                    request.AddParameter("sender_id", "CHKSMS");
                    request.AddParameter("message", "2");
                    request.AddParameter("variables_values", otp);
                    request.AddParameter("route", "s");
                    request.AddParameter("numbers", register.Contact);
                    IRestResponse response = client.Execute(request);

                    Session["Id"] = register.Contact;
                    return(RedirectToAction("EnterOtp"));
                }
                else
                {
                    return(Content("<script language='javascript' type='text/javascript'>alert('Please Enter Corract Contact Number !!!'); window.location.replace('ForgotPass');</script>"));
                }
            }
        }
示例#3
0
        public ActionResult Index(Register obj)
        {
            if (ModelState.IsValid)
            {
                using (EkartEntities1 db = new EkartEntities1())
                {
                    var v = db.Registers.Where(a => a.Email.Equals(obj.Email) || a.Contact.Equals(obj.Contact)).FirstOrDefault();
                    if (v != null)
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('Email Or Contact Is already Register Please Enter Different Data !!!'); window.location.replace('Index');</script>"));
                    }
                    else
                    {
                        obj.RegisterTime = DateTime.Now.Date;
                        obj.Roal         = "User";
                        obj.IsActive     = "Y";
                        db.Registers.Add(obj);
                        db.SaveChanges();

                        /*                        return Content("<script language='javascript' type='text/javascript'>alert('Your Registration Successful Please Login !!!'); window.location.replace('Login');</script>");
                         */
                        Session["check"] = "Yes";
                        return(RedirectToActionPermanent("Login", "Home"));
                    }
                }
            }
            else
            {
                return(RedirectToAction("Index"));
            }

            /* obj.RegisterTime = DateTime.Now;
             * obj.Roal = "User";
             * obj.IsActive = "Y";
             * db.Registers.Add(obj);
             * db.SaveChanges();
             * obj.FirstName = null;
             * return Content("<script language='javascript' type='text/javascript'>alert('Your Registration Successful Please Login !!!'); window.location.replace('ForgotPass');</script>");
             *
             * }
             * else
             * {
             * return RedirectToAction("Index");
             *
             * }
             */
        }
示例#4
0
        public ActionResult Login(Register register)
        {
            using (EkartEntities1 dc = new EkartEntities1())
            {
                var v = dc.Registers.Where(a => a.Email.Equals(register.Email) && a.Password.Equals(register.Password)).FirstOrDefault();
                if (v != null)
                {
                    Session["userName"] = register.Email;

                    Register r = db.Registers.Where(a => a.Email == register.Email).SingleOrDefault();
                    if (r.IsActive == "Y")
                    {
                        Session["Userid"] = r.UserId;
                        if (r.Roal == "Admin")
                        {
                            TempData["message"] = "Save successfully";

                            return(RedirectToActionPermanent("Index", "Admin"));

                            /*                        return View("~/Views/CategoryLists/Index.cshtml");
                             */                        /*                        return Content("<script language='javascript' type='text/javascript'>alert('You Are Not Registered User Please Register First !!!'); window.location.replace('Login');</script>");
                             */
                        }
                        else
                        {
                            Session["Uid"] = register.UserId;

                            return(RedirectToActionPermanent("Index", "BasketItems"));
                        }
                    }
                    else
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('You Cant Access The Site Beacuse You Are Not Active User'); window.location.replace('Index');</script>"));
                    }
                }
                else
                {
                    return(Content("<script language='javascript' type='text/javascript'>alert('You Are Not Registered User Please Register First !!!'); window.location.replace('Login');</script>"));
                }
            }
        }