public ActionResult ForgetPassword(CMember m) { List <CMember> SELECTMember = CMemberFactory.fn會員查詢(); CMember cMember = SELECTMember.FirstOrDefault(n => n.fAccount == m.fAccount); if (cMember != null) { System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); msg.To.Add(m.fAccount); msg.From = new MailAddress("*****@*****.**", "Not$edge官方網站", System.Text.Encoding.UTF8); msg.Subject = "Not$edge官方網站-忘記密碼連結網址"; //郵件標題 msg.SubjectEncoding = System.Text.Encoding.UTF8; //郵件標題編碼 msg.Body = "請點擊此連結-> https://noteledge.azurewebsites.net/Member/PasswordSetup/" + cMember.fThePasswordURL; //郵件內容 msg.BodyEncoding = System.Text.Encoding.UTF8; //郵件內容編碼 msg.IsBodyHtml = true; //是否是HTML郵件 //msg.Priority = MailPriority.High;//郵件優先級 SmtpClient client = new SmtpClient(); client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "inno2100"); //這裡要填正確的帳號跟密碼 client.Host = "smtp.gmail.com"; //設定smtp Server client.Port = 25; //設定Port client.EnableSsl = true; //gmail預設開啟驗證 client.Send(msg); //寄出信件 client.Dispose(); msg.Dispose(); ViewBag.Message = m.fAccount + "已發送驗證成功,請查看您的Email"; return(View("../Member/ForgetPassword", "_Layout")); } else { ViewBag.Message = "!查無此信箱填寫不正確,請重新輸入"; return(View("../Member/ForgetPassword", "_Layout")); } }
//將選取的對象加入黑名單 public string intoblacklist(int memberid, string blackreason) { var goblacklist = CMemberFactory.fn會員查詢().FirstOrDefault(g => g.fMemberId == memberid); if (goblacklist.fIsBanned == true)//判斷是否已經是黑名單 避免重複加入黑名單 { ViewBag.blacklist = "此會員已是黑名單會員"; return("已是黑名單成員"); } else { goblacklist.fIsBanned = true; CMemberFactory.fn會員更新(goblacklist); CBlackListFactory.fn黑名單新增(new CBlackList() { fLockDateTime = DateTime.UtcNow.AddHours(08), fMemberId = memberid, fReason = blackreason }); CNotice c = new CNotice(); c.fNoticeDatetime = DateTime.Now; c.fNoticeContent = "此帳號因發言屢次違規已被設為黑名單,期間內無法針對商品進行留言"; c.fCategoryType = "管理員"; c.fLink = "超連結"; c.fMemberId = goblacklist.fMemberId; CNoticeFactory.fn通知訂單訊息新增(c); return("黑名單更新成功!"); } }
// GET: ProductDetail public ActionResult ProductDetail(int ProductId) { //登入的會員資訊 CMember member = (CMember)Session[CMemberSession.Session_Login_User]; //防止未登入者進入 if (member == null) { return(RedirectToAction("../Member/Login")); } //所有會員資訊 List <CMember> lsMember = CMemberFactory.fn會員查詢().ToList(); List <CMember> Isbanned = CMemberFactory.fn會員查詢().Where(n => n.fMemberId == member.fMemberId).ToList(); //所選到的商品 CProduct product = CProductFactory.fn商品查詢().FirstOrDefault(p => p.fProductId == ProductId); //該商品的賣家資訊 CMember memberseller = CMemberFactory.fn會員查詢().FirstOrDefault(m => m.fMemberId == product.fMemberSellerId); //該商品的圖片(多個) List <CProductPicture> lsProductPicture = CProductPictureFactory.fn商品圖片查詢().Where(p => p.fProductId == ProductId).ToList(); //該商品的類別(多個) List <CProductCompare> lsCategory = CProductCompareFactory.fn商品類別對照查詢().Where(c => c.fProductId == ProductId).ToList(); //該商品的留言(多個) List <CComment> lsProductComment = CCommentFactory.fn留言查詢().Where(c => c.fProductId == ProductId).ToList(); List <CProductRank> lsProductRank = CProductRankFactory.fn評價查詢(ProductId).ToList(); //新增瀏覽紀錄 CProductBrowse productBrowse = new CProductBrowse() { fBrowseDataTime = DateTime.UtcNow.AddHours(08), fProductId = ProductId }; CProductBrowseFactory.fn商品瀏覽紀錄新增(product, productBrowse); List <CProductDetailVM> lsProductDetail = new List <CProductDetailVM>(); CProductDetailVM productDetailVM = new CProductDetailVM() { lsMember = lsMember, MemberSeller = memberseller, Product = product, lsProductPicture = lsProductPicture, lsProductCategory = lsCategory, lsProductComment = lsProductComment, lsProductRank = lsProductRank, Isbanned = Isbanned }; return(View(productDetailVM)); }
public int ToDetial() { //登入的會員資訊 CMember member = (CMember)Session[CMemberSession.Session_Login_User]; List <CMember> SELECTMember = CMemberFactory.fn會員查詢(); CMember cMember = SELECTMember.FirstOrDefault(n => n.fMemberId == member.fMemberId); return(cMember.fMoneyPoint); }
public static int fn訂單商品累積量() { List <CMember> lsmember = CMemberFactory.fn會員查詢().ToList(); List <int> lsordertotal = new List <int>(); foreach (var m in lsmember) { int ordertotal = COrderFactory.fn訂單查詢(m).Count(); lsordertotal.Add(ordertotal); } int total = lsordertotal.Sum(); return(total); }
public static int fn訂單總金額() { List <CMember> lsmember = CMemberFactory.fn會員查詢().ToList(); List <int> lsprice = new List <int>(); foreach (var m in lsmember) { int price = COrderFactory.fn訂單查詢(m).Sum(p => p.fTotalPrice); lsprice.Add(price); } int sum = lsprice.Sum(); return(sum); }
public string PasswordChange(CMemberEditor m) { List <CMember> SELECTMember = CMemberFactory.fn會員查詢(); CMember member = Session[CMemberSession.Session_Login_User] as CMember; CMember cMember = SELECTMember.FirstOrDefault(n => n.fMemberId == member.fMemberId); if (m.NewfPassword == null || m.ChackNewfPassword == null) { ViewBag.Error = "!不可為空,請輸入密碼"; CMemberEditPassword editPassword = new CMemberEditPassword(); editPassword.PasswordMassage = ViewBag.Error; Session[CMemberSession.Session_Change_Password] = editPassword; return(ViewBag.Error); } else if (m.NewfPassword != m.ChackNewfPassword) { ViewBag.Error = "!與上方密碼不相符"; CMemberEditPassword editPassword = new CMemberEditPassword(); editPassword.PasswordMassage = ViewBag.Error; Session[CMemberSession.Session_Change_Password] = editPassword; return(ViewBag.Error); } else if (m.NewfPassword.Length < 5 || m.NewfPassword.Length > 15) { ViewBag.Error = "!密碼請符合,5字元-15字元之間"; CMemberEditPassword editPassword = new CMemberEditPassword(); editPassword.PasswordMassage = ViewBag.Error; Session[CMemberSession.Session_Change_Password] = editPassword; return(ViewBag.Error); } else if (cMember.fPassword == m.NewfPassword) { ViewBag.Error = "!新密碼與舊密碼相符"; CMemberEditPassword editPassword = new CMemberEditPassword(); editPassword.PasswordMassage = ViewBag.Error; Session[CMemberSession.Session_Change_Password] = editPassword; return(ViewBag.Error); } else { ViewBag.PasswordTrue = "修改成功"; cMember.fPassword = m.ChackNewfPassword; CMemberFactory.fn會員更新(cMember); Session[CMemberSession.Session_Login_User] = cMember; return(ViewBag.PasswordTrue); } }
public ActionResult MemberImage(CMemberEditor m) { CMember member = Session[CMemberSession.Session_Login_User] as CMember; List <CMember> SELECTMember = CMemberFactory.fn會員查詢(); CMember cMember = SELECTMember.FirstOrDefault(n => n.fMemberId == member.fMemberId); if (m.MemberImage != null) { //string photoName = Guid.NewGuid().ToString(); //photoName += Path.GetExtension(m.MemberImage.FileName); ////m.MemberImage.SaveAs(Environment.GetEnvironmentVariable("HOME") + //// "\\site\\wwwroot\\Image\\MemberImage" + photoName); ////var A = Environment.GetEnvironmentVariable("HOME") + //// "\\site\\wwwroot\\Image\\MemberImage"+ photoName; //var A = Server.MapPath(@"~/Image/MemberImage/" + photoName); //m.MemberImage.SaveAs(Server.MapPath("~/Image/MemberImage/" + photoName)); //var CLIENT_ID = "b6ff140d7b00eef"; //var CLIENT_SECRET = "5008867fee0b01b1a3e9ccbc0d82ccee76290f7d"; ////建立ImgurClient(其中的"CLIENT_ID", "CLIENT_SECRET"要換成你自己的) //var client = new ApiClient(CLIENT_ID, CLIENT_SECRET); //var httpClient = new HttpClient(); //var endpoint = new ImageEndpoint(client, httpClient); ////var ImgPath = Environment.GetEnvironmentVariable("HOME") + //// "\\site\\wwwroot\\Image\\MemberImage"+ photoName; //var ImgPath = Server.MapPath(@"~/Image/MemberImage/" + photoName); //IImage image; ////取得圖片檔案FileStream //using (var fs = new FileStream(ImgPath, FileMode.Open)) //{ // image = endpoint.UploadImageAsync(fs).GetAwaiter().GetResult(); //} cMember.fPhoto = "../Image/MemberImage/MemberPreset.jpg"; //System.IO.File.Delete(ImgPath); //cMember.fPhoto = "../Image/MemberImage/" + photoName; CMemberFactory.fn會員更新(cMember); Session[CMemberSession.Session_Login_User] = cMember; return(View("../Member/MemberSetup", "_Layout")); } else { return(View("../Member/MemberSetup", "_Layout")); } }
public ActionResult Login(CMember m, CMemberBrowse browse) { List <CMember> SELECTMember = CMemberFactory.fn會員查詢(); CMember member = SELECTMember.FirstOrDefault(n => n.fAccount == m.fAccount); string code = Request.Form["code"].ToString(); if (member == null) { ViewBag.LoginMessage = "!沒有該使用者帳戶"; return(View()); } if (!member.fPassword.Equals(m.fPassword)) { ViewBag.LoginMessage = "!密碼不符"; return(View()); } if (code != TempData["code"].ToString()) { ViewBag.code = code; ViewBag.LoginMessage = "!驗證碼錯誤"; return(View()); } if (m.Remember_Check != null) { CMemberBrowseFactory.fn會員瀏覽紀錄新增(member); member.fLastLoginDateTime = DateTime.UtcNow.AddHours(08); CMemberFactory.fn會員更新(member); ViewBag.code = code; Session[CMemberSession.Session_Login_User] = member; Session[CMemberSession.Session_Login_Remember] = member; return(View("../Home/MyHome")); } else { CMemberBrowseFactory.fn會員瀏覽紀錄新增(member); member.fLastLoginDateTime = DateTime.UtcNow.AddHours(08); CMemberFactory.fn會員更新(member); ViewBag.code = code; ViewBag.Ans = TempData["code"]; ViewBag.Result = "驗證正確"; Session[CMemberSession.Session_Login_User] = member; Session[CMemberSession.Session_Login_Remember] = null; return(RedirectToAction("../Home/MyHome")); } }
public ActionResult PasswordSetup(CMemberEditor m, string id) { List <CMember> SELECTMember = CMemberFactory.fn會員查詢(); CMember cMember = SELECTMember.FirstOrDefault(n => n.fThePasswordURL == id); if (cMember != null && m.ChackNewfPassword == m.NewfPassword) { cMember.fPassword = m.ChackNewfPassword; CMemberFactory.fn會員更新(cMember); id = ""; return(RedirectToAction("../Member/Login")); } else { ViewBag.Error = "!與上方密碼不相符"; return(View("../Member/PasswordSetup", "_Layout")); } }
public ActionResult PurchaseList(int fMemberId) { //登入的會員資訊 CMember Member = (CMember)Session[CMemberSession.Session_Login_User]; //防止未登入者進入 if (Member == null) { return(RedirectToAction("../Member/Login")); } List <COrder> lsorder = COrderFactory.fn訂單查詢(Member).ToList(); List <CMemberOrderSelectVM> lsdetailorder = CMemberFactory.fn會員訂單個人查詢(Member).ToList(); List <CMember> lsmemberseller = new List <CMember>(); foreach (var item in lsdetailorder) { CProduct product = new CProduct(); product = CProductFactory.fn商品查詢().FirstOrDefault(p => p.fTheRemovedDate == null && p.fProductId == item.fProductId); if (product == null) { break; } CMember memberseller = new CMember(); memberseller = CMemberFactory.fn會員查詢().FirstOrDefault(m => m.fMemberId == product.fMemberSellerId); lsmemberseller.Add(memberseller); } //未下架的商品(含商品封面圖片) List <CProductPicture> lsproductpic = CProductPictureFactory.fn商品圖片查詢().Where(p => p.fTheRemovedDate == null).DistinctBy(p => p.fProductId).OrderBy(p => p.fProductId).ToList(); CPurchaseListVM PurchaseListVM = new CPurchaseListVM() { lsMemberSeller = lsmemberseller, lsProductPicture = lsproductpic, lsOrder = lsorder, lsOrderDetail = lsdetailorder }; return(PartialView("_PurchaseList", PurchaseListVM)); }
// GET: ManagerSystem public ActionResult HomePage(CMember c) { CAdmin admin = Session[CAdminSession.Session_Login_User] as CAdmin; if (admin == null) { return(RedirectToAction("../Member/AdminLogin")); } //資安 未登入時會跳回登入頁面 int membercount = CMemberFactory.fn會員查詢().Count(); //統計會員數量 int memberbrowse = CMemberBrowseFactory.fn會員瀏覽紀錄查詢().Count(); //統計總瀏覽量 int totalprice = COrderFactory.fn訂單總金額(); //統計金額交易量 int totalorder = COrderFactory.fn訂單商品累積量(); //總訂單數量 ViewBag.totalprice = totalprice.ToString("c0"); ViewBag.browse = memberbrowse.ToString(); ViewBag.membercount = membercount.ToString(); ViewBag.totalorder = totalorder; List <CProduct> lsproduct = CProductFactory.fn商品查詢().ToList();//撈出產品列表 List <CProductAndProductCompareViewModel> lsProductAndProductCompareVM = new List <CProductAndProductCompareViewModel>(); //產品與他的產品分類空列表 List <CProductCompare> lsproductcategory = new List <CProductCompare>();//產品分類空列表 foreach (var p in lsproduct) { List <CProductCompare> vlsProductcategory = CProductCompareFactory.fn商品類別對照查詢() .Where(m => m.fProductId == p.fProductId) .ToList();//抓出某產品所有產品分類 lsProductAndProductCompareVM.Add(new CProductAndProductCompareViewModel() { product = p, //單一產品 lsProductCompare = vlsProductcategory //上述單一產品的多項標籤 }); } CShoppingDataViewModel sd = new CShoppingDataViewModel() { lsMember = CMemberFactory.fn會員查詢().ToList(), ls產品與產品分類 = lsProductAndProductCompareVM };//將資訊加入列表 return(View("HomePage", "_LayoutAdmin", sd)); }
public ActionResult ProductIndex(int ProductId) { if (Session[CMemberSession.Session_Login_User] == null) { return(RedirectToAction("../Member/Login")); } CMember member = (CMember)Session[CMemberSession.Session_Login_User]; var lsChatBeau = CChatFactory.fn聊聊查詢(member).Select(n => new { from = n.fMemberFrom, to = n.fMemberTo, time = n.fSubmitDateTime }).OrderByDescending(n => n.time).Distinct().ToList(); List <CChatBeauViewModel> lsChatBeauVM = new List <CChatBeauViewModel>(); ViewBag.ProductId = ProductId; foreach (var q in lsChatBeau) { if (q.from == member.fMemberId) { var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.to).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList(); if (lsChatBeauVM.Any(n => n.BeauId == q.to) == false) { lsChatBeauVM.Add(new CChatBeauViewModel() { Beau = w.Single().surname + w.Single().name, BeauId = q.to, MyID = q.from }); } } else { var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.from).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList(); if (lsChatBeauVM.Any(n => n.BeauId == q.from) == false) { lsChatBeauVM.Add(new CChatBeauViewModel() { Beau = w.Single().surname + w.Single().name, BeauId = q.from, MyID = q.to }); } } } return(View(lsChatBeauVM)); }
//更換密碼-------------------------------------------------------------------------------\\ public ActionResult PasswordSetup(string id) { Session[CMemberSession.Session_Edit_Password] = null; Session[CMemberSession.Session_Change_Password] = null; Session[CMemberSession.Session_Login_User] = null; Session[CMemberSession.Session_Message_Count] = null; List <CMember> SELECTMember = CMemberFactory.fn會員查詢(); CMember cMember = SELECTMember.FirstOrDefault(n => n.fThePasswordURL == id); if (cMember != null) { ViewBag.MD5 = id; return(View("../Member/PasswordSetup", "_Layout")); } else { ViewBag.Message = "!再重新操作一次"; return(View("../Member/ForgetPassword", "_Layout")); } }
public void ToComment(string content, int pid) { //登入的會員資訊 CMember member = (CMember)Session[CMemberSession.Session_Login_User]; CComment c = new CComment(); c.fCommentDateTime = DateTime.UtcNow.AddHours(08); c.fContent = content; c.fIsBanned = false; c.fIsRetract = false; c.fLikeCount = 0; c.fMemberId = member.fMemberId; c.fProductId = pid; CCommentFactory.fn留言新增(c); var m = CMemberFactory.fn會員查詢().Where(z => z.fMemberId == member.fMemberId); GlobalHost.ConnectionManager.GetHubContext <ProductHub>().Clients.Group(ProductHub.getGroupIdString(pid)).newMessage(m.Single().fPhoto, m.Single().fTheNickName, DateTime.UtcNow.AddHours(08).ToString(), content); }
public string SignIn(CMember m, CNotice c) { List <CMember> SELECTMember = CMemberFactory.fn會員查詢(); CMember member = SELECTMember.FirstOrDefault(n => n.fAccount == m.fAccount); var data = ""; if (member == null) { string str = m.fPassword + "QAQ"; var md5 = CMemberFactory.MD5驗證碼新增(str); m.fMoneyPoint = 100; m.fPhoto = "../Image/MemberImage/Member.jpg"; m.fRegisterDateTime = DateTime.UtcNow.AddHours(08); m.fLastLoginDateTime = DateTime.UtcNow.AddHours(08); m.fIsVIP = false; m.fIsBanned = false; m.fThePasswordURL = md5; m.fTheAddress = m.fCity + m.fTown + m.fTheAddress; CMemberFactory.fn會員新增(m); //會員註冊訊息新增---------------------------------------------------------------\\ List <CMember> SELECTMember2 = CMemberFactory.fn會員查詢(); CMember member2 = SELECTMember2.FirstOrDefault(n => n.fAccount == m.fAccount); c.fNoticeDatetime = DateTime.UtcNow.AddHours(08); c.fNoticeContent = m.fFirstName + m.fLastName + "歡迎加入Notedge!"; c.fCategoryType = "系統"; c.fLink = "我是超連結"; c.fMemberId = member2.fMemberId; CNoticeFactory.fn通知訊息新增(member2, c); //會員註冊新增未分類筆記----------------------------------------------------------\\ CNoteFolderFactory.fn建立預設筆記資料夾(member2); data = "新增成功"; return(data); } else { data = "新增失敗"; ViewBag.Message = "信箱與人重複,請重新輸入"; return(data); } }
//將選取的對象加入黑名單 public string commentboard(int commentid, string content, int memberid) { CAdmin admin = Session[CAdminSession.Session_Login_User] as CAdmin; var comment = CCommentFactory.fn留言查詢().FirstOrDefault(m => m.fCommentId == commentid); comment.fContent = content; comment.fIsBanned = true; CCommentFactory.fn留言更新(comment); var member = CMemberFactory.fn會員查詢().FirstOrDefault(n => n.fMemberId == memberid); CNotice c = new CNotice(); c.fNoticeDatetime = DateTime.UtcNow.AddHours(08); c.fNoticeContent = "此留言因涉及違規發言已被遮蔽"; c.fCategoryType = "管理員"; c.fLink = "超連結"; c.fMemberId = member.fMemberId; CNoticeFactory.fn通知訂單訊息新增(c); return("遮蔽原因更新成功!"); }
//將選取的對象解除黑名單 public string unlockBlacklist(int bannid, int memberid) { CAdmin admin = Session[CAdminSession.Session_Login_User] as CAdmin; List <CBlackList> blacklist = new List <CBlackList>(); var unlock = CBlackListFactory.fn黑名單查詢().FirstOrDefault(m => m.fBannedId == bannid); var member = CMemberFactory.fn會員查詢().FirstOrDefault(n => n.fMemberId == memberid); member.fIsBanned = false; CMemberFactory.fn會員更新(member); CBlackListFactory.fn黑名單刪除(unlock); CNotice c = new CNotice(); c.fNoticeDatetime = DateTime.UtcNow.AddHours(08); c.fNoticeContent = "此帳號已從黑名單解鎖"; c.fCategoryType = "管理員"; c.fLink = "超連結"; c.fMemberId = member.fMemberId; CNoticeFactory.fn通知訂單訊息新增(c); return("解鎖成功!"); }
//GET: ShoppingHome public ActionResult Index() { //登入的會員資訊 CMember member = (CMember)Session[CMemberSession.Session_Login_User]; //防止未登入者進入 if (member == null) { return(RedirectToAction("../Member/Login")); } //未下架的商品(含商品封面圖片) List <CProductPicture> lsproduct = CProductPictureFactory.fn商品圖片查詢().Where(p => p.fTheRemovedDate == null).DistinctBy(p => p.fProductId).OrderBy(p => p.fProductId).ToList(); //裝多個CShoppingHomeVM的容器 List <CShoppingHomeVM> lsshoppinghomeVM = new List <CShoppingHomeVM>(); foreach (var product in lsproduct) { //撈出該商品的賣家資訊 CMember memberseller = CMemberFactory.fn會員查詢().FirstOrDefault(m => m.fMemberId == product.fMemberSellerId); //撈出該商品的類別 List <CProductCompare> category = CProductCompareFactory.fn商品類別對照查詢().Where(c => c.fProductId == product.fProductId).ToList(); //CShoppingHomeVM內的變數給值 CShoppingHomeVM shoppinghomeVM = new CShoppingHomeVM() { member = memberseller, lsproductcategory = category, productpicture = product, }; lsshoppinghomeVM.Add(shoppinghomeVM); } return(View("Index", lsshoppinghomeVM)); }
public void ToOrder(int totalprice, int remain, int cartId) { CMember member = (CMember)Session[CMemberSession.Session_Login_User];//會員 COrder o = new COrder(); o.fPurchaseDate = DateTime.UtcNow.AddHours(08); o.fTotalPrice = totalprice; o.fMemberId = member.fMemberId; COrderFactory.fn訂單新增(o); CMemberFactory.fn會員更新點數(member, remain); CNotice c = new CNotice(); c.fCategoryType = "系統"; c.fLink = "超連結"; c.fNoticeDatetime = DateTime.UtcNow.AddHours(08); c.fMemberId = member.fMemberId; c.fNoticeContent = "您的訂單已完成了"; CNoticeFactory.fn通知訂單訊息新增(c); List <CCartProduct> CP = CCartProductFactory.fn購物車商品個人查詢(cartId).ToList(); var f = CNoteFolderFactory.fn筆記資料夾查詢(member).Where(q => q.fFolderName == "未分類筆記").ToList(); int orderid = COrderFactory.fn訂單查詢(member).LastOrDefault().fOrderId; foreach (var a in CP) { CDetailOrderFactory.fn訂單明細新增(orderid, a.fProductId); CNotice c1 = new CNotice(); c1.fCategoryType = "銷售"; c1.fLink = "超連結"; c1.fNoticeDatetime = DateTime.UtcNow.AddHours(08); c1.fMemberId = a.fMemberSellerId; c1.fNoticeContent = "您的" + a.fName + "已被購買"; CNoticeFactory.fn通知訂單訊息新增(c1); CIncome i1 = new CIncome(); i1.fIncome = a.fPrice; i1.fPaymentDateTime = DateTime.UtcNow.AddHours(08); i1.fIncomeCategory = "獲利"; i1.fMemberId = a.fMemberSellerId; CIncomeFactory.fn公司獲利新增(i1); var point = CMemberFactory.fn會員查詢().Where(z => z.fMemberId == a.fMemberSellerId); int point1 = (point.Single().fMoneyPoint) + a.fPrice; CMember cm1 = new CMember(); cm1.fMemberId = point.Single().fMemberId; CMemberFactory.fn會員更新點數(cm1, point1); var t = CNoteFactory.fn私人筆記全部查詢().Where(q => q.fFolderId == f.Single().fFolderId).ToList(); int t1 = t.Count(); CNote n = new CNote(); n.fNoteListName = a.fName; n.fCreateDateTime = DateTime.UtcNow.AddHours(08); n.fEditDateTime = DateTime.UtcNow.AddHours(08); n.fNoteListLevel = t1; n.fIsMyFavourite = false; n.fIsTrash = false; n.fFolderId = f.Single().fFolderId; n.fJsonContent = a.fContent; n.fTheShareLink = null; n.fTheContactPerson = null; n.fHTMLContent = ""; CNoteFactory.fn訂單私人筆記新增(n); } CCartFactory.fn購物車個人更新(cartId); }
public string MemberSetup(CMemberEditor m) { var data = ""; CMember member = Session[CMemberSession.Session_Login_User] as CMember; if (m.fPhoto == null && m.NewfPassword == null) { List <CMember> SELECTMember = CMemberFactory.fn會員查詢(); CMember cMember = SELECTMember.FirstOrDefault(n => n.fMemberId == member.fMemberId); if (cMember != null) { if (m.MemberImage != null) { string photoName = Guid.NewGuid().ToString(); photoName += Path.GetExtension(m.MemberImage.FileName); var A = Server.MapPath(@"~/Image/MemberImage/" + photoName); m.MemberImage.SaveAs(Server.MapPath("../Image/MemberImage/" + photoName)); var CLIENT_ID = "b6ff140d7b00eef"; var CLIENT_SECRET = "5008867fee0b01b1a3e9ccbc0d82ccee76290f7d"; //建立ImgurClient(其中的"CLIENT_ID", "CLIENT_SECRET"要換成你自己的) var client = new ApiClient(CLIENT_ID, CLIENT_SECRET); var httpClient = new HttpClient(); var endpoint = new ImageEndpoint(client, httpClient); var ImgPath = Server.MapPath(@"~/Image/MemberImage/" + photoName); IImage image; //取得圖片檔案FileStream using (var fs = new FileStream(ImgPath, FileMode.Open)) { image = endpoint.UploadImageAsync(fs).GetAwaiter().GetResult(); } cMember.fPhoto = image.Link; System.IO.File.Delete(ImgPath); //顯示圖檔位置 Response.Write("Image uploaded. Image Url: " + image.Link); m.MemberImage.SaveAs(A); cMember.fAccount = m.fAccount; cMember.fPassword = m.fPassword; cMember.fFirstName = m.fFirstName; cMember.fLastName = m.fLastName; cMember.fTheNickName = m.fTheNickName; cMember.fGender = m.fGender; cMember.fBirthDay = m.fBirthDay; cMember.fTheAddress = m.fTheAddress; cMember.fMobilePhone = m.fMobilePhone; CMemberFactory.fn會員更新(cMember); Session[CMemberSession.Session_Login_User] = cMember; data = "修改成功"; return(data); } else { cMember.fAccount = m.fAccount; cMember.fPassword = m.fPassword; cMember.fFirstName = m.fFirstName; cMember.fLastName = m.fLastName; cMember.fTheNickName = m.fTheNickName; cMember.fGender = m.fGender; cMember.fBirthDay = m.fBirthDay; cMember.fTheAddress = m.fTheAddress; cMember.fMobilePhone = m.fMobilePhone; CMemberFactory.fn會員更新(cMember); Session[CMemberSession.Session_Login_User] = cMember; data = "修改成功"; return(data); } } else { data = "修改失敗"; return(data); } } data = "修改失敗"; return(data); }
// GET: AllProduct public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page) { //登入的會員資訊 CMember member = (CMember)Session[CMemberSession.Session_Login_User]; //防止未登入者進入 if (member == null) { return(RedirectToAction("../Member/Login")); } //排序條件(日期/價格/下載量/讚數) ViewBag.CurrentSort = sortOrder; ViewBag.DateSortParm = String.IsNullOrEmpty(sortOrder) ? "Date" : ""; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; //記錄每頁商品數及目前頁數 int pageSize = 8; int pageNumber = (page ?? 1); //未下架的商品(含商品封面圖片) List <CProductPicture> lsproduct = CProductPictureFactory.fn商品圖片查詢().Where(p => p.fTheRemovedDate == null).DistinctBy(p => p.fProductId).OrderBy(p => p.fProductId).ToList(); //篩選商品(類別/名稱/描述) switch (searchString) { case "Education": List <CProductCompare> lscategory = CProductCompareFactory.fn商品類別對照查詢().Where(c => c.fCategoryName == "程式").ToList(); List <CProductPicture> lsproducttag1 = new List <CProductPicture>(); foreach (var item in lscategory) { CProductPicture producttag1 = new CProductPicture(); producttag1 = lsproduct.Where(p => p.fProductId == item.fProductId && p.fTheRemovedDate == null).FirstOrDefault(); if (producttag1 != null) { lsproducttag1.Add(producttag1); } } lsproduct = lsproducttag1; break; case null: searchString = currentFilter; break; default: lsproduct = lsproduct.Where(p => p.fName.Contains(searchString) || p.fDescription.Contains(searchString)).ToList(); break; } switch (sortOrder) { case "New": lsproduct = lsproduct.Where(p => DateTime.UtcNow.AddHours(08).AddMonths(-1).Month < p.fLaunchDate.Month && p.fLaunchDate.Month <= DateTime.UtcNow.AddHours(08).Month).OrderByDescending(p => p.fLaunchDate).ToList(); break; case "Date": lsproduct = lsproduct.OrderBy(p => p.fLaunchDate).ToList(); break; case "Price": lsproduct = lsproduct.OrderBy(p => p.fPrice).ToList(); break; case "Price_desc": lsproduct = lsproduct.OrderByDescending(p => p.fPrice).ToList(); break; case "DownLoad_desc": lsproduct = lsproduct.OrderByDescending(p => p.fDownloadTimes).ToList(); break; case "Like_desc": lsproduct = lsproduct.OrderByDescending(p => p.fLikeCount).ToList(); break; case "Free": lsproduct = lsproduct.Where(p => p.fPrice == 0).ToList(); break; default: lsproduct = lsproduct.OrderByDescending(p => p.fLaunchDate).ToList(); break; } //裝多個CShoppingHomeVM的容器 List <CShoppingHomeVM> lsshoppinghomeVM = new List <CShoppingHomeVM>(); foreach (var product in lsproduct) { //撈出該商品的賣家資訊 CMember memberseller = CMemberFactory.fn會員查詢().FirstOrDefault(m => m.fMemberId == product.fMemberSellerId); //撈出該商品的類別 List <CProductCompare> category = CProductCompareFactory.fn商品類別對照查詢().Where(c => c.fProductId == product.fProductId).ToList(); //CShoppingHomeVM內的變數給值 CShoppingHomeVM shoppinghomeVM = new CShoppingHomeVM() { member = memberseller, lsproductcategory = category, productpicture = product, }; lsshoppinghomeVM.Add(shoppinghomeVM); } IPagedList <CShoppingHomeVM> pagedlist = lsshoppinghomeVM.ToPagedList(pageNumber, pageSize); return(View("Index", pagedlist)); }
// GET: Chat public ActionResult Index(int?productid, int?sellerid, string message) { if (Session[CMemberSession.Session_Login_User] == null) { return(RedirectToAction("../Member/Login")); } CMember member = (CMember)Session[CMemberSession.Session_Login_User]; if (productid == null || productid == 0) { var lsChatBeau = CChatFactory.fn聊聊查詢(member).Select(n => new { from = n.fMemberFrom, to = n.fMemberTo, time = n.fSubmitDateTime }).OrderByDescending(n => n.time).Distinct().ToList(); var lsChat = CChatFactory.fn聊聊查詢(member).Select(n => n).ToList(); List <CChatViewModel> lsChatVM = new List <CChatViewModel>(); List <CChatBeauViewModel> lsChatBeauVM = new List <CChatBeauViewModel>(); foreach (var q in lsChatBeau) { if (q.from == member.fMemberId) { var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.to).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList(); var e = CChatFactory.fn聊聊未讀查詢(q.from, q.to).ToList(); if (lsChatBeauVM.Any(n => n.BeauId == q.to) == false) { lsChatBeauVM.Add(new CChatBeauViewModel() { Beau = w.Single().surname + w.Single().name, BeauId = q.to, MyID = q.from, nRead = e.Single().fProductId }); } } else { var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.from).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList(); var e = CChatFactory.fn聊聊未讀查詢(q.from, q.to).ToList(); if (lsChatBeauVM.Any(n => n.BeauId == q.from) == false) { lsChatBeauVM.Add(new CChatBeauViewModel() { Beau = w.Single().surname + w.Single().name, BeauId = q.from, MyID = q.to, nRead = e.Single().fProductId }); } } } return(View(lsChatBeauVM)); } else { CChat c = new CChat(); c.fSubmitDateTime = DateTime.UtcNow.AddHours(08); c.fMessage = message; c.fIsRead = false; c.fIsRetract = false; c.fMemberFrom = member.fMemberId; c.fMemberTo = Convert.ToInt32(sellerid); c.fProductId = Convert.ToInt32(productid); CChatFactory.fn聊聊新增(c); GlobalHost.ConnectionManager.GetHubContext <ChatHub>().Clients.Group(sellerid.ToString()).newMessage(member.fMemberId, message, DateTime.UtcNow.AddHours(08), Convert.ToInt32(productid)); var lsChatBeau = CChatFactory.fn聊聊查詢(member).Select(n => new { from = n.fMemberFrom, to = n.fMemberTo, time = n.fSubmitDateTime }).OrderByDescending(n => n.time).Distinct().ToList(); var lsChat = CChatFactory.fn聊聊查詢(member).Select(n => n).ToList(); List <CChatViewModel> lsChatVM = new List <CChatViewModel>(); List <CChatBeauViewModel> lsChatBeauVM = new List <CChatBeauViewModel>(); foreach (var q in lsChatBeau) { if (q.from == member.fMemberId) { var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.to).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList(); if (lsChatBeauVM.Any(n => n.BeauId == q.to) == false) { lsChatBeauVM.Add(new CChatBeauViewModel() { Beau = w.Single().surname + w.Single().name, BeauId = q.to, MyID = q.from }); } } else { var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.from).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList(); if (lsChatBeauVM.Any(n => n.BeauId == q.from) == false) { lsChatBeauVM.Add(new CChatBeauViewModel() { Beau = w.Single().surname + w.Single().name, BeauId = q.from, MyID = q.to }); } } } return(View(lsChatBeauVM)); } //foreach (var q in lsChat) //{ // var p = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.fMemberFrom ).Select(n => new { surname = n.fFirstName,name = n.fLastName}).ToList(); // var o = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.fMemberTo).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList(); // if(q.fMemberFrom == member.fMemberId) // { // var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.fMemberTo).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList(); // lsChatVM.Add(new CChatViewModel() // { // beau = w.Single().surname+w.Single().name, // beauId = q.fMemberTo, // fromchatname = p.Single().surname + p.Single().name, // tochatname = o.Single().surname + o.Single().name, // fChatId = q.fChatId, // fSubmitDateTime = q.fSubmitDateTime, // fMessage = q.fMessage, // fIsRead = q.fIsRead, // fIsRetract = q.fIsRetract, // fMemberFrom = q.fMemberFrom, // fMemberTo = q.fMemberTo, // fProductId = q.fProductId // }); // } // else // { // var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.fMemberFrom).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList(); // lsChatVM.Add(new CChatViewModel() // { // beau = w.Single().surname + w.Single().name, // beauId = q.fMemberFrom, // fromchatname = p.Single().surname + p.Single().name, // tochatname = o.Single().surname + o.Single().name, // fChatId = q.fChatId, // fSubmitDateTime = q.fSubmitDateTime, // fMessage = q.fMessage, // fIsRead = q.fIsRead, // fIsRetract = q.fIsRetract, // fMemberFrom = q.fMemberFrom, // fMemberTo = q.fMemberTo, // fProductId = q.fProductId // }); // } //} }
//登入後主畫面-------------------------------------------------------------------------------\\ public ActionResult MyHome(string name, string id, CNotice c) { CMember member = Session[CMemberSession.Session_Login_User] as CMember; //創造一組亂數字串不重複的訂單編號 var str = "123456789ABCDEFGHIJKLMNPQRSTUVWXYZabcdefhijklmnorstuvwxz"; var next = new Random(); var builder = new StringBuilder(); for (var i = 0; i < 10; i++) { builder.Append(str[next.Next(0, str.Length)]); } //MerchantID(不可變動),MerchantTradeNo(亂數訂單編號),MerchantTradeDate(抓取當前日期時間) int MerchantID = 2000132; var MerchantTradeNo = builder; string MerchantTradeDate = DateTime.UtcNow.AddHours(08).ToString("yyyy/MM/dd hh:mm:ss"); /*tring ReturnUrl = "https://localhost:44300/Home/MyHome?id=" + MerchantTradeNo;*/ string ReturnUrl = "https://noteledge.azurewebsites.net/Home/MyHome?id=" + MerchantTradeNo; string ProductName = "Notedge尊爵鑽石豪華VIP頂級會員"; int Amount = 99; //把需要的資料作串接 string Url = "HashKey=5294y06JbISpM5x9&ChoosePayment=ALL&ChooseSubPayment=&ClientBackURL=" + ReturnUrl + "&EncryptType=1&ItemName=" + ProductName + "&MerchantID=" + MerchantID + "&MerchantTradeDate=" + MerchantTradeDate + "&MerchantTradeNo=" + MerchantTradeNo + "&PaymentType=aio&ReturnURL=" + ReturnUrl + "&StoreID=&TotalAmount=" + Amount + "&TradeDesc=建立全金流測試訂單&HashIV=v77hoKGq4kWxNNIS"; //串接好的資料轉成Encoded var Encoded = System.Web.HttpUtility.UrlEncode(Url); //Encoded 轉成 小寫 encoded var encoded = Encoded.ToLower(); //呼叫sha256_hash(encoded)轉換成SHA256 在轉換大寫 string SHA256 = sha256_hash(encoded).ToUpper(); //把資料傳到前端 ViewBag.MerchantID = MerchantID; ViewBag.MerchantTradeNo = MerchantTradeNo; ViewBag.MerchantTradeDate = MerchantTradeDate; ViewBag.SHA256 = SHA256; ViewBag.Url = ReturnUrl; ViewBag.ProductName = ProductName; ViewBag.Amount = Amount; if (id != null) { List <CMember> SelecteMember = CMemberFactory.fn會員查詢(); CMember cMember = SelecteMember.FirstOrDefault(n => n.fMemberId == member.fMemberId); cMember.fIsVIP = true; cMember.fMoneyPoint = cMember.fMoneyPoint + 500; CMemberFactory.fn會員更新(cMember); //成為VIP新增通知----------------------------------------------------------------------\\ c.fNoticeDatetime = DateTime.UtcNow.AddHours(08); c.fNoticeContent = cMember.fFirstName + cMember.fLastName + "您已成為Notedge尊爵鑽石豪華VIP頂級會員"; c.fCategoryType = "系統"; c.fLink = "連結"; c.fMemberId = member.fMemberId; CNoticeFactory.fn通知訊息新增(member, c); Session[CMemberSession.Session_Login_User] = cMember; if (Session[CMemberSession.Session_Login_User] == null && name == null) { Session[CMemberSession.Session_Login_User] = null; return(RedirectToAction("../Home/Index")); } else { ViewBag.name = name; return(View("../Home/MyHome", "_Layout")); } } if (Session[CMemberSession.Session_Login_User] == null && name == null) { Session[CMemberSession.Session_Login_User] = null; return(RedirectToAction("../Home/Index")); } else { if (name == null) { var SelectNoticess = CNoticeFactory.fn通知訊息查詢(member).Where(n => n.fCategoryType == "銷售" || n.fCategoryType == "評價留言").OrderByDescending(n => n.fNoticeDatetime); var SelectChats = CChatFactory.fn聊聊查詢(member).Where(n => n.fMemberTo == member.fMemberId).OrderByDescending(n => n.fSubmitDateTime); int MCounts = SelectChats.Count(); int SCounts = SelectNoticess.Count(); CMemberMessage memberMessage = new CMemberMessage(); if (Session[CMemberSession.Session_Message_Count] == null) { memberMessage.MessageBell = MCounts; Session[CMemberSession.Session_Message_Count] = memberMessage; } if (Session[CMemberSession.Session_sale_Count] == null) { memberMessage.SaleBell = SCounts; Session[CMemberSession.Session_sale_Count] = memberMessage; } return(View("../Home/MyHome", "_Layout")); } else { ViewBag.name = name; return(View("../Home/MyHome", "_Layout")); } } }