public ActionResult AddComment(Comment comment, string UserName) { int UserID = db.User_.Where(x => x.UserName == UserName).Select(x => x.ID).FirstOrDefault(); comment.UserID = UserID; comment.CreateDate = DateTime.Now; db.Comments.Add(comment); db.SaveChanges(); return(RedirectToAction("ProductDetails", new { id = comment.ProductID })); }
public ActionResult VerifyAccount(string id) { bool Status = false; using (EnstrumanSatisEntities db = new EnstrumanSatisEntities()) { db.Configuration.ValidateOnSaveEnabled = false; var v = db.User_.Where(x => x.ActivationCode == new Guid(id)).FirstOrDefault(); if (v != null) { v.IsEmailVerified = true; db.SaveChanges(); Status = true; } else { ViewBag.Message = "Geçersiz İstek"; } } ViewBag.Status = true; return(View()); }
public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] User_ user) { user.CreatedDate = DateTime.Now; bool Status = false; string message = ""; if (ModelState.IsValid) { #region //Email is already Exist var isExist = IsEmailExist(user.Email); if (isExist) { ModelState.AddModelError("EmailExist", "E-Posta Zaten Var"); return(View(user)); } var isExist2 = IsUserNameExist(user.UserName); if (isExist2) { ModelState.AddModelError("UserNameExist", "Kullanıcı Adı Kullanılmış"); return(View(user)); } #endregion #region Generate Activation Code user.ActivationCode = Guid.NewGuid(); #endregion #region Password Hashing user.Password = Crypto.Hash(user.Password); user.ConfirmPassword = Crypto.Hash(user.ConfirmPassword); user.IsEmailVerified = false; #endregion #region Save to Database using (EnstrumanSatisEntities db = new EnstrumanSatisEntities()) { db.User_.Add(user); db.SaveChanges(); SendVerificationLinkEmail(user.Email, user.ActivationCode.ToString()); message = " Hesap etkinleştirme bağlantısı " + user.Email + " e-posta adresinize gönderildi"; Status = true; } #endregion } else { message = "Geçersiz İstek"; } ViewBag.Message = message; ViewBag.Status = Status; return(View(user)); }