public ActionResult Register(User user, int Role) { if (Members.Login()) { return(RedirectToAction(string.Empty, PortalController.SController)); } if (user == null || (!RolesInt.Anbar.Equals(Role) && !RolesInt.Tajer.Equals(Role))) { return(View()); } List <string> Errorlist = user.Validate(); if (!Errorlist.Any()) { user.RoleID = Role; user.Password = user.Password.GetMd5Hash(); user.Token = ""; user.TryCount = 0; user.LastLoginDate = DateTime.Now; user.Edite = false; user.Validate = false; db.Users.Add(user); db.SaveChanges(); user.Token = user.ID.ToString(CultureInfo.CurrentCulture).GetMd5Hash(); db.SaveChanges(); ViewBag.error = "ثبت نام انجام شد"; return(View(SIndex)); } else { foreach (string item in Errorlist) { ModelState.AddModelError(item, item); } } return(View()); }
private static void UpdatePayment(Payment Payment, string StatusPayment, long SaleRefrenceID, string RefID, int StatePortal = 0) { var p = db.Payments.Find(Payment); p.StatusPayment = StatusPayment; p.SaleReferenceId = SaleRefrenceID; p.StatePortal = StatePortal; if (RefID != null) { p.ReferenceNumber = RefID; } db.SaveChanges(); db.Dispose(); }
public static bool Changepass(string oldpass, string newpass, string confirm) { oldpass = oldpass.GetMd5Hash(); newpass = newpass.GetMd5Hash(); confirm = confirm.GetMd5Hash(); try { var user = db.Users.Where(i => i.Email.Equals(User.Email, StringComparison.OrdinalIgnoreCase) && i.Password == oldpass).FirstOrDefault(); if (user != null && confirm == newpass) { user.Password = newpass; db.SaveChanges(); return(true); } } catch { } return(false); }
public ActionResult SaveToken(string Token) { if (!string.IsNullOrEmpty(Token)) { Token token = db.Tokens.Where(i => i.NotificatioToken.Equals(Token, StringComparison.Ordinal)).FirstOrDefault(); if (token == null) { token = new Token() { NotificatioToken = Token, UserID = Members.User.ID }; db.Tokens.Add(token); db.SaveChanges(); return(Json(true)); } else { if (!token.UserID.Equals(Members.User.ID)) { token.UserID = Members.User.ID; db.SaveChanges(); } return(Json(true)); } } return(Json(false)); }