//Bill checkout public ActionResult SaveBill(FE_Delivery Item) { //valid if (DefaultView.GetRandomCapcha() != Item.CaptchaCode) { return(Json(new { success = false, message = "Mã xác minh không đúng." })); } var userID = ViewData["AuthUser"] == null ? 0 : ((AuthUser)ViewData["AuthUser"]).entryid; DefaultView.FE_Bill.BindFullBill(userID, Item); int resutl = FE_Bill.SaveBill(userID); return(Json(new { success = resutl > 0 })); }
public ActionResult Register(RegisterViewModel model) { if (DefaultView.GetRandomCapcha() != model.CaptchaCode) { ViewBag.message = "Mã xác minh không đúng."; return(View()); } if (model.ConfirmPassword != model.Password) { ViewBag.message = "Mật khẩu xác nhận không giống."; return(View()); } //get internal user with email & code IDbConnection dbConn = new OrmliteConnection().openConn(); var user = AuthUser.GetByCode(model.Email, LoginType.InternalLogin, null, false); if (user != null) { ViewBag.message = "Tài khoản đã tồn tại"; return(View()); } //create user internal user = new AuthUser(); user.password = SqlHelper.GetMd5Hash(model.Password); user.createdat = DateTime.Now; user.updatedat = DateTime.Now; user.entrycode = model.Email; user.entryname = model.Email; user.fullname = model.Email; user.email = model.Email; user.logintype = (int)LoginType.InternalLogin; user.loginprovider = ""; user.isactive = true; user.entryid = user.AddOrUpdate(user.entryid); var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, user.fullname), new Claim(ClaimTypes.Email, string.IsNullOrEmpty(user.email)?"":user.email), new Claim(ClaimTypes.PrimarySid, user.entryid.ToString()) }, "ApplicationCookie"); var ctx = Request.GetOwinContext(); var authManager = ctx.Authentication; authManager.SignIn(identity); return(RedirectToAction("Index", "Home")); }
public ActionResult Login(LogOnModel model, string returnUrl) { returnUrl = string.IsNullOrEmpty(returnUrl) ? "" : returnUrl; if (DefaultView.GetRandomCapcha() != model.CaptchaCode) { ViewBag.message = "Mã xác minh không đúng."; return(View()); } if (ModelState.IsValid) { IDbConnection dbConn = new OrmliteConnection().openConn(); var user = SSKD.Areas.Admin.Models.AuthUser.GetByCode(model.UserName, null, false); if (new AccountMembershipService().ValidateUser(model.UserName, model.Password)) { //FormsAuthentication.SetAuthCookie(model.UserName, true); //FormsAuthentication.SetAuthCookie(user.Id.ToString(), true); var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, user.entrycode), new Claim(ClaimTypes.Email, string.IsNullOrEmpty(user.email)?"":user.email), new Claim(ClaimTypes.PrimarySid, user.entryid.ToString()) }, "ApplicationCookie"); var ctx = Request.GetOwinContext(); var authManager = ctx.Authentication; authManager.SignIn(identity); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Tên đăng nhập hoặc mật khẩu không đúng."); } } return(View(model)); }
//Bill checkout public async Task <ActionResult> SaveContactRequest(FE_ContactRequest Item) { //valid if (DefaultView.GetRandomCapcha() != Item.CaptchaCode) { return(Json(new { success = false, message = "Mã xác minh không đúng." })); } var userID = ViewData["AuthUser"] == null ? 0 : ((AuthUser)ViewData["AuthUser"]).entryid; int resutl = FE_ContactRequest.SaveContactRequest(userID, Item); //send email string subject = "[sskd] - vừa có 1 đơn hàng mới"; //send ContactEmail await sendContactEmail(new List <string>() { ConfigurationManager.AppSettings.Get("EmailContact").ToString() }, subject, Item); return(Json(new { success = resutl > 0 })); }
public async Task <ActionResult> SaveContactRequest(FE_ContactRequest Item) { //valid if (DefaultView.GetRandomCapcha() != Item.CaptchaCode) { return(Json(new { success = false, message = "Mã xác minh không đúng." })); } var userID = ViewData["AuthUser"] == null ? 0 : ((AuthUser)ViewData["AuthUser"]).entryid; Item.Address = Item.Address ?? ""; int resutl = FE_ContactRequest.SaveContactRequest(userID, Item); //string subject = "[Contact] Thông tin liên hệ"; string subject = "[" + ((TopicContact)Item.TopicContact).DescriptionAttr().ToString() + "]"; subject += " - " + Item.EntryName ?? ""; //send ContactEmail await sendContactEmail(new List <string>() { ConfigurationManager.AppSettings.Get("EmailContact").ToString() }, subject, Item); return(Json(new { success = resutl > 0 })); }