public ActionResult InsertData() { //xử lý sửa dữ liệu try { int namDL = int.Parse(Request.Form["namDL"]); string namAmLich = Request.Form["namAmLich"].ToString(); string giaiNghia = Request.Form["giaiNghia"].ToString(); string cungNam = Request.Form["cungNam"].ToString(); string menhNam = Request.Form["menhNam"].ToString(); string cungNu = Request.Form["cungNu"].ToString(); string menhNu = Request.Form["menhNu"].ToString(); string nguHanhNamSinh = Request.Form["nguHanhNamSinh"].ToString(); string tenNguHanh = Request.Form["tenNguHanh"].ToString(); NguHanh nguHanh = new NguHanh(); nguHanh.namDL = namDL; nguHanh.namAL = namAmLich; nguHanh.GiaiNghia = giaiNghia; nguHanh.CungNam = cungNam; nguHanh.NienMenhNam = menhNam; nguHanh.CungNu = cungNu; nguHanh.NienMenhNu = menhNu; nguHanh.NguHanhNamSinh = nguHanhNamSinh; nguHanh.TenNguHanh = tenNguHanh; db.NguHanhs.Add(nguHanh); db.SaveChanges(); // return RedirectToAction("Index"); } catch (Exception) { } return(Redirect("~/Admin/QuanLyDuLieuNguHanh/Index")); //return View(); }
public ActionResult InsertData() { try { //int maTaiLieu = int.Parse(Request.QueryString["maTaiLieu"]); int maTaiLieu = int.Parse(Request.Form["maTaiLieu"].ToString()); string chuDe = Request.Form["chuDe"].ToString(); string tieuDe = Request.Form["tieuDe"].ToString(); string noiDung = Request.Form["noiDung"].ToString(); string linkAnh = Request.Form["linkAnh"].ToString(); DateTime ngayDang = DateTime.Now; TaiLieu taiLieu = new TaiLieu(); taiLieu.MaTaiLieu = maTaiLieu; taiLieu.ChuDe = chuDe; taiLieu.TieuDe = tieuDe; taiLieu.NoiDung = noiDung; taiLieu.LinkAnh = linkAnh; taiLieu.NgayDang = ngayDang; taiLieu.TenNguoiDang = "HuyAdmin"; db.TaiLieux.Add(taiLieu); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception) { } return(RedirectToAction("Index")); }
public ActionResult submit(string mkc, string mkm, string mkm2) { string email = Session["email"].ToString(); var Account = from y in db.Admins where y.Email == email select y; var existAccount = db.Admins.ToList().Any(p => p.Email == email && p.Password == md5Process.md5(mkc)); if (existAccount) { if (mkm == mkm2) { var v = db.Admins.SingleOrDefault(p => p.Email == email); v.Password = md5Process.md5(mkm).Trim().ToString(); db.SaveChanges(); Session.Remove("email"); return(RedirectToAction("Index", "Login")); } else { return(RedirectToAction("Index", "DoiMatKhau")); } //var role = db.Admins.ToList().Single( //p => p.Email == email && p.Password == md5Process.md5(password)); } else { return(RedirectToAction("Index", "DoiMatKhau")); } }
public ActionResult submitPHMK(string maxacnhan, string mkm, string mkm2) { string email = Session["email2"].ToString(); string maxacnhandagui = Session["maxacnhan"].ToString(); if (maxacnhan == maxacnhandagui) { if (mkm == mkm2) { var v = db.Admins.SingleOrDefault(p => p.Email == email); string mkec = md5Process.md5(mkm); v.Password = mkec; db.SaveChanges(); return(RedirectToAction("Index", "Login")); } else { return(RedirectToAction("Index", "PhucHoiMatKhau")); } } return(RedirectToAction("Index2", "PhucHoiMatKhau")); }
public ActionResult FacebookCallback(string code) //Lấy thông tin người dùng fb và login vào { // string bd = "cc"; string IdPost = ""; string id = ""; string date = ""; string gender = ""; string imageURL = ""; var fb = new FacebookClient(); // string nameValues = "sss"; dynamic result = fb.Post("oauth/access_token", new { client_id = "1567232153295149", client_secret = "eab1b4dd9956001f52bd54229aea61c1", redirect_uri = RedirectUri.AbsoluteUri, code = code }); var accessToken = result.access_token; if (!string.IsNullOrEmpty(accessToken)) { fb.AccessToken = accessToken; //dynamic parameters = new ExpandoObject(); //parameters.message = "Check out this funny article"; //parameters.link = "http://www.natiska.com/article.html"; //parameters.picture = "http://www.natiska.com/dav.png"; //parameters.name = "Article Title"; //parameters.privacy = new { value = "EVERYONE" }; //parameters.caption = "Caption for the link"; //fb.Post("/me/feed", parameters //); dynamic me = fb.Get("me?fields=id,name,birthday,gender"); id = me.id; dynamic parameters = new ExpandoObject(); //DateTime dt = Convert.ToDateTime(me.birthday); string datestr = me.birthday; DateTime dt1 = DateTime.ParseExact(datestr, "MM/dd/yyyy", CultureInfo.InvariantCulture); date = dt1.ToString("yyyy-MM-dd"); gender = me.gender; //parameters.message = "Xem chúng ta được bao nhiêu điểm nào <3 ! "; //parameters.link = "http://tuvigiadao.somee.com/Guest/GhepDoiTinhDuyenListener/submit2/?id=" + id + "&birthday=" + date + "&gender=" + me.gender; //parameters.picture = "http://tuvisomenh.com/Media/Default/BlogPost/tu-vi-2017-tuoi-than.jpg"; //parameters.name = id; //parameters.caption = "Click để xem chúng ta hợp nhau tới đâu nhé !"; //fb.Post("/me/feed", parameters); // MD5 encode byte[] mang = System.Text.Encoding.UTF8.GetBytes(id); MD5CryptoServiceProvider my_md5 = new MD5CryptoServiceProvider(); mang = my_md5.ComputeHash(mang); foreach (byte b in mang) { IdPost += b.ToString("x2");//Nếu là "X2" thì kết quả sẽ tự chuyển sang ký tự in Hoa } // // Draw an image imageURL = Image(id, IdPost); var post = new GhepDoiTinhDuyenPost(); // Get post from DB post = db.GhepDoiTinhDuyenPosts.Where(s => s.IdPost == IdPost).FirstOrDefault(); if (post != null) { post.IdPost = IdPost; post.IdFB = id; post.Birthday = date; post.Name = me.name; if (gender.Equals("male", StringComparison.Ordinal)) { // 1 true là nam post.Gender = true; } else { // 0 false là nữ post.Gender = false; } post.Image = imageURL; // Mark entity as modified db.Entry(post).State = System.Data.Entity.EntityState.Modified; // call SaveChanges db.SaveChanges(); } else { post = new GhepDoiTinhDuyenPost(); post.IdPost = IdPost; post.IdFB = id; post.Birthday = date; if (gender.Equals("male", StringComparison.Ordinal)) { // 1 true là nam post.Gender = true; } else { // 0 false là nữ post.Gender = false; } post.Image = imageURL; post.Name = me.name; db.GhepDoiTinhDuyenPosts.Add(post); db.SaveChanges(); } } //TempData["url"] = "http://localhost:3104/Guest/XemPhongThuy/submit?" + nameValues; TempData["url"] = "Guest/GhepDoiTinhDuyenListener/submit2?IDPost=" + IdPost; return(Redirect("/Guest/GhepDoiTinhDuyen/submit2?IdPost=" + IdPost)); // return Redirect("~/Guest/GhepDoiTinhDuyenListener/submit2?"+nameValues); ??????? }
public ActionResult FacebookCallback(string code) //Lấy thông tin người dùng fb và login vào { // string bd = "cc"; string IdPost2 = ""; var fb = new FacebookClient(); // string nameValues = "sss"; dynamic result = fb.Post("oauth/access_token", new { client_id = "1567232153295149", client_secret = "eab1b4dd9956001f52bd54229aea61c1", redirect_uri = RedirectUri.AbsoluteUri, code = code }); var accessToken = result.access_token; if (!string.IsNullOrEmpty(accessToken)) { fb.AccessToken = accessToken; //dynamic parameters = new ExpandoObject(); //parameters.message = "Check out this funny article"; //parameters.link = "http://www.natiska.com/article.html"; //parameters.picture = "http://www.natiska.com/dav.png"; //parameters.name = "Article Title"; //parameters.privacy = new { value = "EVERYONE" }; //parameters.caption = "Caption for the link"; //fb.Post("/me/feed", parameters //); //string objID = TempData["fid"].ToString(); dynamic me = fb.Get("me?fields=id,name,birthday,gender,picture.height(200).width(200)"); //dynamic obj = fb.Get(objID + "?fields=name"); // string nameobj = obj.name; TempData["tentoi"] = me.name; // TempData["tennguoiay"] = nameobj; /// // string myID = me.id; // //string myPic = "https://graph.facebook.com/" + me.id + "/picture?height=200"; //string objPic = "https://graph.facebook.com/" + objID + "/picture?height=200"; TempData["myPic"] = me.id; // TempData["objPic"] = obj.id; dynamic idPost = TempData["idpost"]; string idTEMP = me.id + idPost; // MD5 encode byte[] mang = System.Text.Encoding.UTF8.GetBytes(idTEMP); MD5CryptoServiceProvider my_md5 = new MD5CryptoServiceProvider(); mang = my_md5.ComputeHash(mang); foreach (byte b in mang) { IdPost2 += b.ToString("x2");//Nếu là "X2" thì kết quả sẽ tự chuyển sang ký tự in Hoa } // string IdResult = IdPost2; string dob = me.birthday; // DateTime dt1 = DateTime.ParseExact(dob, "MM/dd/yyyy", CultureInfo.InvariantCulture); // string gender = me.gender; string idfb = me.id; string imageURL = IdResult; string name = me.name; dynamic idPostTruoc = TempData["idpost"]; DateTime date1 = DateTime.Parse(dob); string db1 = dt1.ToString("yyyy-MM-dd"); var Res = new GhepDoiTinhDuyenResult(); Res = db.GhepDoiTinhDuyenResults.Where(s => s.IdResult == IdResult).FirstOrDefault(); if (Res != null) { Res.IdResult = IdResult; Res.IdPost = idPostTruoc; Res.IdFb = idfb; Res.Name = name; Res.Birthday = db1; if (gender.Equals("male", StringComparison.Ordinal)) { // 1 true là nam Res.Gender = true; } else { // 0 false là nữ Res.Gender = false; } Res.Image = imageURL; // Mark entity as modified db.Entry(Res).State = System.Data.Entity.EntityState.Modified; // call SaveChanges db.SaveChanges(); } else { Res = new GhepDoiTinhDuyenResult(); Res.IdResult = IdResult; Res.IdPost = idPostTruoc; Res.IdFb = idfb; Res.Name = name; Res.Birthday = db1; if (gender.Equals("male", StringComparison.Ordinal)) { // 1 true là nam Res.Gender = true; } else { // 0 false là nữ Res.Gender = false; } Res.Image = imageURL; Res.Name = name; db.GhepDoiTinhDuyenResults.Add(Res); db.SaveChanges(); } } return(Redirect("/Guest/GhepDoiTinhDuyenListener/result?IdRes=" + IdPost2)); }