public ActionResult e修改(tMember p) { dbJoutaEntities db = new dbJoutaEntities(); tMember A = db.tMember.FirstOrDefault(m => m.f會員編號 == p.f會員編號); if (A != null) { A.f會員名稱 = p.f會員名稱; A.f會員評分 = p.f會員評分; A.f會員稱號 = p.f會員稱號; A.f會員大頭貼 = p.f會員大頭貼; A.f會員帳號 = p.f會員帳號; A.f會員密碼 = p.f會員密碼; A.f會員電子郵件 = p.f會員電子郵件; A.f會員手機 = p.f會員手機; A.f會員電話 = p.f會員電話; A.f會員生日 = p.f會員生日; A.f會員自我介紹 = p.f會員自我介紹; A.f會員暱稱 = p.f會員暱稱; A.f會員性別 = p.f會員性別; A.f會員興趣 = p.f會員興趣; db.SaveChanges(); } return(RedirectToAction("List")); }
public ActionResult ForgetPassword(string Email) { string message = ""; //bool status = false; using (dbJoutaEntities db = new dbJoutaEntities()) { var account = db.tMember.Where(a => a.f會員電子郵件 == Email).FirstOrDefault(); if (account != null) { string resetCode = Guid.NewGuid().ToString(); sendResetPasswordMail(account.f會員電子郵件, resetCode); account.f重置驗證碼 = resetCode; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); message = "重置密碼連結已經發送至您指定信箱,請前往設置!"; } else { if (Email == "") { message = "請填入信箱"; } else { message = "該信箱不存在!!"; } } } ViewBag.Msg = message; return(View()); }
public ActionResult ResetPassword(CReset c) { var message = ""; if (ModelState.IsValid) { using (dbJoutaEntities db = new dbJoutaEntities()) { var user = db.tMember.Where(a => a.f重置驗證碼 == c.resetCode).FirstOrDefault(); if (user != null) { user.f會員密碼 = c.newPassword; user.f重置驗證碼 = ""; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); message = "新密碼重置成功!"; } } } else { if (c.newPassword == null) { message = "內容必填"; } else { message = "格式錯誤"; } } ViewBag.Message = message; return(View()); }
public ActionResult GetLineChartData() { dbJoutaEntities context = new dbJoutaEntities(); var query = from t in context.tActivity select new { name = t.f活動發起日期, count = t.f活動瀏覽次數 }; //var query = context.tActivity.Include("f活動預算") //.GroupBy(p => p.Product.ProductName) //.Select(g => new { name = g.Key, name = g.Sum(w => w.Quantity) }).ToList(); return(Json(query, JsonRequestBehavior.AllowGet)); }
public ActionResult GetColumnChartData() { dbJoutaEntities db = new dbJoutaEntities(); var query = from t in db.tMember select new { name = t.f會員名稱, count = t.f瀏覽人數 }; //var query = context.tActivity.Include("f活動預算") //.GroupBy(p => p.Product.ProductName) //.Select(g => new { name = g.Key, name = g.Sum(w => w.Quantity) }).ToList(); return(Json(query, JsonRequestBehavior.AllowGet)); }
public ActionResult r回覆(int?id) { if (id == null) { RedirectToAction("List"); } dbJoutaEntities db = new dbJoutaEntities(); tComment x = new tComment(); x = db.tComment.FirstOrDefault(m => m.fID == id); return(View(x)); }
public ActionResult LikeIt(int?id) { var article = from t in (new dbJoutaEntities()).tActivity where t.f活動類型 == "文章" && t.f活動編號 == id select t; dbJoutaEntities db = new dbJoutaEntities(); var target = db.tActivity.Where(t => t.f活動編號 == id).FirstOrDefault(); target.f活動讚數 += 1; db.SaveChanges(); return(RedirectToAction("BlogContent", new { id = id })); }
public ActionResult e修改(int?id) { if (id == null) { RedirectToAction("List"); } dbJoutaEntities db = new dbJoutaEntities(); tMember x = new tMember(); x = db.tMember.FirstOrDefault(m => m.f會員編號 == id); return(View(x)); }
public ActionResult r回覆(C回覆 y, tComment p) { send(y); //ViewBag.kk = "傳送成功"; dbJoutaEntities db = new dbJoutaEntities(); tComment A = db.tComment.FirstOrDefault(m => m.fID == p.fID); if (A != null) { A.f意見狀態 = "已回覆"; db.SaveChanges(); } return(RedirectToAction("List")); }
public ActionResult v查看(int?id) { if (id == null) { RedirectToAction("List"); } dbJoutaEntities db = new dbJoutaEntities(); tActivity x = new tActivity(); x = db.tActivity.FirstOrDefault(m => m.f活動編號 == id); return(View(x)); }
//信箱驗證碼驗證 public string emailValidation(string email, string authCode) { CRegisterModel c = getAccount(email); //宣告驗證後訊息字串 string validationStr = string.Empty; if (c != null) { dbJoutaEntities db = new dbJoutaEntities(); tMember t = db.tMember.FirstOrDefault(k => k.f會員電子郵件 == email && k.f驗證碼 == authCode); t.f驗證碼 = ""; validationStr = "信箱驗證成功,現在可以登入囉~"; } return(validationStr); }
public ActionResult Create(CBlog p) { HttpPostedFileBase blogPhoto = Request.Files["blogPhoto"]; if (p.blogPhoto != null) { string photName = Guid.NewGuid().ToString() + Path.GetExtension(p.blogPhoto.FileName); var path = Path.Combine(Server.MapPath("~/Content/images/"), photName); p.blogPhoto.SaveAs(path); p.f活動團圖 = photName; } tActivity article = new tActivity(); article.f活動類型 = "文章"; article.f活動標題 = p.txtTitle; article.f活動地點 = p.txtLocation; article.f活動內容 = p.txtContent; article.f活動團圖 = p.f活動團圖; article.fQRcode網址 = p.QRcode; article.fQRcodeImage = p.QRcodeImage; article.f活動發起日期 = (DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss"); article.f活動地區 = p.f活動地區; article.f活動瀏覽次數 = 0; article.f活動讚數 = 0; var LoginMember = (tMember)Session["member"]; article.f會員編號 = LoginMember.f會員編號; if (article != null) { dbJoutaEntities db = new dbJoutaEntities(); db.tActivity.Add(article); db.SaveChanges(); return(RedirectToAction("index")); } else { return(RedirectToAction("index")); } }
public ActionResult d刪除(int?id) { if (id == null) { RedirectToAction("List"); } tActivity x = new tActivity(); dbJoutaEntities db = new dbJoutaEntities(); x = db.tActivity.FirstOrDefault(m => m.f活動編號 == id); db.tActivity.Remove(x); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult GetPieChartData() { dbJoutaEntities db = new dbJoutaEntities(); var north = db.tActivity.Where(x => x.f活動地區 == "北部").Count(); var south = db.tActivity.Where(x => x.f活動地區 == "南部").Count(); var east = db.tActivity.Where(x => x.f活動地區 == "東部").Count(); Ratio obj = new Ratio(); obj.North = north; obj.South = south; obj.East = east; return(Json(obj, JsonRequestBehavior.AllowGet)); }
public ActionResult BlogContent(int?id) { var article = from t in (new dbJoutaEntities()).tActivity where t.f活動類型 == "文章" && t.f活動編號 == id select t; dbJoutaEntities db = new dbJoutaEntities(); var target = db.tActivity.Where(t => t.f活動編號 == id).FirstOrDefault(); target.f活動瀏覽次數 += 1; db.SaveChanges(); return(View(article.FirstOrDefault())); }
public ActionResult d刪除(int?id) { if (id == null) { RedirectToAction("List"); } tComment x = new tComment(); dbJoutaEntities db = new dbJoutaEntities(); x = db.tComment.FirstOrDefault(m => m.fID == id); db.tComment.Remove(x); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult ResetPassword(string id) { using (dbJoutaEntities db = new dbJoutaEntities()) { var user = db.tMember.Where(a => a.f重置驗證碼 == id).FirstOrDefault(); if (user != null) { CReset c = new CReset(); c.resetCode = id; return(View(c)); } else { return(HttpNotFound()); } } }
public ActionResult UploadImg(tMember t) { dbJoutaEntities db = new dbJoutaEntities(); var x = db.tMember.Where(a => a.f會員編號 == t.f會員編號).FirstOrDefault(); HttpPostedFileBase avaPhoto = Request.Files["f會員大頭貼"]; if (avaPhoto != null) { string photName = Guid.NewGuid().ToString() + Path.GetExtension(avaPhoto.FileName); var path = Path.Combine(Server.MapPath("~/Content/images/"), photName); avaPhoto.SaveAs(path); x.f會員大頭貼 = photName; } db.SaveChanges(); return(RedirectToAction("ProfileIndex")); }
public ActionResult d刪除(int?id) { if (id == null) { RedirectToAction("List"); } tMember x = new tMember(); dbJoutaEntities db = new dbJoutaEntities(); var y = db.tActivity.Where(m => m.f會員編號 == id).ToList(); db.tActivity.RemoveRange(y); x = db.tMember.FirstOrDefault(m => m.f會員編號 == id); db.tMember.Remove(x); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult SendMail(string txtCouponInfo, string memberId1) { dbJoutaEntities db = new dbJoutaEntities(); var x = db.tMember.Where(a => a.f會員帳號 == memberId1.ToString()).FirstOrDefault(); string randCode = Guid.NewGuid().ToString(); //Jouta官方帳號 string gmail_account = "*****@*****.**"; string gmail_password = "******"; string gmail_mail = "*****@*****.**"; //gmail信箱 //var verifyUrl = "/Home/ResetPassword/" + randCode; //var link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, verifyUrl); var fromEmail = new MailAddress(gmail_mail, "Jouta服務團隊"); var toEmail = new MailAddress(x.f會員電子郵件); string body = "您好,<br/><br/>恭喜您抽到:" + txtCouponInfo + "<br/><br/>優惠代碼請至該店家網站或其門市兌換使用:" + randCode + ",使用期限至9/30,請盡速使用!</a>"; SmtpClient smtpServer = new SmtpClient("smtp.gmail.com"); smtpServer.Port = 587; smtpServer.Credentials = new System.Net.NetworkCredential(gmail_account, gmail_password); //開啟SSL smtpServer.EnableSsl = true; MailMessage mail = new MailMessage(); //設定來源信箱 mail.From = new MailAddress(gmail_mail); //設定收信者信箱 mail.To.Add(toEmail); //主旨 mail.Subject = "Jouta 優惠好禮 !"; //內容 mail.Body = body; //設定信箱內容為HTML格式 mail.IsBodyHtml = true; smtpServer.Send(mail); return(RedirectToAction("List")); }
public ActionResult List(string randLocation) { dbJoutaEntities db = new dbJoutaEntities(); var x = (from t in db.tMember //where (t.f會員緯度 < curLat+0.02 && //t.f會員緯度 > curLat - 0.02 && //t.f會員經度 < curLng + 0.02 && //t.f會員經度 > curLng - 0.02) select new { mMemberNum = t.f會員編號, mEmail = t.f會員電子郵件, mName = t.f會員名稱, mRating = t.f會員評分 }) .OrderBy(t => Guid.NewGuid()).Take(1); return(Json(x, JsonRequestBehavior.AllowGet)); }
public ActionResult New(C回覆 y) { dbJoutaEntities db = new dbJoutaEntities(); tComment x = new tComment(); x.f標題 = Request.Form["f標題"]; x.f意見 = Request.Form["f意見"]; x.f性別 = Request.Form["f性別"]; x.f意見類型 = Request.Form["f意見類型"]; x.f聯絡人 = Request.Form["f聯絡人"]; x.f電子郵件 = Request.Form["f電子郵件"]; x.f電話 = Request.Form["f電話"]; x.f意見時間 = DateTime.Now.ToString(); x.f意見狀態 = "未回覆"; db.tComment.Add(x); db.SaveChanges(); string message = "傳送成功"; ViewBag.ll = message; return(View()); }
public ActionResult QuickMatch(int tabNum, double?curLat, double?curLng) { dbJoutaEntities db = new dbJoutaEntities(); //tabNum 0飯局 1旅遊 //curLat curLng 現在定位經緯度 if (tabNum == 0) { if (curLat != null && curLng != null) { var x = (from t in db.tActivity where (t.f活動類型 == "飯局") && (t.f活動經度 > curLng - 0.02) && (t.f活動經度 < curLng + 0.02) && (t.f活動緯度 > curLat - 0.02) && (t.f活動緯度 < curLat + 0.02) select new { mImg = t.f活動團圖, mContent = t.f活動內容, mSort = t.f活動分類, mPlace = t.f活動地區, mEstimate = t.f活動預算, mView = t.f活動瀏覽次數, mLike = t.f活動讚數, mTitle = t.f活動標題, mName = t.tMember.f會員名稱, mDeadline = t.f活動招募截止時間 }) .OrderBy(t => Guid.NewGuid()).Take(1); return(Json(x, JsonRequestBehavior.AllowGet)); } else { var x = (from t in db.tActivity where t.f活動類型 == "飯局" select new { mImg = t.f活動團圖, mContent = t.f活動內容, mSort = t.f活動分類, mPlace = t.f活動地區, mEstimate = t.f活動預算, mView = t.f活動瀏覽次數, mLike = t.f活動讚數, mTitle = t.f活動標題, mName = t.tMember.f會員名稱, mDeadline = t.f活動招募截止時間 }) .OrderBy(t => Guid.NewGuid()).Take(1); return(Json(x, JsonRequestBehavior.AllowGet)); } } else { if (curLat != null && curLng != null) { var x = (from t in db.tActivity where (t.f活動類型 == "旅遊") && (t.f活動經度 > curLng - 0.02) && (t.f活動經度 < curLng + 0.02) && (t.f活動緯度 > curLat - 0.02) && (t.f活動緯度 < curLat + 0.02) select new { mImg = t.f活動團圖, mContent = t.f活動內容, mSort = t.f活動分類, mPlace = t.f活動地區, mEstimate = t.f活動預算, mView = t.f活動瀏覽次數, mLike = t.f活動讚數, mTitle = t.f活動標題, mName = t.tMember.f會員名稱, mDeadline = t.f活動招募截止時間 }) .OrderBy(t => Guid.NewGuid()).Take(1); return(Json(x, JsonRequestBehavior.AllowGet)); } else { var x = (from t in db.tActivity where t.f活動類型 == "旅遊" select new { mImg = t.f活動團圖, mContent = t.f活動內容, mSort = t.f活動分類, mPlace = t.f活動地區, mEstimate = t.f活動預算, mView = t.f活動瀏覽次數, mLike = t.f活動讚數, mTitle = t.f活動標題, mName = t.tMember.f會員名稱, mDeadline = t.f活動招募截止時間 }) .OrderBy(t => Guid.NewGuid()).Take(1); return(Json(x, JsonRequestBehavior.AllowGet)); } } }