Example #1
0
        public JsonResult registGetPasswordrationJson(string AccdanhNhap_Email, string EmailLayPass)
        {
            /*
             * 1 la tai khoan khong chinh xac
             * 2 la gmail khong chinh xac
             * 3 la thanh cong
             * 0 la he thong gap loi
             */
            string Trave = "";

            try
            {
                if (db.accs.Where(n => n.taikhoan == AccdanhNhap_Email).Count() == 1)
                {
                    if (db.accs.Where(n => n.taikhoan == AccdanhNhap_Email && n.email == EmailLayPass).Count() == 1)
                    {
                        guiMail gm = new guiMail();
                        Ran     r  = new Ran();
                        if (gm.ToguiMail(EmailLayPass, r.songaunhien().ToString()) == true)
                        {
                            Trave = "3";
                        }
                        else
                        {
                            Trave = "0";
                        }
                    }
                    else
                    {
                        Trave = "2";
                    }
                }
                else
                {
                    Trave = "1";
                }
            }
            catch (Exception)
            {
                Trave = "0";
            }
            return(Json(Trave));
        }
Example #2
0
        public JsonResult laymk(string taikhoan, string gmail)
        {
            string trave = "";

            if (taikhoan == null || taikhoan == "" || gmail == null || gmail == "")
            {
                trave = "3";
            }
            else
            {
                try
                {
                    Ran     a               = new Ran();
                    int     songaunhien     = a.songaunhien();
                    guiMail g               = new guiMail();
                    var     taiKhoanLayDuoc = db.accs.Where(n => n.taikhoan == taikhoan.Trim() && n.email == gmail.Trim());
                    if (taiKhoanLayDuoc.Count() == 1)
                    {
                        if (g.ToguiMail(gmail, Convert.ToString(songaunhien).Trim()) == true)
                        {
                            taiKhoanLayDuoc.FirstOrDefault().matkhau = MD5.ToMD5(Convert.ToString(songaunhien).Trim());
                            db.SaveChanges();
                            trave = "1";
                        }
                        else
                        {
                            //gui mail den tai khoan cua ban
                            trave = "2";
                        }
                    }
                    else
                    {
                        trave = "0";
                    }
                }
                catch (Exception)
                {
                    trave = "2";
                }
            }
            return(Json(trave));
        }