Exemplo n.º 1
0
        public ActionResult Confirmation(string id)
        {
            MyDatabaseDataContext db = new MyDatabaseDataContext();
            V_Unuser unuser          = db.V_Unusers.Where(x => x.ConfCode == id).FirstOrDefault();

            V_user user = new V_user()
            {
                Name       = unuser.Name,
                SurName    = unuser.SurName,
                CreateDate = DateTime.Now,
                Password   = unuser.Password,
                Email      = unuser.Email,
                Secret     = Random32(),
            };

            using (var transaction = new TransactionScope())
            {
                db.V_users.InsertOnSubmit(user);
                db.SubmitChanges();

                db.V_Unusers.DeleteAllOnSubmit(db.V_Unusers.Where(x => x.Email == unuser.Email).ToList());
                db.SubmitChanges();
                transaction.Complete();
            }

            return(RedirectToAction("Success"));
        }
Exemplo n.º 2
0
        public ActionResult Register(Register users)

        {
            MyDatabaseDataContext db = new MyDatabaseDataContext();
            int count = db.V_users.Where(x => x.Email == users.Email).Count();

            if (String.IsNullOrEmpty(users.Name) || String.IsNullOrEmpty(users.Surname) || String.IsNullOrEmpty(users.Email) || String.IsNullOrEmpty(users.Password) || String.IsNullOrEmpty(users.ConfirmPassword))
            {
                ViewBag.error = "შეავსეთ ყველა ველი!";
                return(View());
            }

            else if (users.ConfirmPassword != users.Password)
            {
                ViewBag.error = "პაროლები არ მთხვევა ერთმანეთს";
                return(View());
            }
            else if (count > 0)
            {
                ViewBag.error = "მომხამრებელი ასეთი ელ.ფოსტით უკვე დარეგისტრირებულია";
                return(View());
            }
            else
            {
                string   confirmationcode = Random32();
                V_Unuser unuser           = new V_Unuser()
                {
                    Name       = users.Name,
                    SurName    = users.Surname,
                    Email      = users.Email,
                    Password   = MD5Hash(users.Password + authsecret),
                    CreateDate = DateTime.Now,
                    ConfCode   = confirmationcode,
                };
                db.V_Unusers.InsertOnSubmit(unuser);
                db.SubmitChanges();
                string body = "http://localhost:51328/Account/Confirmation/" + confirmationcode;
                SendMail(users.Email, "Confirmation", body, false);
                return(RedirectToAction("conf"));
            }
        }