public ActionResult Autherize(REW_TATTOO_KORAT.Models.Member memberModel) { var memberDetail = db.Members.Where(x => x.UserName == memberModel.UserName && x.Password == memberModel.Password).FirstOrDefault(); if (memberDetail == null) { ViewBag.LoginErrorMessage = "Email หรือ เบอร์โทรศัพท์ไม่ถูกต้อง"; return(View("Index", memberModel)); } else { Session["UserName"] = memberDetail.UserName; Session["EMail"] = memberDetail.EMail; Session["Address"] = memberDetail.Address; Session["FirstName"] = memberDetail.FirstName; Session["LastName"] = memberDetail.LastName; Session["Tel"] = memberDetail.Tel; return(RedirectToAction("Index", "AdminTattoos")); } }
public ActionResult Create([Bind(Include = "UserName,FirstName,LastName,Address,Tel,EMail,Password")] Member member, REW_TATTOO_KORAT.Models.Member memberModel) { try { var emailChecked = new System.Net.Mail.MailAddress(member.EMail); if (member.Tel.Length < 10) { var phoneChecked = new System.Net.Mail.MailAddress(member.Tel); } if (ModelState.IsValid) { Session["UserName"] = memberModel.UserName; Session["EMail"] = memberModel.EMail; Session["Address"] = memberModel.Address; Session["FirstName"] = memberModel.FirstName; Session["LastName"] = memberModel.LastName; Session["Tel"] = memberModel.Tel; db.Members.Add(memberModel); db.SaveChanges(); var memberDetail = db.Members.OrderByDescending(x => x.UserName).FirstOrDefault(); Session["UserName"] = memberDetail.UserName; Session["EMail"] = memberDetail.EMail; Session["Address"] = memberDetail.Address; Session["FirstName"] = memberDetail.FirstName; Session["LastName"] = memberDetail.LastName; Session["Tel"] = memberDetail.Tel; } return(RedirectToAction("Index", "Home")); } catch { ViewBag.ErrorCHK = "True"; ViewBag.LoginErrorMessageTEL = "เบอร์โทรต้องมี 10 หลัก"; ViewBag.LoginErrorMessageEMAIL = "กรุณาตรวจสอบ Email"; ViewBag.LoginErrorMessageUSERNAME = "******"; return(View(memberModel)); } }